What does the error “PHP Fatal error: cannot call

2019-02-28 17:35发布

问题:

I have WordPress website running on a GoDaddy Linux host. The error PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/class-wp.php on line 529 is being happening at random, usually in response to a POST request, I think.

  • WordPress version: 3.8
  • PHP version: 5.4.23

Line 529 of file wp-includes/class-wp.php is the body of the following function in class WP:

function init() {
    wp_get_current_user();
}

The error seems to be somehow related to the presence of the WooCommerce plugin. I haven't seen the error when the plugin is deactivated.

Unfortunately, removing WooCommerce is not an option so I need to discover how is the error being triggered and provide a solution. The problem is I don't know what to look for.

I want to understand what causes an error like the one above in a general case.

  • Can anyone provide an example of PHP code that generates such an error? or
  • an explanation of why it happens?

I'm hoping to be able to use that information to find a similar problem in WooCommerce's source code.

I took a quick look at PHP's interpreter source code (here and here) and found the line that generates the error message, but to be honest, that didn't help me.

A question in SO about the same error in a different application has an answer indicating the problem was caused by server overload. I don't think that's the case here. We don't get too much traffic.

A different question in WordPress SE offers two possible causes. Either the problem is associated with Alternate PHP Cache (APC) being enabled or the problem is caused by a plugin. Unfortunately nobody offers actual solutions or specific causes.

My case is similar to the one exposed in the question above: I have APC enabled (currently trying to get help from GoDaddy to disable it) and my tests suggest WooCommerce has some responsibility.

I appreciate all your help.

回答1:

Go to root directory and create a php.ini file and write the following ;extension=apc.so

and save.

Neighbourhood Wordpress theme had this issue.



回答2:

I was able to solve this for individual sites by adding php_flag apc.cache_by_default Off to .htaccess



回答3:

We found that this is related to the APC module for Apache. To resolve it, simply edit your php.ini to uncomment the apc module so it reads from

extension=apc.so

to

;extension=apc.so

This will resolve the problem.



回答4:

I had the white screen of death for some time. Prior to that a related issue -PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/class-wp.php on line 529. This issue was solved by upgrading my godaddy account.

As mentioned above, the white screen issue could either be a plugin or the APC. The fastest way to determine if it is a plugin is NOT to deactivate them all and then reactivate one-by-one - but rather deactivate and reactivate all at once - the plugin causing the problem with get an error reactivating.

That said, I wanted to keep the plugin so I contacted Godaddy, who readily disabled the APC.

I have reactivated the plugin and all seems fine. The only potential issue with disabling the APC is slower load times, but I haven't experienced that yet.



标签: php wordpress