Skip to content

Fast cache clearing on Linux does not behave correctly #45

@icedream

Description

@icedream

The cache clearing command currently attempts to use a shortcut to move the sCompileDir out of the way for OXID to immediately create a new one:

https://github.com/OXIDprojects/oxrun/blob/2c6f8376aa12bd0bc6425908b782c371e5cad9ac/src/Oxrun/Command/Cache/ClearCommand.php#L46-51

Respective function snippet:

protected function unixFastClear($compileDir)
{
$compileDir = escapeshellarg($compileDir);
// Fast Process: Move folder and create new folder
passthru("mv ${compileDir} ${compileDir}_old && mkdir -p ${compileDir}/smarty");
// Low Process delete folder on slow HD
passthru("rm -Rf ${compileDir}_old");
}

If the shortcut is not used then instead PHP globbing is used:

foreach (glob($compileDir . DIRECTORY_SEPARATOR . '*') as $filename) {
if (!is_dir($filename)) {
unlink($filename);
}
}
foreach (glob($compileDir . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . '*') as $filename) {
if (!is_dir($filename)) {
unlink($filename);
}
}

PHP globbing does not match dotfiles such as .htaccess, which is a file placed by the OXID eShop installation itself to prevent public access to files inside this directory. Moving the directory itself out of the way and then deleting it will cause the .htaccess file to be deleted though.

Moving the directory is also problematic in setups where the sCompileDir is a mount point such as in Docker environments where this directory is a volume.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions