From: Tim Starling Date: Sat, 25 Nov 2006 17:11:58 +0000 (+0000) Subject: Fixed inefficient use of array_keys() introduced by Nick in r17880. If this is settin... X-Git-Tag: 1.31.0-rc.0~55081 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=b1cd1b035ce269d4fedacb3d9935ae3d75d8e925;p=lhc%2Fweb%2Fwiklou.git Fixed inefficient use of array_keys() introduced by Nick in r17880. If this is setting off alarms, then fix the alarms. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 3d002f662f..238c77e2aa 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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] ); } diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 53f6c01cfa..61e1c040d4 100644 --- a/includes/LinkBatch.php +++ b/includes/LinkBatch.php @@ -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 { diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 532ce593ee..dbae08d086 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -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 ); } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1b8707ef5c..1dbcb9f715 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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; diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 254dda80d2..f96262fe6b 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -130,7 +130,7 @@ class ProtectionForm { $out .= ""; $out .= ""; $out .= "\n"; - foreach( array_keys($this->mRestrictions) as $action ) { + foreach( $this->mRestrictions as $action => $required ) { /* Not all languages have V_x <-> N_x relation */ $out .= "\n"; } diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 697399c366..22f02ba589 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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 +?> diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 3b8e15a0ee..c1009ea4a2 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -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 +?> diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 0890689d5b..07928b5012 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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])
" . wfMsgHtml( 'restriction-' . $action ) . "