Page 1 of 1
[SOLVED] php warning unlink
Posted: Wed May 05, 2021 12:34 am
by aljo91258
Hi,
randomly I get this error message:
Warning: unlink(/home/customer/www/XXX.eu/storage/cache/cache.store.1619857657): No such file or directory in /home/customer/www/XXX.eu/public_html/YYYYYY/system/library/cache/file.php on line 17
Opencart version is 3.0.3.2 / PHP 7.3.27
I tried the language cache fix (
https://github.com/opencart/opencart/co ... 990171168e)
I created a file named "cache.store.1619857657"
I made "system/library/cache/file.php" folder writable with CHMOD 755
But nothing works - the warning continues to appear (also to users when they are on product pages)
Maybe somebody has a new idea?
Re: php warning unlink
Posted: Wed May 05, 2021 3:12 am
by OSWorX
aljo91258 wrote: ↑Wed May 05, 2021 12:34 am
.. the warning continues to appear (also to users when they are on product pages) ..
Beside this message, the first and most important action should be to
disable the Display Errors in your shop configuration after you set it live.
Re: php warning unlink
Posted: Wed May 05, 2021 4:18 am
by aljo91258
"Display Errors" is already disabled. Only "Log Errors" is on yes.
Re: php warning unlink
Posted: Wed May 05, 2021 7:43 am
by straightlight
The cache file library does not need to be set to CHMOD 0755. The storage needs to be outside of your www folder and recursively set to CHMOD 0755 and the files needs to remain the way they are on this folder. Then, ensure both config.php files are properly configured with your DIR_STORAGE constant.
Re: php warning unlink
Posted: Wed May 05, 2021 5:19 pm
by paulfeakins
aljo91258 wrote: ↑Wed May 05, 2021 12:34 am
Maybe somebody has a new idea?
Pay a developer from Commercial Support?
Re: php warning unlink
Posted: Wed May 05, 2021 7:19 pm
by ADD Creative
aljo91258 wrote: ↑Wed May 05, 2021 4:18 am
"Display Errors" is already disabled. Only "Log Errors" is on yes.
There is always a chance you will get a race condition as you can get the problem of:
Process 1 checks if the old cache file exists. Which it does.
Process 2 checks if the old cache file exists. Which it does.
Process 1 deletes the old cache file with unlink. Which will be successful.
Process 2 deletes the old cache file with unlink. Which will fail as process 1 has already deleted it.
As long as you have display errors set to off (in all three places) then there should not be an issue.
If you did want to suppress the warning in you logs, you could always add a @ in front of unlink at the line below.
https://github.com/opencart/opencart/bl ... le.php#L68
If you are getting a lot of unlink errors and the cache file does not exist. Then it could be an issue with the store cache not being read correctly. This would cause the store cache to be deleted and set on each request. Greatly increasing the chances of a race condition. Could be caused by a permission issue or a modification.
Re: php warning unlink
Posted: Thu May 06, 2021 10:01 pm
by aljo91258
Thank you for your comments.
For the moment I think I solved the issue, the site is workin fine. I simply deleted in storage/cache all cache.store.xxxxxxxx files. There were almost 1000 of them in the folder storage/cache and may be because of that, file operations broke down when new files came in. Therefore these new files couldn't be found later on. But why is it, that the old cache.storage.xxxx files are not deleted after a certain period of time and that they simply cumulate in this folder storage/cache?
Re: php warning unlink
Posted: Thu May 06, 2021 10:36 pm
by straightlight
aljo91258 wrote: ↑Thu May 06, 2021 10:01 pm
Thank you for your comments.
For the moment I think I solved the issue, the site is workin fine. I simply deleted in storage/cache all cache.store.xxxxxxxx files. There were almost 1000 of them in the folder storage/cache and may be because of that, file operations broke down when new files came in. Therefore these new files couldn't be found later on. But why is it, that the old cache.storage.xxxx files are not deleted after a certain period of time and that they simply cumulate in this folder storage/cache?
Ensure to keep the index.html file in the cache folder. However, now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.
Re: php warning unlink
Posted: Thu May 06, 2021 11:37 pm
by ADD Creative
aljo91258 wrote: ↑Thu May 06, 2021 10:01 pm
Thank you for your comments.
For the moment I think I solved the issue, the site is workin fine. I simply deleted in storage/cache all cache.store.xxxxxxxx files. There were almost 1000 of them in the folder storage/cache and may be because of that, file operations broke down when new files came in. Therefore these new files couldn't be found later on. But why is it, that the old cache.storage.xxxx files are not deleted after a certain period of time and that they simply cumulate in this folder storage/cache?
The unlink is trying to delete them, if it isn't then it could be a permissions or a configuration issue with storage/cache.
Re: php warning unlink
Posted: Mon Jul 22, 2024 8:34 pm
by parkookk
I changed the following a month a go and so far I haven't got any error since.
in
/system/library/cache/file.php
on line 17, change to:
unlink(realpath($file));
Re: php warning unlink
Posted: Tue Jul 23, 2024 7:17 pm
by paulfeakins
parkookk wrote: ↑Mon Jul 22, 2024 8:34 pm
I changed the following a month a go and so far I haven't got any error since.
in
/system/library/cache/file.php
on line 17, change to:
unlink(realpath($file));
Great! Maybe time to add [SOLVED] to the start of this topic title then.
Re: php warning unlink
Posted: Mon Jan 20, 2025 7:20 pm
by parkookk
parkookk wrote: ↑Mon Jul 22, 2024 8:34 pm
I changed the following a month a go and so far I haven't got any error since.
in
/system/library/cache/file.php
on line 17, change to:
unlink(realpath($file));
It didn't work, I still get those errors.
Re: php warning unlink
Posted: Mon Jan 20, 2025 7:23 pm
by parkookk
straightlight wrote: ↑Thu May 06, 2021 10:36 pm
aljo91258 wrote: ↑Thu May 06, 2021 10:01 pm
Thank you for your comments.
For the moment I think I solved the issue, the site is workin fine. I simply deleted in storage/cache all cache.store.xxxxxxxx files. There were almost 1000 of them in the folder storage/cache and may be because of that, file operations broke down when new files came in. Therefore these new files couldn't be found later on. But why is it, that the old cache.storage.xxxx files are not deleted after a certain period of time and that they simply cumulate in this folder storage/cache?
Ensure to keep the index.html file in the cache folder. However, now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.
There are no index file on this folder.
Re: php warning unlink
Posted: Mon Jan 20, 2025 8:19 pm
by ADD Creative
parkookk wrote: ↑Mon Jan 20, 2025 7:20 pm
parkookk wrote: ↑Mon Jul 22, 2024 8:34 pm
I changed the following a month a go and so far I haven't got any error since.
in
/system/library/cache/file.php
on line 17, change to:
unlink(realpath($file));
It didn't work, I still get those errors.
You can suppress the unlink errors with.
If you only want to suppress the errors caused by a race condition but log other errors try.
Code: Select all
if (!@unlink($file)) {
if (is_file($file)) {
unlink($file);
}
}
Re: php warning unlink
Posted: Mon Jan 20, 2025 9:02 pm
by parkookk
ADD Creative wrote: ↑Wed May 05, 2021 7:19 pm
aljo91258 wrote: ↑Wed May 05, 2021 4:18 am
"Display Errors" is already disabled. Only "Log Errors" is on yes.
There is always a chance you will get a race condition as you can get the problem of:
Process 1 checks if the old cache file exists. Which it does.
Process 2 checks if the old cache file exists. Which it does.
Process 1 deletes the old cache file with unlink. Which will be successful.
Process 2 deletes the old cache file with unlink. Which will fail as process 1 has already deleted it.
As long as you have display errors set to off (in all three places) then there should not be an issue.
If you did want to suppress the warning in you logs, you could always add a @ in front of unlink at the line below.
https://github.com/opencart/opencart/bl ... le.php#L68
If you are getting a lot of unlink errors and the cache file does not exist. Then it could be an issue with the store cache not being read correctly. This would cause the store cache to be deleted and set on each request. Greatly increasing the chances of a race condition. Could be caused by a permission issue or a modification.
Thanks, I was still getting the same issue as as the error was refering to line 17, so following your suggenstion, I have done the following and hopefully that would be the fix.
Find both instances of:
Code: Select all
if (file_exists($file)) {
unlink($file);
}
Replace with:
Because using the @ does remove the file if it exists as well, so no need to use this line.
if (file_exists($file)) {