Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Have you tried disabling all of your plugins and switching to the default theme? –  Brian Fegter Mar 1 '12 at 6:09
    
I just got the same problem on line 1357. on function current_user_can( $capability ) but the line is the same: $current_user = wp_get_current_user(); –  user13701 Mar 1 '12 at 7:45
    
I'm having the same problem in class-wp.php line 529, which also happens to call wp_get_current_user. I think I narrowed the problem down to the WooCommerce plugin. The error happens at random, but I haven't seen it since I disabled that plugin. Does anyone has a better idea about what causes this error? –  wvega Feb 20 at 2:31
add comment

2 Answers 2

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.

share|improve this answer
add comment

I have found that usually these capability problems end up being in a plugin somewhere (hard to find since the error looks like it's in core wordpress).

The non-object part may mean that wp does not yet have the $current_user object setup - may mean a call to a capability check too early in the wordpress actions.

The overloading part usually means that it is a user meta value that wp is trying to fetch (which a capability is).

BEST way is disable plugins one by one until message goes away - then you know which plugin it is at least. Bit tough if you do not know when it is happening - can you tell which page it is on, or what people are doingwhen it happens?

Then look at plugins wordpress functions - maybe a add action that is early in action sequence? http://codex.wordpress.org/Plugin_API/Action_Reference

(could also try googling each plugin with the later part of that message?

eg: "wp-includes/capabilities.php on line 1187" gave me: http://support.dev7studios.com/discussions/nivo-slider-wordpress-plugin/544-fatal-error

let us know how you go

share|improve this answer
    
There is no as such page on which this error is occurring. Its coming randomly and whenever it happens, 500 error with this message comes on each and every request. It automatically start working fine after 20-30 seconds. –  pankajbatra Mar 7 '12 at 7:53
    
I am trying to find out culprit plugin by disabling plugin one by one and checking if error still is coming. Following are plugins installed on blog: Akismet, Contact form 7, Google Analytics for WordPress, Google XML Sitemaps, HTTP 404 Email Notifier, My Page Order Secure WordPress, W3 Total Cache,WebsiteDefender WordPress Security,WordPress File Monitor,Wordpress Firewall 2,WP-PostViews,Yet Another Related Posts Plugin Out of these, I have checked deactivating following plugins so far with no luck: HTTP 404 email notifier,Secure wordpress,WordPress File Monitor, Wordpress Firewall 2 –  pankajbatra Mar 7 '12 at 7:59
    
Also, is there any plugin/apache/php extension which can show detailed stack trace of errors. Like who called this function with line number etc. –  pankajbatra Mar 7 '12 at 8:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.