• I recently switched hosting companies. I dumped my mysql db from the original host and imported it on the new host, as I’ve done several times before. While I was at it, I decided to go ahead and upgrade wordpress to 2.5 as well. Everything seemed to be working fine at first, until I needed to edit an entry. The “Manage” tab on wp-admin doesn’t list any posts. It gives an accurate count (Published (1,107) | Private (116)), but the actual list just says “No posts found.”

    Obviously that’s not right.

    Pages list correctly. Comments list correctly also. However, none of my RSS or ATOM feeds list anything, for posts or comments.

    My template is showing the last 10 entries without any problem, but that might be because I invoke <?php query_posts("showposts=10"); ?>. If I remove that, I get ALL of my posts.

    I enabled tracing on mysql and noticed that the query generated at line 1427 of query.php has a weird limit clause:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 2592000, 10

    Clearly, that’s causing a problem.

    I traced it back to this bit of code in query.php:

    // Paging
    		if ( empty($q['nopaging']) && !$this->is_singular ) {
    			$page = absint($q['paged']);
    			if (empty($page)) {
    				$page = 1;
    			}
    
    			if ( empty($q['offset']) ) {
    				$pgstrt = '';
    				$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
    				$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
    			} else { // we're ignoring $page and using 'offset'
    				$q['offset'] = absint($q['offset']);
    				$pgstrt = $q['offset'] . ', ';
    				$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
    			}
    		}

    The else condition (when $q[‘offset’] is empty) is the one being run, and it appears that $q[‘offset’] is being set explicitly to 2592000. I can’t for the life of me figure out why. I tried adding ?offset=1 to the url manually, but offset remained at 2592000.

    I can’t figure out where it’s coming from.

    Is there a setting somewhere that might have gotten screwed up in the transfer? I didn’t find any options in wp_options that seemed relevant, and I’ve tried changing the limit on how many posts to show in wp-admin several times with no effect.

    I hope someone can help, because I’m lost.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    ww.wp.xz.cn Admin

    Hmmm.. 2592000 seconds is exactly 30 days. Got any plugins doing anything weird?

    I love it when otto goes all ‘rain man’ 😉

    Thread Starter jrsmith

    (@jrsmith)

    Pretty much all of my plugins are still deactivated from when I upgraded, so I don’t think so. I’ll get rid of the last few and see if that helps.

    Thread Starter jrsmith

    (@jrsmith)

    Still nothing. This is very frustrating. I have a feeling there’s a very simple explanation for this, but I don’t know enough about the inner workings of wordpress to figure it out.

    Moderator Samuel Wood (Otto)

    (@otto42)

    ww.wp.xz.cn Admin

    I did a search, and don’t see the offset being set anywhere by WordPress to any sort of default setting. Meaning that it should be empty/undefined at that point. So something, somewhere, has to be setting it.

    Thread Starter jrsmith

    (@jrsmith)

    As a test, I added

    $q['offset'] = '';

    right before that if/else block, and everything comes up fine. I’m really stumped. I can’t even tell if this happened after the move to a new host or the upgrade to 2.5.

    I’m going to keep digging, and I might try the wp-debug plugin.

    Thanks for the help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Issue with post/comment queries’ is closed to new replies.