Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the cache files are really removed #51920

Closed

Conversation

tolnaiz
Copy link

@tolnaiz tolnaiz commented Jun 26, 2024

Currently, config:clear, event:clear, and route:clear do not check if the cache files were actually removed.

If the user running the command has only read permissions for these files, the commands simply return a “… cache cleared successfully.” message without any indication that the files weren't removed.

This problem exists because Filesystem::delete doesn't throw an exception, just returns a boolean indicating whether unlink ran successfully on all the files provided. This return value is then ignored in the command handle.

For reference, here is the filesystem delete function which is called by the clear commands:

public function delete($paths)
{
$paths = is_array($paths) ? $paths : func_get_args();
$success = true;
foreach ($paths as $path) {
try {
if (@unlink($path)) {
clearstatcache(false, $path);
} else {
$success = false;
}
} catch (ErrorException) {
$success = false;
}
}
return $success;
}

Since this change might be considered breaking, I made the pull request to the master branch.

@taylorotwell
Copy link
Member

Just leaving as is for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants