PHP 8+ – admin ajax 500 error
-
Hi, I would like to make you aware of an error I encountered while attempting to use the plugin on PHP 8+. When attempting to load the assets listed on the backend for each page dynamically, there would be a 500 admin ajax error in the console. WP Debug enabled didn’t reveal the source of the problem. However my PHP log indicated a problem at the following location:
PHP Warning: Undefined array key “script_src_or_inline_and_noscript_inline_tags” in /chroot/home/ae3909cd/bcda6510ff.nxcli.io/html/wp-content/plugins/wp-asset-clean-up/templates/meta-box-loaded-assets/_assets-hardcoded-list.php on line 46
[27-Feb-2023 18:05:47 UTC] PHP Fatal error: Uncaught TypeError: array_unique(): Argument #1 ($array) must be of type array, null given in /chroot/home/ae3909cd/bcda6510ff.nxcli.io/html/wp-content/plugins/wp-asset-clean-up/templates/meta-box-loaded-assets/_assets-hardcoded-list.php:46After investigating, it appeared that on line 46 of that particular file the array key needed addressing to check if an array key exists. I applied an isset conditional statement here and now the ajax error no longer appears, and assets can now finally load again on the edit mode of each page for PHP version 8+. The problem doesn’t exist on PHP 7.4 and below, likely because of strictness being increased in newer versions of PHP for existing objects/arrays.
I would appreciate if this change could be implemented in future versions, so that I don’t have to go into the core plugin files to make the update each time the plugin has a new version release.
Many Thanks
Drew
- The topic ‘PHP 8+ – admin ajax 500 error’ is closed to new replies.