Aaron Schulz has uploaded a new change for review.

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


Change subject: Use FileRepo::findFiles() to avoid a bunch of queries
......................................................................

Use FileRepo::findFiles() to avoid a bunch of queries

Change-Id: I93e07f823d6252b1916be96792a1d973ab9170b2
---
M GlobalUsageHooks.php
1 file changed, 3 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUsage 
refs/changes/27/99527/1

diff --git a/GlobalUsageHooks.php b/GlobalUsageHooks.php
index 8411181..787ce3a 100644
--- a/GlobalUsageHooks.php
+++ b/GlobalUsageHooks.php
@@ -20,17 +20,9 @@
                // Create a list of locally existing images
                $images = array_keys( $linksUpdater->getImages() );
 
-               //$localFiles = array_keys( 
RepoGroup::singleton()->getLocalRepo()->findFiles( $images ) );
-               // Unrolling findFiles() here because pages with thousands of 
images trigger an OOM
-               // error while building an array with thousands of File objects 
(bug 32598)
-               $localFiles = array();
-               $repo = RepoGroup::singleton()->getLocalRepo();
-               foreach ( $images as $image ) {
-                       $file = $repo->findFile( $image );
-                       if ( $file ) {
-                               $localFiles[] = $file->getTitle()->getDBkey();
-                       }
-               }
+               // Use FileRepo::TIME_ONLY to avoid OOMs
+               $localFiles = array_keys(
+                       RepoGroup::singleton()->getLocalRepo()->findFiles( 
$images, FileRepo::TIME_ONLY ) );
 
                $missingFiles = array_diff( $images, $localFiles );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I93e07f823d6252b1916be96792a1d973ab9170b2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalUsage
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

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

Reply via email to