Prestashop: [1.7.6.5 and 1.7.7] [Bug] Fatal error: Uncaught Error: Class 'Tools' not found

Created on 22 Jun 2020  路  6Comments  路  Source: PrestaShop/PrestaShop

When I click on the clear cache button, I got the following error message this happen in both prestashop 1.7.7-beta1 and 1.7.6.5

Fatal error: Uncaught Error: Class 'Tools' not found in /home/admin/domains/server.com/public_html/www/classes/db/Db.php:794 Stack trace: #0 /home/admin/domains/server.com/public_html/www/config/alias.php(47): DbCore->escape('configuration', false) #1 /home/admin/domains/server.com/public_html/www/config/alias.php(52): pSQL('configuration') #2 /home/admin/domains/server.com/public_html/www/classes/Configuration.php(155): bqSQL('configuration') #3 /home/admin/domains/server.com/public_html/www/classes/Configuration.php(209): ConfigurationCore::loadConfiguration() #4 /home/admin/domains/lozserverra.com/public_html/www/classes/PrestaShopAutoload.php(171): ConfigurationCore::get('PS_DISABLE_OVER...') #5 /home/admin/domains/server.com/public_html/www/classes/PrestaShopAutoload.php(130): PrestaShopAutoload->generateIndex() #6 [internal function]: PrestaShopAutoload->load('Tools') #7 /home/admin/domains/server.com/public_html/www/config/config.inc.php(84): spl_autoload_call('Tools') #8 /home/admin/domains/l in /home/admin/domains/server.com/public_html/www/classes/db/Db.php on line 794
I saw a similar issue but it was closed without any official way how to solve this issue and no pull request was submitted: https://github.com/PrestaShop/PrestaShop/issues/12667 .

====================

  • Tested on PHP 7.2 and PHP 7.3 (using php-fpm) for PS 1.7.6.5 and for PS 1.7.7-beta1 tested only with PHP 7.3 (php-fpm)
  • Using nginx for the front and apache as the backend apache_nginx
  • No memcached and opcache installed. No caching software at the backend
  • Tested with and without debugging mode at BackOffice
  • Modsecurity is turned off (no security software is installed), even the firewall is CSF is turn off temporarily for the test.
  • Tested on both Prestashop 1.7.7-beta1 and the latest production version 1.7.6.5 (both producing the same bug)
  • Believe me permission of the folder caches are perfect.
  • Tested with and without Cache option in BO

- Tested on fresh installation of Prestashop

My biggest guess here, perhaps php-fpm is having compatibility issue with the prestashop cache? But it's written in the documentation that we could use php-fpm. I open this issue for anyone to look into this issue and submit PR because whenever I download new fresh prestashop, I have to do this to fix it temporarily. This workaround was mentioned by @r1si

fix with change this line:
line 797 file classes/db/DB.php
change line 796:
$string = strip_tags(Tools::nl2br($string));
with this:
$string = str_replace(array("\r\n", "\r", "\n", AddressFormat::FORMAT_NEW_LINE, PHP_EOL), '
', $string);

But if you look at the date, this issue has been reported since february 2019. 1 year++, maybe not many people are using php-fpm and apache_nginx as reverse proxy ?

extra information: this is my php.ini for both php72 and php73:

allow_url_fopen=On
allow_url_include=Off
date.timezone=Asia/Kuala_Lumpur
display_errors=Off
magic_quotes_gpc=Off
max_execution_time=300
max_input_time=300
max_input_vars=20000
memory_limit=368M
post_max_size=128M
session.auto_start=Off
short_open_tag=Off
upload_max_filesize=128M

Ok this is the information from psphpinfo.php (everything is green):

bug

Duplicate

Most helpful comment

No, #11105 is different issue. It's about clicking the cache button twice but this issue is different where some suspect php-fpm compatibility issue. I have mentioned in the first post that my issue was duplicated from here: #12667 and a solution has been given temporarily by @r1si but no pull request has been made since feb 2019. You are closing the same unresolved issue. Please wait for somebody to do pull request and you can happily close this.

All 6 comments

Thanks for opening this issue! We will help you to keep its state consistent

@PrestaShop/prestashop-core-developers could you check this issue ?

@sarahdib It's the same as this. https://github.com/PrestaShop/PrestaShop/issues/11105

Soon, we will celebrate a 3 year aniversary of clearing cache not working. 馃槃

Duplicate of #11105

@arafatx Your issue is a duplicate of the issue mentionned above, please follow it

No, #11105 is different issue. It's about clicking the cache button twice but this issue is different where some suspect php-fpm compatibility issue. I have mentioned in the first post that my issue was duplicated from here: #12667 and a solution has been given temporarily by @r1si but no pull request has been made since feb 2019. You are closing the same unresolved issue. Please wait for somebody to do pull request and you can happily close this.

Was this page helpful?
0 / 5 - 0 ratings