Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/265618

Change subject: Use newer Maintenance/DB methods
......................................................................

Use newer Maintenance/DB methods

Change-Id: Ie6397da95a3541885c0cacebb4cab95afeea6c54
---
M maintenance/updateCounts.php
1 file changed, 15 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather 
refs/changes/18/265618/1

diff --git a/maintenance/updateCounts.php b/maintenance/updateCounts.php
index d04d7f5..827d28a 100644
--- a/maintenance/updateCounts.php
+++ b/maintenance/updateCounts.php
@@ -36,12 +36,13 @@
 
                $maxGlId = 0;
                do {
-                       $dbw->begin( __METHOD__ );
+                       $this->beginTransaction( $dbw, __METHOD__ );
 
                        // This locks the list record. All operations which can 
add/remove list items (apart
                        // from full list deletion) lock the record as well, so 
there cannot be race conditions.
-                       $res = $dbw->select( 'gather_list',
-                               array( 'gl_id' ),
+                       $ids = $dbw->selectFieldValues(
+                               'gather_list',
+                               'gl_id',
                                array( 'gl_id > ' . $maxGlId ),
                                __METHOD__,
                                array(
@@ -51,26 +52,19 @@
                                )
                        );
 
-                       $ids = array();
-                       foreach ( $res as $row ) {
-                               $ids[] = $row->gl_id;
+                       if ( $ids ) {
+                               $dbw->update(
+                                       'gather_list',
+                                       array( 'gl_item_count = ' .
+                                               '(SELECT COUNT(*) FROM 
gather_list_item WHERE gli_gl_id = gl_id)' ),
+                                       array( 'gl_id' => $ids ),
+                                       __METHOD__
+                               );
+                               $maxGlId = max( $ids );
                        }
 
-                       if ( !$ids ) {
-                               $dbw->rollback( __METHOD__ );
-                               continue;
-                       }
-
-                       $dbw->update( 'gather_list',
-                               array( 'gl_item_count = (SELECT COUNT(*) FROM 
gather_list_item WHERE gli_gl_id = gl_id)' ),
-                               array( 'gl_id' => $ids ),
-                       __METHOD__ );
-
-                       $dbw->commit( __METHOD__ );
-                       $maxGlId = max( $ids );
-
-                       wfWaitForSlaves();
-               } while ( $res->numRows() );
+                       $this->commitTransaction( $dbw, __METHOD__ );
+               } while ( $ids );
        }
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6397da95a3541885c0cacebb4cab95afeea6c54
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: dev
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to