You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If multiple requests try to activate a plugin concurrently, OnDiskUIAsset::delete may throw. The situation that arises is as follows:
one request starts the activation process, it checks whether the asset file exists
another request checks whether it exists AND removes the file
the original request tries to remove the file, but it doesn't exist anymore and an exception is thrown
To fix, OnDiskUIAsset should silence the unlink error and only throw if the file is not writable. This may require a bit of refactoring to the existing code.
The text was updated successfully, but these errors were encountered:
if (file_exists($file)) {
$result = @unlink($file);
if (!$result && file_exists($file)) {
thrownewException(...);
}
}
i.e. check file_exists again after removing, that way if a concurrent request already removed the file, then the exception will not be thrown because the file will be gone anyway.
I also suggest we move those file handling methods to Piwik\Filesystem.
If you think that's a good solution I could work on a PR.
If multiple requests try to activate a plugin concurrently, OnDiskUIAsset::delete may throw. The situation that arises is as follows:
To fix, OnDiskUIAsset should silence the unlink error and only throw if the file is not writable. This may require a bit of refactoring to the existing code.
The text was updated successfully, but these errors were encountered: