0

I have custom WordPress plugin where I giving option for admins to download export of survey. The plugin using package phpoffice I have test hosting with PHP 7.3 where export goes well and the production hosting is on PHP 7.3.3 (before it was PHP 7.4) where the exactly same problem does not work.

I'm expecting to resolve this error and make the option for download exports working.. I've tried searching for google but I didn't find solution exactly for my problem. I tried this stuffs:

  1. Upgrade memory_limit from 256MB to 512MB
  2. Tried to downgrade production hosting PHP version from 7.4 to 7.3.3

When production hosting PHP version was 7.4 it gived this error in PHP error log:

[22-Dec-2022 08:45:24 UTC] PHP Fatal error:  Uncaught Error: Interface 'Psr\SimpleCache\CacheInterface' not found in /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php:14
Stack trace:
#0 /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/composer/ClassLoader.php(571): include()
#1 /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/www/doc/www.di...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('PhpOffice\\PhpSp...')
#3 /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Settings.php(164): spl_autoload_call('PhpOffice\\PhpSp...')
#4 /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/CellsFactory.php(19): PhpOffice\PhpSpreadsheet\Settings::getCache()
#5 /www/doc/www.digitalniagora.cz/www/wp-content/ in /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php on line 14

After I downgraded the PHP version to 7.3.3 (because I haven't option to downgrade to PHP 7.3) I getting just this error:

[27-Dec-2022 15:43:23 UTC] PHP Fatal error:  Interface 'Psr\SimpleCache\CacheInterface' not found in /www/doc/www.digitalniagora.cz/www/wp-content/plugins/agora_survey/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Memory.php on line 14

EDIT 29.12.2022: I tried update PHP version on test hosting to the same version as production hosting is but on test version it working well and production version code does not work.

But the code is exactly same as on test hosting where everything works well and also the code is exactly same after downgrade PHP version.. Can anybody give me some hints to find the solution?

MartyQek
  • 1
  • 1
  • check if you have CacheInterface.php file. If not, here's the project https://github.com/php-fig/simple-cache/tree/master/src – WiatroBosy Dec 28 '22 at 17:18
  • I have the CacheInterface.php file in folder: /vendor/psr/simple-cache/src/CacheInterface.php on test hosting and production hosting too, but on test it works, on production it throwings me this error. – MartyQek Dec 28 '22 at 19:52
  • test and production environments have exactly the same configuration (php version, apache)? – WiatroBosy Dec 28 '22 at 19:54
  • if you downloaded a phpOffice or simple-cache project with composer on your local computer or test environment - then probably the composer.json file on the test environment is different than on the production one. check if the composer.json file is the same everywhere – WiatroBosy Dec 28 '22 at 20:03
  • @WiatroBosy Hi, everything is same on test and production, just the production hosting does not giving me option to upgrade PHP to 7.3 as I have on test environment, so on production I have version PHP 7.3.3 – MartyQek Dec 29 '22 at 09:08
  • Downgrading to a really old and unsupported PHP version is pretty stupid. It could allow any script kiddie to download a script for hacking your site off the internet, because fixed exploits for such old version are well-documented. Stay with the latest 7.4 version at least (though that one is also not supported any longer). Also, when you did that, did you run `composer install -o` to check/install dependencies and to regenerate the autoloader? Odds are you code is simply not compatible with 7.3 any longer. – Ulrich Eckhardt Dec 29 '22 at 11:01

0 Answers0