Coding standards
Security in ResourceSpace
Developer reference
Database
User api session functions
Geolocation functions
Storage test functions

storage_test_cleanup()

Description

Delete only fixed manifest entries, children first. Never recursively delete enumerated content.
Unknown files or symlinks block cleanup and preserve recovery state for an administrator.

Parameters

ColumnTypeDefaultDescription
&$state array
$deadline: float
array_reverse$manifest['dirs']
['']; 0; while $state['cleanup_cursor'] < count$paths && $count++ < 16 && hrtimetrue / 1e9 < $deadline
$state array Mutable state, including a resumable cleanup cursor.
$deadline float Monotonic request deadline, in seconds.

Return

bool True once the private directory has been removed.

Location

include/storage_test_functions.php lines 296 to 319

Definition

 
function storage_test_cleanup(array &$state, float $deadline): bool
{
    
$manifest = storage_test_manifest();
    
$paths = array_merge(array_keys($manifest['files']), array_reverse($manifest['dirs']), ['']);
    
$count = 0;
    while (
$state['cleanup_cursor'] < count($paths) && $count++ < 16 && hrtime(true) / 1e9 < $deadline) {
        
$relative = $paths[$state['cleanup_cursor']];
        
$path = storage_test_path($state, $relative);
        if (
file_exists($path)) {
            
$directory = is_dir($path);
            
$metric = $directory ? 'directory_remove' : 'file_delete';
            
storage_test_measure($state, $metric, static function () use ($path, $directory): int {
                if (
$directory ? !rmdir($path) : !unlink($path)) {
                    throw new 
RuntimeException('storage_test_cleanup_error');
                }
                return 
1;
            });
            
$state['last_operation'] = ['kind' => $directory ? 'directory_removed' : 'file_deleted',
                
'path' => $relative === '' ? '.rs-storage-test-' . $state['id'] : $relative];
        }
        ++
$state['cleanup_cursor'];
    }
    return 
$state['cleanup_cursor'] === count($paths);
}

This article was last updated 13th November 2026 16:05 Europe/London time based on the source file dated 13th November 2026 11:40 Europe/London time.