Subnavigation
  • # Front Page
    Displays posts from every section of the site on one page.
  • # Blog
    Only show blog posts.
  • # Archive
    List of all posts for quick browsing.

Hosting
  • Anything is appreciated, even a dollar can cover my hosting costs for a while, depending on bandwidth usage.

Recent Comments
RSS Feeds
Friends
  • # David Baines
  • # Charles Woods
  • # Henry B. Rosenbush
  • # Matt Friel
  • # Locust Fork Journal
  • # Jimmy Cantrell
  • # Josh Billions
  • # Jamie Smith
  • # IT Pros on the Go
  • # Cody Girdlestone
  • # Film Guys
  • # Paul Chater
  • # Gordon Lowrey
  • # Ian Hamilton

  • I hate Wordpress

    Posted on Friday, January 23, 2009 at 01:38:21 PM.

    Upgraded a client to Wordpress 2.7 and the pagination went missing.

    I started echoing out all of the variables until I found out that $max_page was null.

    Open wp-includes/link-template.php.

    Look for the "get_next_posts_link" function and for the following line:
    $max_page = $wp_query->max_num_pages;

    I did a print_r() of $wp_query and found that "max_num_pages" was NULL. I tried going up-stream from there into the database code to look for any bugs but wasn't able to find any. I double-checked the database to make sure max_num_pages was set, and it was... After digging around a bit I was able to find posts_per_page under $wp_query->query_vars[].

    So, here's my fix:

    Replace
    $max_page = $wp_query->max_num_pages;
    with
    $max_page = $wp_query->query_vars['posts_per_page'];

    My question is this... How does this even get shipped out for download to users if it's completely broken?

    If it's NOT broken for anyone else, why am I having problems? What would cause max_num_pages to be NULL?

    If there is a bug or something, this is as far as I've traced it back:

    Line 2266 in wp-includes/query.php:

    $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);

    $this->found_posts == 0
    $q['posts_per_page'] == 6 (correct)

    So, I looked for found_posts:

    Lines 2263 and 2264:

    $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
    $this->found_posts = $wpdb->get_var( $found_posts_query );

    $found_posts_query == 'SELECT FOUND_ROWS()'


    So that calls $wpdb->get_var(SELECT FOUND_ROWS()), which, unless I'm wrong, isn't even a valid database call...

    Comments

    Posted by Andrew Brim on Friday, January 30, 2009 at 06:51:59 PM.
    Haven't had any probs with 2.7 on either of my blogs, but I'm not exactly a power-user.
    Posted by Andrew Brim on Friday, January 30, 2009 at 06:52:44 PM.
    Just an FYI, my comment got spam filtered for entering a Gmail address. might want to change that.
    Posted by Gordo on Saturday, January 31, 2009 at 03:09:16 AM.
    Oh I know... I had some spammer a few months ago that kept using Gmail addresses... Gimme your email and I'll whitelist it.

    I think I had the issues becuase I upgraded... I should have backed up the database and just installed a fresh copy of 2.7 and imported the old posts...
    Posted by Connor on Monday, February 9, 2009 at 10:01:13 PM.
    POWNED.
    Posted by Gordo on Monday, February 9, 2009 at 11:24:01 PM.
    holy shit it lives!
    Posted by Connor on Saturday, February 21, 2009 at 06:07:17 PM.
    don't you worry gordo i haven't forgot about you :D
    Posted by Gordo on Saturday, February 21, 2009 at 06:45:24 PM.
    Hah, I don't think that'll ever happen... Ever. You'll be like 70 years old and telling your kids about me.

    Add a comment:

    To add a link, please use the following format: [link]domain.com/page.htm[/link]
    Do not add www or http to the URL.





    Comment Preview: