• I seem to have run into a problem with the Akismet plugin; I have three pages of spam comments to delete. I read through each page then tried to skip back to the first page to check the timestamps. When I did that, I got the following error:

    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 ‘-50, 0’ at line 1]
    SELECT * FROM wp_comments WHERE comment_approved = ‘spam’ ORDER BY comment_date DESC LIMIT -50, 0

    No results found.

    There are currently 149 comments identified as spam.

    I can reliably reproduce this. Using the previous button on page 2 yields the same result. Can someone please try this and verify my sanity – is it a problem with the plugin?

Viewing 4 replies - 1 through 4 (of 4 total)
  • fel64

    (@fel64)

    I can also reproduce that error, but I do not get a WP DB error – only the “No results found” message.

    # Server version: 4.0.27-standard
    # Protocol version: 10
    # MySQL client version: 4.1.10

    If it helps.

    Thread Starter cr0wley

    (@cr0wley)

    Cheers for that mate, I’ll have to look up the LIMIT function and check the valid syntax. It may be that my comment table is poorly

    Thread Starter cr0wley

    (@cr0wley)

    Scratch that, I see what’s going on. If the page number is 2, the code decreases that by 1, but it doesn’t return the parameter as 1, it returns as null so you end up with ‘edit-comments.php?page=akismet-admin&apage=’
    The select statement doesn’t like having the apage variable fed to it as null; if it’s not set it sets it to 1, but if it’s fed it uses (that-1) * 50 for the start and start+50 for the end. Null is like 0, so (0-1)*50=-50
    It’s damn same my php skills aren’t up to scratch, otherwise I’d be able to understand lines 388 and 458 of akismet.php better

    Thread Starter cr0wley

    (@cr0wley)

    Still, I’ve managed to bodge something in that works; from line 370:

    if ( isset( $_GET[‘apage’] ) )
    $page = (int) $_GET[‘apage’];
    else
    $page = 1;

    if ($page < 2)
    $page = 1;

    $start = ( $page – 1 ) * 50;
    $end = $start + 50;

    Would anyone with a more elegant hand care to tidy that up and maybe stick it in the Akismet CVS?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Akismet won’t go back to page 1 of spam’ is closed to new replies.