Fixed inefficient use of array_keys() introduced by Nick in r17880. If this is settin...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Nov 2006 17:11:58 +0000 (17:11 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Nov 2006 17:11:58 +0000 (17:11 +0000)
includes/GlobalFunctions.php
includes/LinkBatch.php
includes/MessageCache.php
includes/OutputPage.php
includes/ProtectionForm.php
includes/api/ApiMain.php
includes/api/ApiPageSet.php
includes/api/ApiQueryInfo.php

index 3d002f6..238c77e 100644 (file)
@@ -72,7 +72,7 @@ if ( !function_exists( 'array_diff_key' ) ) {
         */
        function array_diff_key( $left, $right ) {
                $result = $left;
-               foreach ( array_keys($left) as $key ) {
+               foreach ( $left as $key => $unused ) {
                        if ( isset( $right[$key] ) ) {
                                unset( $result[$key] );
                        }
index 53f6c01..61e1c04 100644 (file)
@@ -97,7 +97,7 @@ class LinkBatch {
 
                // The remaining links in $data are bad links, register them as such
                foreach ( $remaining as $ns => $dbkeys ) {
-                       foreach ( array_keys($dbkeys) as $dbkey ) {
+                       foreach ( $dbkeys as $dbkey => $unused ) {
                                $title = Title::makeTitle( $ns, $dbkey );
                                $cache->addBadLinkObj( $title );
                                $ids[$title->getPrefixedDBkey()] = 0;
@@ -160,7 +160,7 @@ class LinkBatch {
                        $sql .= "({$prefix}_namespace=$ns AND {$prefix}_title IN (";
 
                        $firstTitle = true;
-                       foreach( array_keys($dbkeys) as $dbkey ) {
+                       foreach( $dbkeys as $dbkey => $unused ) {
                                if ( $firstTitle ) {
                                        $firstTitle = false;
                                } else {
index 532ce59..dbae08d 100644 (file)
@@ -313,7 +313,7 @@ class MessageCache {
                # Go through the language array and the extension array and make a note of
                # any keys missing from the cache
                $allMessages = Language::getMessagesFor( 'en' );
-               foreach ( array_keys($allMessages) as $key ) {
+               foreach ( $allMessages as $key => $unused ) {
                        $uckey = $wgLang->ucfirst( $key );
                        if ( !array_key_exists( $uckey, $this->mCache ) ) {
                                $this->mCache[$uckey] = false;
@@ -324,7 +324,7 @@ class MessageCache {
                MessageCache::loadAllMessages();
 
                # Add them to the cache
-               foreach ( array_keys($this->mExtensionMessages) as $key ) {
+               foreach ( $this->mExtensionMessages as $key => $unused ) {
                        $uckey = $wgLang->ucfirst( $key );
                        if ( !array_key_exists( $uckey, $this->mCache ) &&
                         ( isset( $this->mExtensionMessages[$key][$wgLang->getCode()] ) || isset( $this->mExtensionMessages[$key]['en'] ) )  ) {
@@ -343,7 +343,7 @@ class MessageCache {
                if ( !$this->mKeys ) {
                        $this->mKeys = array();
                        $allMessages = Language::getMessagesFor( 'en' );
-                       foreach ( array_keys($allMessages) as $key ) {
+                       foreach ( $allMessages as $key => $unused ) {
                                $title = $wgContLang->ucfirst( $key );
                                array_push( $this->mKeys, $title );
                        }
index 1b8707e..1dbcb9f 100644 (file)
@@ -243,7 +243,7 @@ class OutputPage {
                $lb->execute();
 
                $sk =& $wgUser->getSkin();
-               foreach ( array_keys($categories) as $category ) {
+               foreach ( $categories as $category => $unused ) {
                        $title = Title::makeTitleSafe( NS_CATEGORY, $category );
                        $text = $wgContLang->convertHtml( $title->getText() );
                        $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
@@ -1011,7 +1011,7 @@ class OutputPage {
                        return;
                }
                foreach ( $links2d as $dbkeys ) {
-                       foreach( array_keys($dbkeys) as $dbkey ) {
+                       foreach( $dbkeys as $dbkey => $unused ) {
                                $this->addKeyword( $dbkey );
                                if ( ++$count > 10 ) {
                                        break 2;
index 254dda8..f96262f 100644 (file)
@@ -130,7 +130,7 @@ class ProtectionForm {
                $out .= "<table id='mwProtectSet'>";
                $out .= "<tbody>";
                $out .= "<tr>\n";
-               foreach( array_keys($this->mRestrictions) as $action ) {
+               foreach( $this->mRestrictions as $action => $required ) {
                        /* Not all languages have V_x <-> N_x relation */
                        $out .= "<th>" . wfMsgHtml( 'restriction-' . $action ) . "</th>\n";
                }
index 697399c..22f02ba 100644 (file)
@@ -296,7 +296,7 @@ class ApiMain extends ApiBase {
 
                $astriks = str_repeat('*** ', 10);
                $msg .= "\n\n$astriks Modules  $astriks\n\n";
-               foreach( array_keys($this->mModules) as $moduleName ) {
+               foreach( $this->mModules as $moduleName => $unused ) {
                        $msg .= "* action=$moduleName *";
                        $module = new $this->mModules[$moduleName] ($this, $moduleName);
                        $msg2 = $module->makeHelpMsg();
@@ -306,7 +306,7 @@ class ApiMain extends ApiBase {
                }
 
                $msg .= "\n$astriks Formats  $astriks\n\n";
-               foreach( array_keys($this->mFormats) as $formatName ) {
+               foreach( $this->mFormats as $formatName => $unused ) {
                        $msg .= "* format=$formatName *";
                        $module = $this->createPrinterByName($formatName);
                        $msg2 = $module->makeHelpMsg();
@@ -363,4 +363,4 @@ class UsageException extends Exception {
                return "{$this->getCodeString()}: {$this->getMessage()}";
        }
 }
-?>
\ No newline at end of file
+?>
index 3b8e15a..c1009ea 100644 (file)
@@ -382,7 +382,7 @@ class ApiPageSet extends ApiQueryBase {
                        if($processTitles) {
                                // The remaining titles in $remaining are non-existant pages
                                foreach ($remaining as $ns => $dbkeys) {
-                                       foreach ( array_keys($dbkeys) as $dbkey ) {
+                                       foreach ( $dbkeys as $dbkey => $unused ) {
                                                $title = Title :: makeTitle($ns, $dbkey);
                                                $this->mMissingTitles[] = $title;
                                                $this->mAllPages[$ns][$dbkey] = 0;
@@ -595,4 +595,4 @@ class ApiPageSet extends ApiQueryBase {
                return __CLASS__ . ': $Id$';
        }
 }
-?>
\ No newline at end of file
+?>
index 0890689..07928b5 100644 (file)
@@ -52,7 +52,7 @@ class ApiQueryInfo extends ApiQueryBase {
                $pageTouched = $pageSet->getCustomField('page_touched');
                $pageLatest = $pageSet->getCustomField('page_latest');
 
-               foreach ( array_keys($titles) as $pageid) {
+               foreach ( $titles as $pageid => $unused ) {
                        $pageInfo = array (
                                'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]),
                                'lastrevid' => intval($pageLatest[$pageid])