Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php |
— | — | @@ -17,7 +17,19 @@ |
18 | 18 | |
19 | 19 | // Create a list of locally existing images |
20 | 20 | $images = array_keys( $linksUpdater->getImages() ); |
21 | | - $localFiles = array_keys( RepoGroup::singleton()->getLocalRepo()->findFiles( $images ) ); |
| 21 | + |
| 22 | + //$localFiles = array_keys( RepoGroup::singleton()->getLocalRepo()->findFiles( $images ) ); |
| 23 | + // Unrolling findFiles() here because pages with thousands of images trigger an OOM |
| 24 | + // error while building an array with thousands of File objects (bug 32598) |
| 25 | + $localFiles = array(); |
| 26 | + $repo = RepoGroup::singleton()->getLocalRepo(); |
| 27 | + foreach ( $images as $image ) { |
| 28 | + $file = $repo->findFile( $image ); |
| 29 | + if ( $file ) { |
| 30 | + $localFiles[] = $file->getTitle()->getDBkey(); |
| 31 | + } |
| 32 | + } |
| 33 | + |
22 | 34 | $missingFiles = array_diff( $images, $localFiles ); |
23 | 35 | |
24 | 36 | global $wgUseDumbLinkUpdate; |