UltrasonicNXT has submitted this change and it was merged.

Change subject: Delete all but the 50 newest messages
......................................................................


Delete all but the 50 newest messages

This should have been happening for ages, but it wasn't working, because
(a) a number to big for an int was being converted to an int, and (b),
ORDER BY was incorrectly written as ORDER_BY (underscore)

Change-Id: I1692f54f60d8ba672e2d712116a62242ee3f2516
---
M MediaWikiChatClass.php
1 file changed, 4 insertions(+), 5 deletions(-)

Approvals:
  UltrasonicNXT: Verified; Looks good to me, approved



diff --git a/MediaWikiChatClass.php b/MediaWikiChatClass.php
index 5bb55c0..4ce1e4f 100644
--- a/MediaWikiChatClass.php
+++ b/MediaWikiChatClass.php
@@ -225,21 +225,20 @@
         */
        static function deleteEntryIfNeeded() {
                $dbr = wfGetDB( DB_SLAVE );
-               $dbw = wfGetDB( DB_MASTER );
                $field = $dbr->selectField(
                        'chat',
                        'chat_timestamp',
                        array(),
                        __METHOD__,
                        array(
-                               'ORDER_BY' => 'chat_timestamp DESC',
+                               'ORDER BY' => 'chat_timestamp DESC',
                                'OFFSET' => 50,
                                'LIMIT' => 1
                        )
                );
 
-               if ( is_int( $field ) ) {
-                       $field = intval( $field );
+               if ( $field ) {
+                       $dbw = wfGetDB( DB_MASTER );
                        $dbw->delete(
                                'chat',
                                array( "chat_timestamp < $field" ),
@@ -247,4 +246,4 @@
                        );
                }
        }
-}
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/104754
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1692f54f60d8ba672e2d712116a62242ee3f2516
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiChat
Gerrit-Branch: master
Gerrit-Owner: UltrasonicNXT <adamr_car...@btinternet.com>
Gerrit-Reviewer: UltrasonicNXT <adamr_car...@btinternet.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to