r83699 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83698‎ | r83699 | r83700 >
Date:14:47, 11 March 2011
Author:ialex
Status:deferred
Tags:
Comment:
Do existence check in a batch operation rather than one by one
Modified paths:
  • /trunk/extensions/Polyglot/Polyglot.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Polyglot/Polyglot.php
@@ -212,11 +212,23 @@
213213 $n = $title->getDBkey();
214214 $ns = $title->getNamespace();
215215
 216+ $titles = array();
 217+ $batch = new LinkBatch();
 218+
 219+ foreach ( $wgPolyglotLanguages as $lang ) {
 220+ $obj = Title::makeTitle( $ns, $n . '/' . $lang );
 221+ $batch->addObj( $obj );
 222+ $titles[] = array( $obj, $lang );
 223+ }
 224+
 225+ $batch->execute();
216226 $links = array();
217227
218 - foreach ($wgPolyglotLanguages as $lang) {
219 - $t = Title::makeTitle($ns, $n . '/' . $lang);
220 - if ($t->exists()) $links[$lang] = $t->getFullText();
 228+ foreach( $titles as $parts ) {
 229+ list( $t, $lang ) = $parts;
 230+ if ( $t->exists() ) {
 231+ $links[$lang] = $t->getFullText();
 232+ }
221233 }
222234
223235 return $links;

Status & tagging log