Fatal Error due to PHP 8 Compatibility OR missing Database Tables
-
I am getting the same error as reported here
The error is:
Fatal error: Uncaught TypeError: json_decode(): Argument #1 ($json) must be of type string, array given in /var/www/html/wp-content/plugins/wordfence/lib/wfConfig.php:545 Stack trace: #0 /var/www/html/wp-content/plugins/wordfence/lib/wfConfig.php(545): json_decode() #1 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(700): wfConfig::getJSON() #2 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(719): wfUtils::whitelistPresets() #3 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(750): wfUtils::whitelistedServiceIPs() #4 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(776): wfUtils::getIPWhitelist() #5 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(934): wfUtils::isPrivateAddress() #6 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(1117): wfUtils::getCleanIPAndServerVar() #7 /var/www/html/wp-content/plugins/wordfence/lib/wfUtils.php(1048): wfUtils::getIPAndServerVariable() #8 /var/www/html/wp-content/plugins/wordfence/lib/wfLog.php(114): wfUtils::getIP() #9 /var/www/html/wp-content/plugins/wordfence/lib/wordfenceClass.php(1132): wfLog->initLogRequest() #10 /var/www/html/wp-content/plugins/wordfence/wordfence.php(95): wordfence::install_actions() #11 /var/www/html/wp-admin/includes/plugin.php(2300): include('...') #12 /var/www/html/wp-admin/plugins.php(191): plugin_sandbox_scrape() #13 {main} thrown in /var/www/html/wp-content/plugins/wordfence/lib/wfConfig.php on line 545
Running an NGINX VPS with PHP 8 as suggested by the hosting service.
I am aware that WP is itself not really yet PHP 8 compatible and many plugins are not either, but the fact is that running WP, Toolset, several custom plugins and theme produces no issues at all. I also do not believe the issue is due to PHP 8, rather, as see below, something else.I have of course tried to disable all Plugins and enable only WF, however run in the precise same issue.
I tried to debug it, and found that when I dump the error throwing line (544)
$json = self::get($key, $default, $allowCached);
then I get an empty array as result.
That probably is due to the underlying error I have seen:[12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'allowLegacy2FA' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), require_once('/plugins/wordfence/lib/wordfenceClass.php'), wfCredentialsController::useLegacy2FA, wfCredentialsController::allowLegacy2FA, wfConfig::get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfls_settings' doesn't exist for query SELECT <code>name</code>, <code>value</code>, <code>autoload</code> FROM <code>wp_wfls_settings</code> WHERE <code>name</code> = 'allow-xml-rpc' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), require_once('/plugins/wordfence/lib/wordfenceClass.php'), require('/plugins/wordfence/modules/login-security/wordfence-login-security.php'), WordfenceLS\Controller_WordfenceLS->init, WordfenceLS\Controller_WordfenceLS->_init_actions, WordfenceLS\Controller_Settings->get_bool, WordfenceLS\Controller_Settings->get, WordfenceLS\Settings\Model_DB->get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'apiKey' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), wordfence::install_actions, wordfence::getLog, wfLog::shared, wfConfig::get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'howGetIPs' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), wordfence::install_actions, wfLog->initLogRequest, wfUtils::getIP, wfUtils::getIPAndServerVariable, wfConfig::get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'detectProxyRecommendation' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), wordfence::install_actions, wfLog->initLogRequest, wfUtils::getIP, wfUtils::getIPAndServerVariable, wfConfig::get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'howGetIPs_trusted_proxies' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), wordfence::install_actions, wfLog->initLogRequest, wfUtils::getIP, wfUtils::getIPAndServerVariable, wfUtils::getCleanIPAndServerVar, wfConfig::get [12-Apr-2021 18:40:04 UTC] WordPress database error Table 'database_name.wp_wfconfig' doesn't exist for query SELECT name, val, autoload FROM wp_wfconfig WHERE name = 'whitelistPresets' made by activate_plugin, include_once('/plugins/wordfence/wordfence.php'), wordfence::install_actions, wfLog->initLogRequest, wfUtils::getIP, wfUtils::getIPAndServerVariable, wfUtils::getCleanIPAndServerVar, wfUtils::isPrivateAddress, wfUtils::getIPWhitelist, wfUtils::whitelistedServiceIPs, wfUtils::whitelistPresets, wfConfig::getJSON, wfConfig::get
So to summarise it, perhaps this seems due to the Database tables not being created, hence the offending line results in an empty array and cannot be converted to JSON String.
That made me think, and results that this is a site migration where we had to delete all wf_ database tables due to problems after migration with the login.
So, perhaps WF still has something in the options table telling it is already installed and doesnt create the database tables anymore?
Hence the Query SELECT fails, hence the array is not populated and results in failure to build the JSON String?Bottom line, any suggestion to resolve this?
- This topic was modified 3 years, 11 months ago by . Reason: Edit title as more adequate
- This topic was modified 3 years, 11 months ago by . Reason: darn typo!
- The topic ‘Fatal Error due to PHP 8 Compatibility OR missing Database Tables’ is closed to new replies.