jenkins-bot has submitted this change and it was merged.

Change subject: Do LinkCache queries in a batch
......................................................................


Do LinkCache queries in a batch

Currently a separate query is done for each link. Try to make it more
efficient by using LinkBatch.

Change-Id: I8c06a20d2c3a2351adff740116a4cf2d2f272a05
---
M CheckUserLogPager.php
1 file changed, 23 insertions(+), 0 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CheckUserLogPager.php b/CheckUserLogPager.php
index e0a569c..3d87ae5 100644
--- a/CheckUserLogPager.php
+++ b/CheckUserLogPager.php
@@ -84,4 +84,27 @@
                        'cul_target_id', 'cul_target_text', 'user_name'
                );
        }
+
+       /**
+        * Do a batch query for links' existence and add it to LinkCache
+        *
+        * @param ResultWrapper $result
+        */
+       protected function preprocessResults( $result ) {
+               if ( $this->getNumRows() === 0 ) {
+                       return;
+               }
+
+               $lb = new LinkBatch;
+               $lb->setCaller( __METHOD__ );
+               foreach ( $result as $row ) {
+                       $lb->add( NS_USER, $row->user_name ); // Performer
+                       if ( $row->cul_type == 'userips' || $row->cul_type == 
'useredits' ) {
+                               $lb->add( NS_USER, $row->cul_target_text );
+                               $lb->add( NS_USER_TALK, $row->cul_target_text );
+                       }
+               }
+               $lb->execute();
+               $result->seek( 0 );
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8c06a20d2c3a2351adff740116a4cf2d2f272a05
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CheckUser
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to