PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/capabilities.php [closed]

I have been experiencing too many following errors in my apache logs.

PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/capabilities.php on line 1187

This is inside function current_user_can( $capability ) and line 1187 is as follows:

$current_user = wp_get_current_user();

I am not able to figure out what can be the issue?

3 Answers
3

This issue usually stems from PHP configuration issues, APC caching, and/or a call to an incompatible XML library.

From what I’ve seen, it is usually a combination of php 5.2.X and caching. If you’re using caching on your site, try switching from APC/memcached cache to disk caching and see if it clears up. 9/10 times, disabling APC at the server level clears it up as well (if you have full server access). Keep in mind that your host may have APC enabled by default.

In the meantime, make sure you have these lines in your wp-config.php:

/**
 * This will log all errors notices and warnings to a file called debug.log in
 * wp-content (if Apache does not have write permission, you may need to create
 * the file first and set the appropriate permissions (i.e. use 666) ) 
 */
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

This turns on WP debugging, and will output to /wp-content/debug.log. It’s not a full stack trace, but it keeps these errors from showing up to your end users and may log other errors you haven’t seen. You can also install the Debug Bar plugin, which will let you (Administrators only) see errors/notices, memory usage by php (which can tell you if you need to increase the limit), number of queries (if SAVE_QUERIES is set) used to generate a page, and so on. You can also (again, if you have server access) set up PHP with XDebug, which will generate a full stack trace on PHP errors.

I hope some of this at least points you in the right direction.

Leave a Comment