The MU forums have moved to WordPress.org

get_posts db error on upgrade to 2.6 (3 posts)

  1. musnake
    Member
    Posted 15 years ago #

    Hey folks,

    [EDIT to correct 2.5.1 to 2.6]

    Upgrade from 1.5.1 to 2.6 PHP5.

    Post images are not displayed for some posts.

    The db err log shows the following error for each affected post.

    [28-Jul-2008 18:50:23] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wp_1_posts.ID DESC LIMIT 0, 1' at line 1 for query SELECT SQL_CALC_FOUND_ROWS wp_1_posts.* FROM wp_1_posts WHERE 1=1 AND wp_1_posts.post_parent = 4 AND (post_mime_type LIKE 'image/%') AND wp_1_posts.post_type = 'attachment' AND (wp_1_posts.post_status = 'inherit') ORDER BY ,wp_1_posts.ID DESC LIMIT 0, 1 made by get_posts

    Let me try some spacing for my tired eyes...

    Drama occurs here: 'wp_1_posts.ID DESC LIMIT 0, 1' 
    
     SELECT SQL_CALC_FOUND_ROWS  wp_1_posts.*
     FROM wp_1_posts
     WHERE 1=1
     AND wp_1_posts.post_parent = 7
     AND (post_mime_type LIKE 'image/%')
     AND wp_1_posts.post_type = 'attachment'
     AND (wp_1_posts.post_status = 'inherit')  
    
     ORDER BY ,wp_1_posts.ID DESC LIMIT 0, 1 
    
     made by get_posts

    Ah, made by get_posts, hmm, ok. Possibly that leading comma after ORDER BY?

    Help me out here folks, wp-includes/query.php starting @ line 1249 is the section of code that deals with the order by statement where I see $orderby = "$wpdb->posts.ID";
    That jives with wp_1_posts.ID. Ok, so before that point in the code then... line 1443
    $orderby = 'ORDER BY ' . $orderby;

    Doh! No comma insertion.

    Anyone else with image errors?

    Thanks.

  2. lunabyte
    Member
    Posted 15 years ago #

    I'm wondering how you upgrade from 1.5.1 to 2.5.1 when there isn't an MU 2.5.1.

  3. musnake
    Member
    Posted 15 years ago #

    By being the fabulous person that I am! I will it and sometimes a strawberry milkshake appears...want anything?

    Anyway, all fixed. Obscure mu plugin that had an update but doesn't show up in the dash. I guess I should check the other underscore prefaced plugin names... Didn't realise that they would be hidden -but I'm on a roll of being wrong...

About this Topic