1

I am using customized theme for my development. The site was working fine and in last few days started seeing this error

Fatal error: Call to a member function is_singular() on a non-object in /home/content/29/11116929/html/studyus/wp-includes/comment.php on line 2399

The error is on line 2399 which is

if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )     return $posts;

comments.php is wordpress file and we have not changed anything. This is what I have done so far a) upgraded to latest version 3.9.1 b) disabled all plugins c) checked comments.php in my theme's file, reverted to base version and still same issues.

This is my site and this is where search query is being executed

  • Can you please try enabling <a href="codex.wordpress.org/WP_DEBUG">WP_DEBUG</a> mode? To do this, just go to wp-config.php include this: define('WP_DEBUG',true); You might already have a line for WP_DEBUG, so just make sure it's set to true. Let me know what more errors if any you are getting! – Vinod Dalvi Jun 11 '14 at 3:33
  • @VinodDalvi I set it to true and the value is blank in that page – skillguru Jun 11 '14 at 10:13
1

As strange as it may sound, but the error was because in one of the posts I had published , there was - at end!! So I deleted the posts as that looked like the problem.

Then I restored them one of one and tried to find out what was the problem.

Not sure why that caused the exception to be thrown. Maybe because I was using two shortcodes in the posts abase mysql and table2chart.

Bottom line, do not fiddle with wordpress core files

0

The error originates from the function _close_comments_for_old_posts, which accepts two arguments, $posts (array of WP_Post objects) and $query (WP_Query object). As you can see by the error being generated, the problem is that the $query passed is not an object.

By default, _close_comments_for_old_posts only called through the filter the_posts. The the_posts filter is, by default, only applied in the WP_Query object, passing an array of WP_Post object and itself (&$this). This is a WP_Query object by definition, as it's called from inside WP_Query.

Thus, I would say it's good to check if anywhere in your code, the the_posts filter is applied (by default, it only occurs once, in wp-includes/query.php), and check whether _close_comments_for_old_posts is mentioned anywhere outside default-filters.php.

  • I will try this – skillguru Jun 11 '14 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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