Page 1 of 1

php error

Posted: Fri Oct 13, 2023 6:23 am
by robter1973
Hi I have a problem within my opencart site in version 2.0.1.1. with php 7.4. These errors are generated in the error log file:

PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/PHP Warning: flock () expects parameter 1 to be resource, bool given in /var/www/vhosts/PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file.php on line 51
2023-10-12 21:56:32 - PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/vhosts/PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file.php on line 51
2023-10-12 21:56:32 - PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 53
2023-10-12 21:56:32 - PHP Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 55
2023-10-12 21:56:32 - PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 57
2023-10-12 21:56:32 - PHP Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 59
/httpdocs/system/library/cache/file.php online 53
2023-10-12 21:56:32 - PHP Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 55
2023-10-12 21:56:32 - PHP Warning: flock() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 57
2023-10-12 21:56:32 - PHP Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/vhosts/######/httpdocs/system/library/cache/file .php online 59

These errors cause me to display the front of the site incorrectly. Can you help me solve this problem? Thank you

Re: php error

Posted: Fri Oct 13, 2023 4:19 pm
by ADD Creative
The issue is OpenCart us unable to write a cache file. Check the permissions on the system/cache directory.

If that small warning caused problems then you probably have display errors on. Not only can this cause minor notices and warnings to cause bigger errors, it can also be a security risk.

You need make sure display errors in set to off in all 3 places. Your PHP settings, in system/config/default.php and in the settings.

1. In your PHP settings make sure display_errors is set to Off. Use phpinfo() to check. It should be off by default, but there are lots of rubbish hosts out there.

2. In system/config/default.php set error_display to false (2.2.x and above).

3. In your OpenCart Setting on the server tab set Display Errors to No.

Re: php error

Posted: Fri Oct 13, 2023 7:30 pm
by paulfeakins
As above it could be to do with reading/writing files, perhaps check you're not out of disk space and contact your host?

Re: php error

Posted: Sat Dec 02, 2023 7:43 am
by robter1973
The issue is OpenCart us unable to write a cache file. Check the permissions on the system/cache directory.

If that small warning caused problems then you probably have display errors on. Not only can this cause minor notices and warnings to cause bigger errors, it can also be a security risk.

You need make sure display errors in set to off in all 3 places. Your PHP settings, in system/config/default.php and in the settings.

1. In your PHP settings make sure display_errors is set to Off. Use phpinfo() to check. It should be off by default, but there are lots of rubbish hosts out there.

2. In system/config/default.php set error_display to false (2.2.x and above).

3. In your OpenCart Setting on the server tab set Display Errors to No.
Do you have any other suggestions for me regarding this problem of mine? I thank you in advance.

Re: php error

Posted: Sat Dec 02, 2023 8:26 am
by ADD Creative
Only what has already been suggested.

Switch off display errors.
Check both your PHP and OpenCart error logs.
Check permissions.
Contact your host.
Disable any extensions.