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 a weird bug on the dashboard: the dashboard says there are a total of 3 posts, but the list is empty and says "No posts found" (see image below)

enter image description here

It's a fresh install on a shared Windows hosting, using SQL Server as the database with the WP Db Abstraction plugin. I tried reinstalling WP completely and the bug is still there. Before I reinstalled WP, I had configured it for multi-site, and I had the same issue in the site list.

I'm a complete newbie with WordPress and I have no idea how to fix this... any help would be greatly appreciated!


UPDATE: I investigated the queries issued to the database, and it seems that the query that is supposed to return the list of posts is this:

SELECT TOP 0 *
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type LIKE 'post'
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status LIKE 'future' OR wp_posts.post_status LIKE 'draft' OR wp_posts.post_status LIKE 'pending' OR wp_posts.post_status LIKE 'private')
ORDER BY wp_posts.post_date DESC

And of course, TOP 0 returns 0 rows... this query seems to be generated by the DB abstraction plugin when it tries to translate the LIMIT clause to SQL Server.

So I guess my only options are:

  • fix the bug (doesn't seem easy, since there is no obvious translation for LIMIT in SQL Server)
  • or switch to a MySQL database...
share|improve this question
    
do you see anything when you click Published or Drafts? –  Kyle May 4 '12 at 17:05
    
@MotiveKyle, no the list remains empty... –  Thomas Levesque May 4 '12 at 17:18

3 Answers 3

up vote 1 down vote accepted

Try the fix posted here: http://sourceforge.net/tracker/?func=detail&aid=3485384&group_id=315685&atid=1328061

It worked for me.

translations.php line 726 Change this: $pattern = '/LIMIT\s*(\d+)((\s*,?\s*)(\d+))(;{0,1})$/is'; to this: $pattern = '/LIMIT\s(\d+)((\s*,?\s*)(\d+)*);{0,1}$/is';

Removing the extra parentheses allows "LIMIT 0, 10" to become "TOP 10". With the extra parentheses, the "0" is used instead.

share|improve this answer
    
Thanks, actually I had found the same fix myself and posted it in a comment to that bug... and I missed the fact that someone else had proposed almost exactly the same fix 3 months earlier ;) –  Thomas Levesque May 9 '12 at 21:42
    
Cool- so far the SQL Server edition seems to be working. I'm just waiting for the next gotcha! –  Jon Kragh May 10 '12 at 1:02

I had the same issue and it was resolved by changing the translations.php file as indicated in this post on the official DB Abstraction forums.

The following code:

// Check for true offset
if ( count($limit_matches) == 5 && $limit_matches[1] != '0' ) {
    $true_offset = true;
} elseif ( count($limit_matches) == 5 && $limit_matches[1] == '0' ) {
    $limit_matches[1] = $limit_matches[4];
}

Should Be:

    // Check for true offset
    if ( count($limit_matches) == 5 && $limit_matches[1] != '0' ) {
        $true_offset = true;
    } elseif ( count($limit_matches) >= 5 && $limit_matches[1] == '0' ) {
        $limit_matches[1] = $limit_matches[4];
    }

Reference: http://wordpress.org/support/topic/plugin-wp-db-abstraction-not-showing-posts

share|improve this answer

Since you're using MSSQL, repair is a little different. Make sure you backup your database before doing any actions, just in case. Here's some code from Microsoft for MSSQL 2000 - the command may be different depending on your version, so if this doesn't work, just search for 'SQL Server (year) repair database' and you'll find a similar command for your system.

DBCC CHECKDB
    ( 'database_name'
            [ , NOINDEX
                | { REPAIR_ALLOW_DATA_LOSS
                    | REPAIR_FAST
                    | REPAIR_REBUILD
                    } ]
    )    [ WITH { [ ALL_ERRORMSGS ]
                    [ , [ NO_INFOMSGS ] ]
                    [ , [ TABLOCK ] ]
                    [ , [ ESTIMATEONLY ] ]
                    [ , [ PHYSICAL_ONLY ] ]
                    }
        ] 
share|improve this answer
    
Thanks, but I don't think it has anything to do with repairing the database... I think I found the cause of the problem: a bug in the WP Db Abstraction plugin. It tries to "translate" the queries made by WP to queries that are understood by SQL Server, and when it tries to translate "LIMIT 0, 10", it results in "SELECT TOP 0 * FROM...", which of course returns 0 rows –  Thomas Levesque May 4 '12 at 20:29
    
Ouch, yeah that's a pretty serious one there. –  SickHippie May 4 '12 at 20:37

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.