View Issue Details

IDProjectCategoryView StatusLast Update
0007625OXID eShop (all versions)Generalpublic2024-08-14 15:22
Reporteroxid0815 Assigned To 
PrioritynormalSeveritymajorReproducibilityrandom
Status confirmedResolutionopen 
Summary0007625: Fatal on writing cache files
DescriptionHi,

In OxidEsales\EshopEnterprise\Core\Cache\Generic\Connector\FileCacheConnector:_writeFile cache file were created via the fopen function. In some case, maybe when the cache file was already open through on other process, fopen can't open the resource and return false.

In that cases flock will fail with the Exception:
[2024-03-22 05:21:54] OXID Logger.ERROR: flock(): Argument
  1 ($stream) must be of type resource, bool given ["[object] (TypeError(code: 0): flock(): Argument
  1 ($stream) must be of type resource, bool given at /var/www/vhosts/vendor/oxid-esales/oxideshop-ee/Core/Cache/Generic/Connector/FileCacheConnector.php:240)\n[stacktrace]

The following source will solve the issue:
    protected function _writeFile($sFilePath, $oCacheItem, $iExpires) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
    {
        $rHandle = fopen($sFilePath, "w");
        if ($rHandle !== false) {
            flock($rHandle, LOCK_EX);
            fwrite($rHandle, serialize($oCacheItem));
            flock($rHandle, LOCK_UN);
            fclose($rHandle);
    
            touch($sFilePath, $iExpires);
        }
    }


Thanks for investigation and fixing.

Best regards.
Steps To ReproduceAdded by QA -SG-:
Issue is reproduced with OXID 6.5 and OXID 7.1 RC
1. Install EE
2. activate Caching under Master Settings -> Core Settings -> Caching -> Default Cache Backend -> with Cache Connector File System
3. Go to frontend and open a category page.
4. set Files in source/cache to 111 per chmod -R 111 source/cache to simulate problem with file
5. open frontend page again -> maintainance mode

The code changes make the code more robust.
TagsCache, Performance and Caching Rework
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

QA

2024-04-02 09:41

administrator   ~0016685

Thank you for reporting this issue,

we acknowlede this issue.

Best Regards QA -SG-