Skip to:
Content

bbPress.org

Changeset 7325


Ignore:
Timestamp:
06/30/2025 06:27:22 PM (7 months ago)
Author:
johnjamesjacoby
Message:

Extend - Akismet: avoid timeouts in the delete_orphaned_spam_meta() method.

This change modifies the SQL used to query for Akismet post-meta keys, such that it will only retrieve rows where meta_key is like akismet_.

This results in a less-optimized database query, but circumvents a bug where unnecessary rows were being looped through in a way that would never finish.

Props terresquall.

In trunk, for 2.7.

Fixes #3580.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/extend/akismet.php

    r7268 r7325  
    11961196
    11971197        // Setup the query
    1198         $sql = "SELECT m.meta_id, m.post_id, m.meta_key FROM {$wpdb->postmeta} as m LEFT JOIN {$wpdb->posts} as p ON m.post_id = p.ID WHERE p.ID IS NULL AND m.meta_id > %d ORDER BY m.meta_id LIMIT %d";
     1198        $sql = "SELECT m.meta_id, m.post_id, m.meta_key"
     1199            . " FROM {$wpdb->postmeta} as m"
     1200            . " LEFT JOIN {$wpdb->posts} as p"
     1201            . " ON m.post_id = p.ID"
     1202            . " WHERE p.ID IS NULL"
     1203            . " AND m.meta_id > %d"
     1204            . " AND m.meta_key LIKE 'akismet\\_%'"
     1205            . " ORDER BY m.meta_id"
     1206            . " LIMIT %d";
    11991207
    12001208        // Query loop of topic & reply IDs
Note: See TracChangeset for help on using the changeset viewer.