From 14c53b728fe55f9ad21647b2303c49f1cb491901 Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Thu, 23 Nov 2006 08:25:56 +0000 Subject: [PATCH] Code housekeeping stuff (and barring any stuff-ups on my behalf, there should be no changes in behaviour whatsoever after this) - * removing some unused global declarations. * removing or commenting out or adding comments for unused local vars. * Adding one or two local var declarations. * Declaring $matches array passed to preg_match() / preg_match_all() as array() before using [not required, just have a slight preference for the explicitness]. * remove one or two pass-by-reference function declarations where the value is not modified. * Adding some braces to if-else blocks. * In Parser.php, stripstrate is now an object rather than an array as per r17820, so we no longer need ask for a reference to it (as in "$x =& $this->mStripState;"), and in fact it's probably just simpler to get rid of $x altogether. * Moving some preg regexes from "" quoting to '' quoting to stop static analyzer whinging about bad escape sequences. ... up to "LinksUpdate.php" in the includes/ directory. --- includes/Article.php | 22 +++------------- includes/DatabaseFunctions.php | 1 - includes/DatabaseOracle.php | 21 ++++++++-------- includes/EditPage.php | 3 +++ includes/Exif.php | 14 +++++++---- includes/GlobalFunctions.php | 25 +++++++++++-------- includes/HTMLForm.php | 2 +- includes/ImagePage.php | 8 ++---- includes/Licenses.php | 8 +++--- includes/LinkBatch.php | 5 ++-- includes/Linker.php | 10 +++----- includes/MessageCache.php | 8 +++--- includes/MimeMagic.php | 2 -- includes/OutputPage.php | 8 +++--- includes/Parser.php | 12 ++++----- includes/Profiler.php | 4 +-- includes/ProtectionForm.php | 2 +- includes/RecentChange.php | 2 +- includes/Sanitizer.php | 8 +++--- includes/SearchEngine.php | 1 + includes/SearchPostgres.php | 3 ++- includes/SpecialAllpages.php | 16 ++++++------ includes/SpecialBlockip.php | 2 +- includes/SpecialContributions.php | 1 - includes/SpecialImport.php | 3 +-- includes/SpecialMovepage.php | 3 +-- includes/SpecialNewimages.php | 9 ++++--- includes/SpecialRecentchanges.php | 7 +++--- includes/SpecialRecentchangeslinked.php | 2 +- includes/SpecialRevisiondelete.php | 7 +++--- includes/SpecialSearch.php | 3 +-- includes/SpecialUpload.php | 29 +++++++++++----------- includes/SpecialUserlogin.php | 1 - includes/SpecialUserrights.php | 1 - includes/SpecialWatchlist.php | 23 ++++++----------- includes/SpecialWhatlinkshere.php | 2 -- includes/User.php | 12 +++++---- includes/Xml.php | 4 +-- includes/ZhClient.php | 2 +- includes/api/ApiBase.php | 1 - includes/api/ApiFeedWatchlist.php | 4 +-- includes/api/ApiFormatYaml_spyc.php | 9 ++++++- includes/api/ApiMain.php | 4 +-- includes/api/ApiOpenSearch.php | 2 +- includes/api/ApiPageSet.php | 2 +- includes/api/ApiQueryAllpages.php | 2 +- includes/api/ApiQueryBacklinks.php | 1 - includes/api/ApiQueryInfo.php | 2 +- includes/api/ApiQueryRecentChanges.php | 2 +- includes/api/ApiQueryUserContributions.php | 9 ++++--- includes/api/ApiQueryWatchlist.php | 2 +- includes/cbt/CBTCompiler.php | 4 +-- includes/normal/RandomTest.php | 1 + includes/normal/Utf8Test.php | 2 ++ includes/normal/UtfNormal.php | 6 ++--- includes/normal/UtfNormalGenerate.php | 1 + includes/normal/UtfNormalTest.php | 2 +- 57 files changed, 166 insertions(+), 186 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index abae3dd3bb..d85a24bee2 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -79,7 +79,7 @@ class Article { } } else { if( $rt->getNamespace() == NS_SPECIAL ) { - // Gotta hand redirects to special pages differently: + // Gotta handle redirects to special pages differently: // Fill the HTTP response "Location" header and ignore // the rest of the page we're on. // @@ -139,7 +139,7 @@ class Article { * @return Return the text of this revision */ function getContent() { - global $wgRequest, $wgUser, $wgOut; + global $wgUser, $wgOut; wfProfileIn( __METHOD__ ); @@ -236,9 +236,6 @@ class Article { # Pre-fill content with error message so that if something # fails we'll have something telling us what we intended. - - $t = $this->mTitle->getPrefixedText(); - $this->mOldId = $oldid; $this->fetchContent( $oldid ); } @@ -575,13 +572,10 @@ class Article { function getContributors($limit = 0, $offset = 0) { # XXX: this is expensive; cache this info somewhere. - $title = $this->mTitle; $contribs = array(); $dbr =& wfGetDB( DB_SLAVE ); $revTable = $dbr->tableName( 'revision' ); $userTable = $dbr->tableName( 'user' ); - $encDBkey = $dbr->addQuotes( $title->getDBkey() ); - $ns = $title->getNamespace(); $user = $this->getUser(); $pageId = $this->getId(); @@ -784,9 +778,6 @@ class Article { if( !$wasRedirected && $this->isCurrent() ) { $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); } - $targetUrl = $rt->escapeLocalURL(); - # fixme unused $titleText : - $titleText = htmlspecialchars( $rt->getPrefixedText() ); $link = $sk->makeLinkObj( $rt ); $wgOut->addHTML( '#REDIRECT' . @@ -1924,7 +1915,7 @@ class Article { */ function doDeleteArticle( $reason ) { global $wgUseSquid, $wgDeferredUpdateList; - global $wgPostCommitUpdateList, $wgUseTrackbacks; + global $wgUseTrackbacks; wfDebug( __METHOD__."\n" ); @@ -2041,8 +2032,6 @@ class Article { $bot = $wgRequest->getBool( 'bot' ); # Replace all this user's current edits with the next one down - $tt = $this->mTitle->getDBKey(); - $n = $this->mTitle->getNamespace(); # Get the last editor $current = Revision::newFromTitle( $this->mTitle ); @@ -2409,8 +2398,7 @@ class Article { 'comment' => $comment, 'minor_edit' => $minor ? 1 : 0, ) ); - # fixme : $revisionId never used - $revisionId = $revision->insertOn( $dbw ); + $revision->insertOn( $dbw ); $this->updateRevisionOn( $dbw, $revision ); $dbw->commit(); @@ -2524,8 +2512,6 @@ class Article { static function onArticleEdit( $title ) { global $wgDeferredUpdateList, $wgUseFileCache; - $urls = array(); - // Invalidate caches of articles which include this page $update = new HTMLCacheUpdate( $title, 'templatelinks' ); $wgDeferredUpdateList[] = $update; diff --git a/includes/DatabaseFunctions.php b/includes/DatabaseFunctions.php index c9dc9e7259..ca83b9e551 100644 --- a/includes/DatabaseFunctions.php +++ b/includes/DatabaseFunctions.php @@ -14,7 +14,6 @@ * @param $fname String: name of the php function calling */ function wfQuery( $sql, $db, $fname = '' ) { - global $wgOut; if ( !is_numeric( $db ) ) { # Someone has tried to call this the old way throw new FatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) ); diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index 81635677e5..1a6f62f2fe 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -55,9 +55,6 @@ class DatabaseOracle extends Database { $this->mPassword = $password; $this->mDBname = $dbName; - $success = false; - - $hstring=""; $this->mConn = oci_new_connect($user, $password, $dbName, "AL32UTF8"); if ( $this->mConn === false ) { wfDebug( "DB connection error\n" ); @@ -147,7 +144,6 @@ class DatabaseOracle extends Database { for ($i = 1; $i <= $this->mNcols[$res]; $i++) { $name = $this->mFieldNames[$res][$i]; - $type = $this->mFieldTypes[$res][$i]; if (isset($this->mFetchCache[$res][$this->mFetchID[$res]][$name])) $value = $this->mFetchCache[$res][$this->mFetchID[$res]][$name]; else $value = NULL; @@ -165,7 +161,7 @@ class DatabaseOracle extends Database { return false; $i = 0; $ret = array(); - foreach ($r as $key => $value) { + foreach ($r as $value) { wfdebug("ret[$i]=[$value]\n"); $ret[$i++] = $value; } @@ -201,14 +197,19 @@ class DatabaseOracle extends Database { function lastError() { if ($this->mErr === false) { - if ($this->mLastResult !== false) $what = $this->mLastResult; - else if ($this->mConn !== false) $what = $this->mConn; - else $what = false; + if ($this->mLastResult !== false) { + $what = $this->mLastResult; + } else if ($this->mConn !== false) { + $what = $this->mConn; + } else { + $what = false; + } $err = ($what !== false) ? oci_error($what) : oci_error(); - if ($err === false) + if ($err === false) { $this->mErr = 'no error'; - else + } else { $this->mErr = $err['message']; + } } return str_replace("\n", '
', $this->mErr); } diff --git a/includes/EditPage.php b/includes/EditPage.php index 33db6fdfbe..28fab28379 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -571,6 +571,7 @@ class EditPage { $this->mMetaData = '' ; # Check for spam + $matches = array(); if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) { $this->spamPage ( $matches[0] ); wfProfileOut( "$fname-checks" ); @@ -858,6 +859,7 @@ class EditPage { $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText() ); } else { $s = wfMsg('editingsection', $this->mTitle->getPrefixedText() ); + $matches = array(); if( !$this->summary && !$this->preview && !$this->diff ) { preg_match( "/^(=+)(.+)\\1/mi", $this->textbox1, @@ -1513,6 +1515,7 @@ END } $currentText = $currentRevision->getText(); + $result = ''; if( wfMerge( $baseText, $editText, $currentText, $result ) ){ $editText = $result; wfProfileOut( $fname ); diff --git a/includes/Exif.php b/includes/Exif.php index 2ab0feb13e..e21b4d9ef7 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -439,7 +439,7 @@ class Exif { return false; } - if ( preg_match( "/^\s*$/", $in ) ) { + if ( preg_match( '/^\s*$/', $in ) ) { $this->debug( $in, __FUNCTION__, 'input consisted solely of whitespace' ); return false; } @@ -468,7 +468,8 @@ class Exif { } function isRational( $in ) { - if ( !is_array( $in ) && @preg_match( "/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/", $in, $m ) ) { # Avoid division by zero + $m = array(); + if ( !is_array( $in ) && @preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero return $this->isLong( $m[1] ) && $this->isLong( $m[2] ); } else { $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' ); @@ -477,7 +478,7 @@ class Exif { } function isUndefined( $in ) { - if ( !is_array( $in ) && preg_match( "/^\d{4}$/", $in ) ) { // Allow ExifVersion and FlashpixVersion + if ( !is_array( $in ) && preg_match( '/^\d{4}$/', $in ) ) { // Allow ExifVersion and FlashpixVersion $this->debug( $in, __FUNCTION__, true ); return true; } else { @@ -497,7 +498,8 @@ class Exif { } function isSrational( $in ) { - if ( !is_array( $in ) && preg_match( "/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/", $in, $m ) ) { # Avoid division by zero + $m = array(); + if ( !is_array( $in ) && preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] ); } else { $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' ); @@ -729,7 +731,7 @@ class FormatExif { case 'DateTime': case 'DateTimeOriginal': case 'DateTimeDigitized': - if( preg_match( "/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/", $val ) ) { + if( preg_match( '/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/', $val ) ) { $tags[$tag] = $wgLang->timeanddate( wfTimestamp(TS_MW, $val) ); } break; @@ -1054,6 +1056,7 @@ class FormatExif { * @return mixed A floating point number or whatever we were fed */ function formatNum( $num ) { + $m = array(); if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) ) return $m[2] != 0 ? $m[1] / $m[2] : $num; else @@ -1069,6 +1072,7 @@ class FormatExif { * @return mixed A floating point number or whatever we were fed */ function formatFraction( $num ) { + $m = array(); if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) ) { $numerator = intval( $m[1] ); $denominator = intval( $m[2] ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 14e49ea593..50935e1b30 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -52,6 +52,7 @@ if( !function_exists('iconv') ) { # UTF-8 substr function based on a PHP manual comment if ( !function_exists( 'mb_substr' ) ) { function mb_substr( $str, $start ) { + $ar = array(); preg_match_all( '/./us', $str, $ar ); if( func_num_args() >= 3 ) { @@ -71,7 +72,7 @@ if ( !function_exists( 'array_diff_key' ) ) { */ function array_diff_key( $left, $right ) { $result = $left; - foreach ( $left as $key => $value ) { + foreach ( array_keys($left) as $key ) { if ( isset( $right[$key] ) ) { unset( $result[$key] ); } @@ -382,8 +383,6 @@ function wfMsgNoDBForContent( $key ) { * @return String: the requested message. */ function wfMsgReal( $key, $args, $useDB = true, $forContent=false, $transform = true ) { - $fname = 'wfMsgReal'; - $message = wfMsgGetKey( $key, $useDB, $forContent, $transform ); $message = wfMsgReplaceArgs( $message, $args ); return $message; @@ -530,7 +529,7 @@ function wfMsgWikiHtml( $key ) { * parsemag: ?? */ function wfMsgExt( $key, $options ) { - global $wgOut, $wgMsgParserOptions, $wgParser; + global $wgOut, $wgParser; $args = func_get_args(); array_shift( $args ); @@ -807,6 +806,7 @@ function wfClientAcceptsGzip() { global $wgUseGzip; if( $wgUseGzip ) { # FIXME: we may want to blacklist some broken browsers + $m = array(); if( preg_match( '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', $_SERVER['HTTP_ACCEPT_ENCODING'], @@ -972,6 +972,7 @@ function wfEscapeShellArg( ) { } // Double the backslashes before the end of the string, because // we will soon add a quote + $m = array(); if ( preg_match( '/^(.*?)(\\\\+)$/', $arg, $m ) ) { $arg = $m[1] . str_replace( '\\', '\\\\', $m[2] ); } @@ -1095,6 +1096,7 @@ function wfAcceptToPrefs( $accept, $def = '*/*' ) { foreach( $parts as $part ) { # FIXME: doesn't deal with params like 'text/html; level=1' @list( $value, $qpart ) = explode( ';', $part ); + $match = array(); if( !isset( $qpart ) ) { $prefs[$value] = 1; } elseif( preg_match( '/q\s*=\s*(\d*\.\d+)/', $qpart, $match ) ) { @@ -1289,19 +1291,19 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { $da = array(); if ($ts==0) { $uts=time(); - } elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D",$ts,$da)) { + } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D',$ts,$da)) { # TS_DB $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); - } elseif (preg_match("/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/D",$ts,$da)) { + } elseif (preg_match('/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/D',$ts,$da)) { # TS_EXIF $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); - } elseif (preg_match("/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D",$ts,$da)) { + } elseif (preg_match('/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D',$ts,$da)) { # TS_MW $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); - } elseif (preg_match("/^(\d{1,13})$/D",$ts,$datearray)) { + } elseif (preg_match('/^(\d{1,13})$/D',$ts,$da)) { # TS_UNIX $uts = $ts; } elseif (preg_match('/^(\d{1,2})-(...)-(\d\d(\d\d)?) (\d\d)\.(\d\d)\.(\d\d)/', $ts, $da)) { @@ -1312,11 +1314,11 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { # TS_ISO_8601 $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); - } elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)[\+\- ](\d\d)$/",$ts,$da)) { + } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)[\+\- ](\d\d)$/',$ts,$da)) { # TS_POSTGRES $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); - } elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/",$ts,$da)) { + } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/',$ts,$da)) { # TS_POSTGRES $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], (int)$da[2],(int)$da[3],(int)$da[1]); @@ -1687,7 +1689,7 @@ function wfShellExec( $cmd, &$retval=null ) { $output = array(); $retval = 1; // error by default? - $lastline = exec( $cmd, $output, $retval ); + exec( $cmd, $output, $retval ); // returns the last line of output. return implode( "\n", $output ); } @@ -1753,6 +1755,7 @@ function wfRegexReplacement( $string ) { * @return string */ function wfBaseName( $path ) { + $matches = array(); if( preg_match( '#([^/\\\\]*)[/\\\\]*$#', $path, $matches ) ) { return $matches[1]; } else { diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 3ee85859c5..189e5c7956 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -99,7 +99,7 @@ class HTMLForm { if ( $this->mRequest->wasPosted() ) { $arr = $this->mRequest->getArray( $varname ); if ( is_array( $arr ) ) { - foreach ( $_POST[$varname] as $index => $element ) { + foreach ( $_POST[$varname] as $element ) { $s .= htmlspecialchars( $element )."\n"; } } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 102ae49ea3..247c539f56 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -142,6 +142,7 @@ class ImagePage extends Article { $fields = array(); $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) ); foreach( $lines as $line ) { + $matches = array(); if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) { $fields[] = $matches[1]; } @@ -536,15 +537,10 @@ END * @param $reason User provided reason for deletion. */ function doDelete( $reason ) { - global $wgOut, $wgRequest, $wgUseSquid; - global $wgPostCommitUpdateList; - - $fname = 'ImagePage::doDelete'; + global $wgOut, $wgRequest; $oldimage = $wgRequest->getVal( 'oldimage' ); - $dbw =& wfGetDB( DB_MASTER ); - if ( !is_null( $oldimage ) ) { if ( strlen( $oldimage ) < 16 ) { $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); diff --git a/includes/Licenses.php b/includes/Licenses.php index aaa44052bf..dd1308b44e 100644 --- a/includes/Licenses.php +++ b/includes/Licenses.php @@ -63,12 +63,14 @@ class Licenses { $obj = new License( $line ); $this->stackItem( $this->licenses, $levels, $obj ); } else { - if ( $level < count( $levels ) ) + if ( $level < count( $levels ) ) { $levels = array_slice( $levels, 0, $level ); - if ( $level == count( $levels ) ) + } + if ( $level == count( $levels ) ) { $levels[$level - 1] = $line; - else if ( $level > count( $levels ) ) + } else if ( $level > count( $levels ) ) { $levels[] = $line; + } } } } diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 061f1b191a..53f6c01cfa 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 ( $dbkeys as $dbkey => $nothing ) { + foreach ( array_keys($dbkeys) as $dbkey ) { $title = Title::makeTitle( $ns, $dbkey ); $cache->addBadLinkObj( $title ); $ids[$title->getPrefixedDBkey()] = 0; @@ -112,7 +112,6 @@ class LinkBatch { */ function doQuery() { $fname = 'LinkBatch::doQuery'; - $namespaces = array(); if ( $this->isEmpty() ) { return false; @@ -161,7 +160,7 @@ class LinkBatch { $sql .= "({$prefix}_namespace=$ns AND {$prefix}_title IN ("; $firstTitle = true; - foreach( $dbkeys as $dbkey => $nothing ) { + foreach( array_keys($dbkeys) as $dbkey ) { if ( $firstTitle ) { $firstTitle = false; } else { diff --git a/includes/Linker.php b/includes/Linker.php index db82a77cb6..ba66873922 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -38,7 +38,6 @@ class Linker { function getInterwikiLinkAttributes( $link, $text, $class='' ) { global $wgContLang; - $same = ($link == $text); $link = urldecode( $link ); $link = $wgContLang->checkTitleEncoding( $link ); $link = preg_replace( '/[\\x00-\\x1f]/', ' ', $link ); @@ -200,8 +199,6 @@ class Linker { return "{$prefix}{$text}{$trail}"; } - $ns = $nt->getNamespace(); - $dbkey = $nt->getDBkey(); if ( $nt->isExternal() ) { $u = $nt->getFullURL(); $link = $nt->getPrefixedURL(); @@ -210,6 +207,7 @@ class Linker { $inside = ''; if ( '' != $trail ) { + $m = array(); if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) { $inside = $m[1]; $trail = $m[2]; @@ -381,8 +379,6 @@ class Linker { * the end of the link. */ function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { - $link = $nt->getPrefixedURL(); - $u = $nt->escapeLocalURL( $query ); if ( '' == $text ) { @@ -717,7 +713,6 @@ class Linker { ### HOTFIX. Instead of breaking, return empty string. return $text; } else { - $name = $title->getDBKey(); $img = new Image( $title ); if( $img->exists() ) { $url = $img->getURL(); @@ -901,6 +896,7 @@ class Linker { # some nasty regex. # We look for all comments, match any text before and after the comment, # add a separator where needed and format the comment itself with CSS + $match = array(); while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) { $pre=$match[1]; $auto=$match[2]; @@ -943,6 +939,7 @@ class Linker { } else { $text = $match[1]; } + $submatch = array(); if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) { # Media link; trail not supported. $linkRegexp = '/\[\[(.*?)\]\]/'; @@ -1094,6 +1091,7 @@ class Linker { } $inside = ''; if ( '' != $trail ) { + $m = array(); if ( preg_match( $regex, $trail, $m ) ) { $inside = $m[1]; $trail = $m[2]; diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 058ada5aa6..532ce593ee 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -298,8 +298,6 @@ class MessageCache { if ( !$dbr ) { throw new MWException( 'Invalid database object' ); } - $conditions = array( 'page_is_redirect' => 0, - 'page_namespace' => NS_MEDIAWIKI); $res = $dbr->select( array( 'page', 'revision', 'text' ), array( 'page_title', 'old_text', 'old_flags' ), 'page_is_redirect=0 AND page_namespace='.NS_MEDIAWIKI.' AND page_latest=rev_id AND rev_text_id=old_id', @@ -315,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 ( $allMessages as $key => $value ) { + foreach ( array_keys($allMessages) as $key ) { $uckey = $wgLang->ucfirst( $key ); if ( !array_key_exists( $uckey, $this->mCache ) ) { $this->mCache[$uckey] = false; @@ -326,7 +324,7 @@ class MessageCache { MessageCache::loadAllMessages(); # Add them to the cache - foreach ( $this->mExtensionMessages as $key => $value ) { + foreach ( array_keys($this->mExtensionMessages) as $key ) { $uckey = $wgLang->ucfirst( $key ); if ( !array_key_exists( $uckey, $this->mCache ) && ( isset( $this->mExtensionMessages[$key][$wgLang->getCode()] ) || isset( $this->mExtensionMessages[$key]['en'] ) ) ) { @@ -345,7 +343,7 @@ class MessageCache { if ( !$this->mKeys ) { $this->mKeys = array(); $allMessages = Language::getMessagesFor( 'en' ); - foreach ( $allMessages as $key => $value ) { + foreach ( array_keys($allMessages) as $key ) { $title = $wgContLang->ucfirst( $key ); array_push( $this->mKeys, $title ); } diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index dd197c31c8..ca05dbb351 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -403,8 +403,6 @@ class MimeMagic { elseif ($tag==="svg") $mime= "image/svg"; elseif (strpos($doctype,"-//W3C//DTD XHTML")===0) $mime= "text/html"; elseif ($tag==="html") $mime= "text/html"; - - $test_more= false; } } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b1bc128ecc..1b8707ef5c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -243,7 +243,7 @@ class OutputPage { $lb->execute(); $sk =& $wgUser->getSkin(); - foreach ( $categories as $category => $arbitrary ) { + foreach ( array_keys($categories) as $category ) { $title = Title::makeTitleSafe( NS_CATEGORY, $category ); $text = $wgContLang->convertHtml( $title->getText() ); $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text ); @@ -512,7 +512,7 @@ class OutputPage { public function output() { global $wgUser, $wgOutputEncoding, $wgRequest; global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType; - global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgScriptPath, $wgServer; + global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgServer; global $wgStyleVersion; if( $this->mDoNothing ){ @@ -1010,8 +1010,8 @@ class OutputPage { if ( !is_array( $links2d ) ) { return; } - foreach ( $links2d as $ns => $dbkeys ) { - foreach( $dbkeys as $dbkey => $id ) { + foreach ( $links2d as $dbkeys ) { + foreach( array_keys($dbkeys) as $dbkey ) { $this->addKeyword( $dbkey ); if ( ++$count > 10 ) { break 2; diff --git a/includes/Parser.php b/includes/Parser.php index 73ac43ce55..b1abe91472 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -383,10 +383,9 @@ class Parser */ function recursiveTagParse( $text ) { wfProfileIn( __METHOD__ ); - $x =& $this->mStripState; - wfRunHooks( 'ParserBeforeStrip', array( &$this, &$text, &$x ) ); - $text = $this->strip( $text, $x ); - wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$x ) ); + wfRunHooks( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) ); + $text = $this->strip( $text, $this->mStripState ); + wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); $text = $this->internalParse( $text ); wfProfileOut( __METHOD__ ); return $text; @@ -931,8 +930,7 @@ class Parser wfProfileIn( $fname ); # Hook to suspend the parser in this state - $x =& $this->mStripState; // FIXME: Please check that this initialization is correct. - if ( !wfRunHooks( 'ParserBeforeInternalParse', array( &$this, &$text, &$x ) ) ) { + if ( !wfRunHooks( 'ParserBeforeInternalParse', array( &$this, &$text, &$this->mStripState ) ) ) { wfProfileOut( $fname ); return $text ; } @@ -1820,7 +1818,7 @@ class Parser * @return string less-or-more HTML with NOPARSE bits */ function armorLinks( $text ) { - return preg_replace( "/\b(" . wfUrlProtocols() . ')/', + return preg_replace( '/\b(' . wfUrlProtocols() . ')/', "{$this->mUniqPrefix}NOPARSE$1", $text ); } diff --git a/includes/Profiler.php b/includes/Profiler.php index 78003e02fc..b15f1c3d3c 100644 --- a/includes/Profiler.php +++ b/includes/Profiler.php @@ -164,7 +164,7 @@ class Profiler { } function getCallTreeLine($entry) { - list ($fname, $level, $start, $x, $end) = $entry; + list ($fname, $level, $start, /* $x */, $end) = $entry; $delta = $end - $start; $space = str_repeat(' ', $level); @@ -208,7 +208,6 @@ class Profiler { # First, subtract the overhead! foreach ($this->mStack as $entry) { $fname = $entry[0]; - $thislevel = $entry[1]; $start = $entry[2]; $end = $entry[4]; $elapsed = $end - $start; @@ -229,7 +228,6 @@ class Profiler { # Collate foreach ($this->mStack as $index => $entry) { $fname = $entry[0]; - $thislevel = $entry[1]; $start = $entry[2]; $end = $entry[4]; $elapsed = $end - $start; diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index f96262fe6b..254dda80d2 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -130,7 +130,7 @@ class ProtectionForm { $out .= ""; $out .= ""; $out .= "\n"; - foreach( $this->mRestrictions as $action => $required ) { + foreach( array_keys($this->mRestrictions) as $action ) { /* Not all languages have V_x <-> N_x relation */ $out .= "\n"; } diff --git a/includes/RecentChange.php b/includes/RecentChange.php index ebd4b3358a..6204def9c2 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -95,7 +95,7 @@ class RecentChange # Writes the data in this object to the database function save() { - global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix, $wgUseRCPatrol; + global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix; $fname = 'RecentChange::save'; $dbw =& wfGetDB( DB_MASTER ); diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 49a5f10d3e..cda1478c23 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -391,8 +391,9 @@ class Sanitizer { $tagstack = $tablestack = array(); foreach ( $bits as $x ) { $prev = error_reporting( E_ALL & ~( E_NOTICE | E_WARNING ) ); + $regs = array(); preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ); - list( $qbar, $slash, $t, $params, $brace, $rest ) = $regs; + list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; error_reporting( $prev ); $badtag = 0 ; @@ -487,7 +488,7 @@ class Sanitizer { foreach ( $bits as $x ) { preg_match( '/^(\\/?)(\\w+)([^>]*?)(\\/{0,1}>)([^<]*)$/', $x, $regs ); - @list( $qbar, $slash, $t, $params, $brace, $rest ) = $regs; + @list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs; if ( isset( $htmlelements[$t = strtolower( $t )] ) ) { if( is_callable( $processCallback ) ) { call_user_func_array( $processCallback, array( &$params, $args ) ); @@ -1223,8 +1224,9 @@ class Sanitizer { $url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url ); # Validate hostname portion + $matches = array(); if( preg_match( '!^([^:]+:)(//[^/]+)?(.*)$!iD', $url, $matches ) ) { - list( $whole, $protocol, $host, $rest ) = $matches; + list( /* $whole */, $protocol, $host, $rest ) = $matches; // Characters that will be ignored in IDNs. // http://tools.ietf.org/html/3454#section-3.1 diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 32725a5a34..cec40c9166 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -126,6 +126,7 @@ class SearchEngine { } # Quoted term? Try without the quotes... + $matches = array(); if( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) { return SearchEngine::getNearMatch( $matches[1] ); } diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php index faf53f027a..fb4dd5be8f 100644 --- a/includes/SearchPostgres.php +++ b/includes/SearchPostgres.php @@ -60,6 +60,7 @@ class SearchPostgres extends SearchEngine { $this->searchTerms = array(); # FIXME: This doesn't handle parenthetical expressions. + $m = array(); if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach( $m as $terms ) { @@ -77,7 +78,7 @@ class SearchPostgres extends SearchEngine { $this->searchTerms[] = $regexp; } wfDebug( "Would search with '$searchon'\n" ); - wfDebug( "Match with /\b" . implode( '\b|\b', $this->searchTerms ) . "\b/\n" ); + wfDebug( 'Match with /\b' . implode( '\b|\b', $this->searchTerms ) . "\b/\n" ); } else { wfDebug( "Can't understand search query '{$this->filteredText}'\n" ); } diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index e868ec7160..1fc4815adc 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -83,8 +83,7 @@ function namespaceForm ( $namespace = NS_MAIN, $from = '' ) { * @param integer $namespace (default NS_MAIN) */ function showToplevel ( $namespace = NS_MAIN, $including = false ) { - global $wgOut, $wgUser; - $sk = $wgUser->getSkin(); + global $wgOut; $fname = "indexShowToplevel"; # TODO: Either make this *much* faster or cache the title index points @@ -186,8 +185,6 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) { */ function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) { global $wgUser; - $sk = $wgUser->getSkin(); - $dbr =& wfGetDB( DB_SLAVE ); $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) ); $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) ); @@ -241,7 +238,6 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { $n = 0; $out = '
" . wfMsgHtml( 'restriction-' . $action ) . "
'; - $namespaces = $wgContLang->getFormattedNamespaces(); while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title ); if( $t ) { @@ -298,18 +294,20 @@ function getNamespaceKeyAndText ($ns, $text) { return array( $ns, '', '' ); # shortcut for common case $t = Title::makeTitleSafe($ns, $text); - if ( $t && $t->isLocal() ) + if ( $t && $t->isLocal() ) { return array( $t->getNamespace(), $t->getDBkey(), $t->getText() ); - else if ( $t ) + } else if ( $t ) { return NULL; + } # try again, in case the problem was an empty pagename $text = preg_replace('/(#|$)/', 'X$1', $text); $t = Title::makeTitleSafe($ns, $text); - if ( $t && $t->isLocal() ) + if ( $t && $t->isLocal() ) { return array( $t->getNamespace(), '', '' ); - else + } else { return NULL; + } } } diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index fd1a8aa970..98d75ff0af 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -80,7 +80,6 @@ class IPBlockForm { } $scBlockAddress = htmlspecialchars( $this->BlockAddress ); - $scBlockExpiry = htmlspecialchars( $this->BlockExpiry ); $scBlockReason = htmlspecialchars( $this->BlockReason ); $scBlockOtherTime = htmlspecialchars( $this->BlockOther ); $scBlockExpiryOptions = htmlspecialchars( wfMsgForContent( 'ipboptions' ) ); @@ -189,6 +188,7 @@ class IPBlockForm { # Check for invalid specifications if ( ! preg_match( "/^$rxIP$/", $this->BlockAddress ) ) { + $matches = array(); if ( preg_match( "/^($rxIP)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { if ( $wgSysopRangeBans ) { if ( $matches[2] > 31 || $matches[2] < 16 ) { diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 239fb8b689..5d058e923d 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -168,7 +168,6 @@ class ContribsFinder { */ function wfSpecialContributions( $par = null ) { global $wgUser, $wgOut, $wgLang, $wgRequest; - $fname = 'wfSpecialContributions'; $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' ); if ( !strlen( $target ) ) { diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 04deb1bfd3..f147808268 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -208,7 +208,7 @@ class ImportReporter { $dbw = wfGetDB( DB_MASTER ); $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleId(), $comment, true ); - $nullRevId = $nullRevision->insertOn( $dbw ); + $nullRevision->insertOn( $dbw ); } } @@ -304,7 +304,6 @@ class WikiRevision { } function importOldRevision() { - $fname = "WikiImporter::importOldRevision"; $dbw =& wfGetDB( DB_MASTER ); # Sneak a single revision into place diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 1b9e7b2dce..6701c083d3 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -9,7 +9,7 @@ * Constructor */ function wfSpecialMovepage( $par = null ) { - global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove; + global $wgUser, $wgOut, $wgRequest, $action; # Check rights if ( !$wgUser->isAllowed( 'move' ) ) { @@ -189,7 +189,6 @@ class MovePageForm { function doSubmit() { global $wgOut, $wgUser, $wgRequest; - $fname = "MovePageForm::doSubmit"; if ( $wgUser->pingLimiter( 'move' ) ) { $wgOut->rateLimited(); diff --git a/includes/SpecialNewimages.php b/includes/SpecialNewimages.php index 66cf42603c..062e7e12ee 100644 --- a/includes/SpecialNewimages.php +++ b/includes/SpecialNewimages.php @@ -9,7 +9,7 @@ * */ function wfSpecialNewimages( $par, $specialPage ) { - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgGroupPermissions; + global $wgUser, $wgOut, $wgLang, $wgRequest, $wgGroupPermissions; $wpIlMatch = $wgRequest->getText( 'wpIlMatch' ); $dbr =& wfGetDB( DB_SLAVE ); @@ -67,9 +67,11 @@ function wfSpecialNewimages( $par, $specialPage ) { /** Hardcode this for now. */ $limit = 48; - if ( $parval = intval( $par ) ) - if ( $parval <= $limit && $parval > 0 ) + if ( $parval = intval( $par ) ) { + if ( $parval <= $limit && $parval > 0 ) { $limit = $parval; + } + } $where = array(); $searchpar = ''; @@ -163,7 +165,6 @@ function wfSpecialNewimages( $par, $specialPage ) { htmlspecialchars( $wpIlMatch ) . "\" /> " . "" ); } - $here = $wgContLang->specialPage( 'Newimages' ); /** * Paging controls... diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index cfa115f168..b7ed1302fe 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -14,7 +14,7 @@ require_once( 'ChangesList.php' ); * Constructor */ function wfSpecialRecentchanges( $par, $specialPage ) { - global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol, $wgDBtype; + global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol; global $wgRCShowWatchingUsers, $wgShowUpdatedMarker; global $wgAllowCategorizedRecentChanges ; $fname = 'wfSpecialRecentchanges'; @@ -90,7 +90,8 @@ function wfSpecialRecentchanges( $par, $specialPage ) { if ( is_numeric( $bit ) ) { $limit = $bit; } - + + $m = array(); if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) { $limit = $m[1]; } @@ -222,7 +223,6 @@ function wfSpecialRecentchanges( $par, $specialPage ) { } // And now for the content - $sk = $wgUser->getSkin(); $wgOut->setSyndicated( true ); $list = ChangesList::newFromUser( $wgUser ); @@ -397,7 +397,6 @@ function rcDoOutputFeed( $rows, &$feed ) { $sorted[$n] = $obj; $n++; } - $first = false; } foreach( $sorted as $obj ) { diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index 59a3beb5c7..8dcb1dd64b 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -48,7 +48,7 @@ function wfSpecialRecentchangeslinked( $par = NULL ) { if ( ! $days ) { $days = 7; } } $days = (int)$days; - list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' ); + list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' ); $dbr =& wfGetDB( DB_SLAVE ); $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) ); diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index 1ab505dbf1..fb5e9ec8c4 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -10,12 +10,11 @@ */ function wfSpecialRevisiondelete( $par = null ) { - global $wgOut, $wgRequest, $wgUser; + global $wgOut, $wgRequest; $target = $wgRequest->getVal( 'target' ); $oldid = $wgRequest->getIntArray( 'oldid' ); - $sk = $wgUser->getSkin(); $page = Title::newFromUrl( $target ); if( is_null( $page ) ) { @@ -156,7 +155,7 @@ class RevisionDeleteForm { function extractBitfield( $request ) { $bitfield = 0; foreach( $this->checks as $item ) { - list( $message, $name, $field ) = $item; + list( /* message */ , $name, $field ) = $item; if( $request->getCheck( $name ) ) { $bitfield |= $field; } @@ -167,7 +166,7 @@ class RevisionDeleteForm { function save( $bitfield, $reason ) { $dbw = wfGetDB( DB_MASTER ); $deleter = new RevisionDeleter( $dbw ); - $ok = $deleter->setVisibility( $this->revisions, $bitfield, $reason ); + $deleter->setVisibility( $this->revisions, $bitfield, $reason ); } } diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php index 8c2f8aad4d..d28f059c8e 100644 --- a/includes/SpecialSearch.php +++ b/includes/SpecialSearch.php @@ -70,7 +70,7 @@ class SpecialSearch { } /** - * If an exact title match can be found, jump straight ahead to + * If an exact title match can be found, jump straight ahead to it. * @param string $term * @public */ @@ -82,7 +82,6 @@ class SpecialSearch { $this->setupPage( $term ); # Try to go to page as entered. - # $t = Title::newFromText( $term ); # If the string cannot be used to create a title diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 768c14fd7a..937d9fc1db 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -106,7 +106,7 @@ class UploadForm { * @access private */ function initializeFromUrl( $request ) { - global $wgTmpDirectory, $wgMaxUploadSize; + global $wgTmpDirectory; $url = $request->getText( 'wpUploadFileURL' ); $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' ); @@ -126,7 +126,7 @@ class UploadForm { * Returns true if there was an error, false otherwise */ private function curlCopy( $url, $dest ) { - global $wgMaxUploadSize, $wgUser, $wgOut; + global $wgUser, $wgOut; if( !$wgUser->isAllowed( 'upload_by_url' ) ) { $wgOut->permissionRequired( 'upload_by_url' ); @@ -704,8 +704,6 @@ class UploadForm { $wgOut->addHTML( '
' ); $wgOut->addWikiText( wfMsg( 'uploadtext' ) ); $wgOut->addHTML( '
' ); - $sk = $wgUser->getSkin(); - $sourcefilename = wfMsgHtml( 'sourcefilename' ); $destfilename = wfMsgHtml( 'destfilename' ); @@ -732,7 +730,6 @@ class UploadForm { // Prepare form for upload or upload/copy if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) { - $source_comment = wfMsgHtml( 'upload_source_url' ); $filename_form = "" . "&1",$output,$code); - $exit_code= $code; #remeber for user feedback + $exit_code= $code; #remember for user feedback if ($virus_scanner_codes) { #map exit code to AV_xxx constants. - if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping - else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping + if (isset($virus_scanner_codes[$code])) { + $code= $virus_scanner_codes[$code]; # explicit mapping + } else if (isset($virus_scanner_codes["*"])) { + $code= $virus_scanner_codes["*"]; # fallback mapping + } } if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes) wfDebug("$fname: failed to scan $file (code $exit_code).\n"); - if ($wgAntivirusRequired) return "scan failed (code $exit_code)"; - else return NULL; + if ($wgAntivirusRequired) { return "scan failed (code $exit_code)"; } + else { return NULL; } } else if ($code===AV_SCAN_ABORTED) { #scan failed because filetype is unknown (probably imune) wfDebug("$fname: unsupported file type $file (code $exit_code).\n"); @@ -1141,7 +1142,7 @@ class UploadForm { $output= join("\n",$output); $output= trim($output); - if (!$output) $output= true; #if ther's no output, return true + if (!$output) $output= true; #if there's no output, return true else if ($msg_pattern) { $groups= array(); if (preg_match($msg_pattern,$output,$groups)) { diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 719ab370b1..23d5c2825f 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -177,7 +177,6 @@ class LoginForm { } else { # Confirm that the account was created global $wgOut; - $skin = $wgUser->getSkin(); $self = SpecialPage::getTitleFor( 'Userlogin' ); $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); $wgOut->setArticleRelated( false ); diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index 4edbf12805..0afcb486b6 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -89,7 +89,6 @@ class UserrightsForm extends HTMLForm { $oldGroups = $u->getGroups(); $newGroups = $oldGroups; - $logcomment = ' '; // remove then add groups if(isset($removegroup)) { $newGroups = array_diff($newGroups, $removegroup); diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index bc170b3634..760bb8db7e 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -150,21 +150,17 @@ function wfSpecialWatchlist( $par ) { wfAppendToArrayIfNotDefault( 'namespace', $nameSpace, $defaults, $nondefaults ); if ( $days <= 0 ) { - $docutoff = ''; $cutoff = false; $npages = wfMsg( 'watchlistall1' ); } else { - $docutoff = "AND rev_timestamp > '" . - ( $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ) ) - . "'"; - /* - $sql = "SELECT COUNT(*) AS n FROM $page, $revision WHERE rev_timestamp>'$cutoff' AND page_id=rev_page"; - $res = $dbr->query( $sql, $fname ); - $s = $dbr->fetchObject( $res ); - $npages = $s->n; - */ - $npages = 40000 * $days; - + $cutoff = $dbr->timestamp( time() - intval( $days * 86400 ) ); + /* + $sql = "SELECT COUNT(*) AS n FROM $page, $revision WHERE rev_timestamp>'$cutoff' AND page_id=rev_page"; + $res = $dbr->query( $sql, $fname ); + $s = $dbr->fetchObject( $res ); + $npages = $s->n; + */ + $npages = 40000 * $days; } /* Edit watchlist form */ @@ -215,7 +211,6 @@ function wfSpecialWatchlist( $par ) { } else { global $wgContLang; $toolLinks = array(); - $titleText = $titleObj->getPrefixedText(); $pageLink = $sk->makeLinkObj( $titleObj ); $toolLinks[] = $sk->makeLinkObj( $titleObj->getTalkPage(), $wgLang->getNsText( NS_TALK ) ); if( $titleObj->exists() ) @@ -327,7 +322,6 @@ function wfSpecialWatchlist( $par ) { # Spit out some control panel links $thisTitle = SpecialPage::getTitleFor( 'Watchlist' ); $skin = $wgUser->getSkin(); - $linkElements = array( 'hideOwn' => 'wlhideshowown', 'hideBots' => 'wlhideshowbots' ); # Problems encountered using the fancier method $label = $hideBots ? wfMsgHtml( 'show' ) : wfMsgHtml( 'hide' ); @@ -428,7 +422,6 @@ function wlDaysLink( $d, $page, $options = array() ) { function wlCutoffLinks( $days, $page = 'Watchlist', $options = array() ) { $hours = array( 1, 2, 6, 12 ); $days = array( 1, 3, 7 ); - $cl = ''; $i = 0; foreach( $hours as $h ) { $hours[$i++] = wlHoursLink( $h, $page, $options ); diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index a95530fefb..438f52e465 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -57,8 +57,6 @@ class WhatLinksHerePage { $wgOut->setPagetitle( $this->target->getPrefixedText() ); $wgOut->setSubtitle( wfMsg( 'linklistsub' ) ); - $isredir = ' (' . wfMsg( 'isredirect' ) . ")\n"; - $wgOut->addHTML( wfMsg( 'whatlinkshere-barrow' ) . ' ' .$this->skin->makeLinkObj($this->target, '', 'redirect=no' )."
\n"); $this->showIndirectLinks( 0, $this->target, $this->limit, $this->from, $this->dir ); diff --git a/includes/User.php b/includes/User.php index 7a3a8856fd..8d402efd2a 100644 --- a/includes/User.php +++ b/includes/User.php @@ -344,7 +344,7 @@ class User { * @return bool */ static function isIP( $name ) { - return preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/",$name); + return preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',$name); /*return preg_match("/^ (?:[01]?\d{1,2}|2(:?[0-4]\d|5[0-5]))\. (?:[01]?\d{1,2}|2(:?[0-4]\d|5[0-5]))\. @@ -873,6 +873,7 @@ class User { $found = false; $host = ''; + $m = array(); if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $m ) ) { # Make hostname for ( $i=4; $i>=1; $i-- ) { @@ -939,6 +940,7 @@ class User { if( isset( $limits['ip'] ) ) { $keys["mediawiki:limiter:$action:ip:$ip"] = $limits['ip']; } + $matches = array(); if( isset( $limits['subnet'] ) && preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) { $subnet = $matches[1]; $keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet']; @@ -1585,7 +1587,7 @@ class User { * @todo FIXME : need to check the old failback system [AV] */ function &getSkin() { - global $IP, $wgRequest; + global $wgRequest; if ( ! isset( $this->mSkin ) ) { wfProfileIn( __METHOD__ ); @@ -1672,7 +1674,7 @@ class User { // any matching rows if ( $watched ) { $dbw =& wfGetDB( DB_MASTER ); - $success = $dbw->update( 'watchlist', + $dbw->update( 'watchlist', array( /* SET */ 'wl_notificationtimestamp' => NULL ), array( /* WHERE */ @@ -1703,7 +1705,7 @@ class User { if( $currentUser != 0 ) { $dbw =& wfGetDB( DB_MASTER ); - $success = $dbw->update( 'watchlist', + $dbw->update( 'watchlist', array( /* SET */ 'wl_notificationtimestamp' => NULL ), array( /* WHERE */ @@ -1740,6 +1742,7 @@ class User { $this->mOptions = array(); $a = explode( "\n", $str ); foreach ( $a as $s ) { + $m = array(); if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) { $this->mOptions[$m[1]] = $m[2]; } @@ -1819,7 +1822,6 @@ class User { * Checks if a user with the given name exists, returns the ID */ function idForName() { - $gotid = 0; $s = trim( $this->getName() ); if ( 0 == strcmp( '', $s ) ) return 0; diff --git a/includes/Xml.php b/includes/Xml.php index 6e66fc416f..202f99023b 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -270,8 +270,8 @@ class Xml { xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); if( !xml_parse( $parser, $text, true ) ) { - $err = xml_error_string( xml_get_error_code( $parser ) ); - $position = xml_get_current_byte_index( $parser ); + //$err = xml_error_string( xml_get_error_code( $parser ) ); + //$position = xml_get_current_byte_index( $parser ); //$fragment = $this->extractFragment( $html, $position ); //$this->mXmlError = "$err at byte $position:\n$fragment"; xml_parser_free( $parser ); diff --git a/includes/ZhClient.php b/includes/ZhClient.php index 0451ce8143..9c9461d539 100644 --- a/includes/ZhClient.php +++ b/includes/ZhClient.php @@ -38,6 +38,7 @@ class ZhClient { */ function connect() { wfSuppressWarnings(); + $errno = $errstr = ''; $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30); wfRestoreWarnings(); if(!$this->mFP) { @@ -115,7 +116,6 @@ class ZhClient { foreach($info as $variant) { list($code, $len) = explode(' ', $variant); $ret[strtolower($code)] = substr($data, $i, $len); - $r = $ret[strtolower($code)]; $i+=$len; } return $ret; diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index e12a256cda..c2dd93b09c 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -154,7 +154,6 @@ abstract class ApiBase { $replacement = '\\0' . "\n " . 'http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/api/\\2'; if (is_array($versions)) { - $ver2 = array(); foreach ($versions as &$v) $v = eregi_replace($pattern, $replacement, $v); $versions = implode("\n ", $versions); diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index a2c75b9f84..b2a8bd8786 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -65,7 +65,7 @@ class ApiFeedWatchlist extends ApiBase { $data = $module->getResultData(); $feedItems = array (); - foreach ($data['query']['watchlist'] as $index => $info) { + foreach ($data['query']['watchlist'] as $info) { $feedItems[] = $this->createFeedItem($info); } @@ -79,8 +79,6 @@ class ApiFeedWatchlist extends ApiBase { } private function createFeedItem($info) { - global $wgUser; - $titleStr = $info['title']; $title = Title :: newFromText($titleStr); $titleUrl = $title->getFullUrl(); diff --git a/includes/api/ApiFormatYaml_spyc.php b/includes/api/ApiFormatYaml_spyc.php index 05a39e2361..1ec8af4887 100644 --- a/includes/api/ApiFormatYaml_spyc.php +++ b/includes/api/ApiFormatYaml_spyc.php @@ -463,6 +463,7 @@ * @param string $line A line from the YAML file */ function _getIndent($line) { + $match = array(); preg_match('/^\s{1,}/',$line,$match); if (!empty($match[0])) { $indent = substr_count($match[0],' '); @@ -500,6 +501,7 @@ } elseif (preg_match('/^(.+):/',$line,$key)) { // It's a key/value pair most likely // If the key is in double quotes pull it out + $matches = array(); if (preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) { $value = trim(str_replace($matches[1],'',$line)); $key = $matches[2]; @@ -529,6 +531,7 @@ * @return mixed */ function _toType($value) { + $matches = array(); if (preg_match('/^("(.*)"|\'(.*)\')/',$value,$matches)) { $value = (string)preg_replace('/(\'\'|\\\\\')/',"'",end($matches)); $value = preg_replace('/\\\\"/','"',$value); @@ -596,6 +599,7 @@ // Check for strings $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; + $strings = array(); if (preg_match_all($regex,$inline,$strings)) { $saved_strings[] = $strings[0][0]; $inline = preg_replace($regex,'YAMLString',$inline); @@ -603,12 +607,14 @@ unset($regex); // Check for sequences + $seqs = array(); if (preg_match_all('/\[(.+)\]/U',$inline,$seqs)) { $inline = preg_replace('/\[(.+)\]/U','YAMLSeq',$inline); $seqs = $seqs[0]; } // Check for mappings + $maps = array(); if (preg_match_all('/{(.+)}/U',$inline,$maps)) { $inline = preg_replace('/{(.+)}/U','YAMLMap',$inline); $maps = $maps[0]; @@ -704,6 +710,7 @@ function _linkRef(&$n,$key,$k = NULL,$v = NULL) { if (empty($k) && empty($v)) { // Look for &refs + $matches = array(); if (preg_match('/^&([^ ]+)/',$n->data[$key],$matches)) { // Flag the node so we know it's a reference $this->_allNodes[$n->id]->ref = substr($matches[0],1); @@ -837,7 +844,7 @@ $ret = array(); foreach($keys as $key) { - list($unused,$val) = each($vals); + list( /* unused */ ,$val) = each($vals); // This is the good part! If a key already exists, but it's part of a // sequence (an int), just keep addin numbers until we find a fresh one. if (isset($ret[$key]) and is_int($key)) { diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index e93fc6111a..697399c366 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 ($this->mModules as $moduleName => $moduleClass) { + foreach( array_keys($this->mModules) as $moduleName ) { $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 ($this->mFormats as $formatName => $moduleClass) { + foreach( array_keys($this->mFormats) as $formatName ) { $msg .= "* format=$formatName *"; $module = $this->createPrinterByName($formatName); $msg2 = $module->makeHelpMsg(); diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 19b30b1a53..3bbcf4e24d 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -68,7 +68,7 @@ class ApiOpenSearch extends ApiBase { // Reformat useful data for future printing by JSON engine $srchres = array (); - foreach ($data['query']['allpages'] as $pageid => & $pageinfo) { + foreach ($data['query']['allpages'] as & $pageinfo) { // Note: this data will no be printable by the xml engine // because it does not support lists of unnamed items $srchres[] = $pageinfo['title']; diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index b5424bbcf9..3b8e15a0ee 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 ($dbkeys as $dbkey => $nothing) { + foreach ( array_keys($dbkeys) as $dbkey ) { $title = Title :: makeTitle($ns, $dbkey); $this->mMissingTitles[] = $title; $this->mAllPages[$ns][$dbkey] = 0; diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 46abcda12d..9b5b0a798e 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -53,7 +53,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { wfProfileOut($this->getModuleProfileName() . '-getDB'); wfProfileIn($this->getModuleProfileName() . '-parseParams'); - $limit = $from = $namespace = $filterredir = null; + $limit = $from = $namespace = $filterredir = $prefix = null; extract($this->extractRequestParams()); $this->addTables('page'); diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 2c171f89b5..c875df3ba3 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -185,7 +185,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->parseContinueParam($continue, $redirect); // Skip all completed links - $db = & $this->getDB(); } else { if ($count !== 1) diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 93b4d08636..0890689d5b 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 ($titles as $pageid => $title) { + foreach ( array_keys($titles) as $pageid) { $pageInfo = array ( 'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]), 'lastrevid' => intval($pageLatest[$pageid]) diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 7c3a90a83f..a25a4e0fcb 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -36,7 +36,7 @@ class ApiQueryRecentChanges extends ApiQueryBase { } public function execute() { - $limit = $prop = $from = $namespace = $show = $dir = $start = $end = null; + $limit = $prop = $namespace = $show = $dir = $start = $end = null; extract($this->extractRequestParams()); $this->addTables('recentchanges'); diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 1d8ae69dc3..65e57377a0 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -99,16 +99,19 @@ class ApiQueryContributions extends ApiQueryBase { //If we got data on the revision only, use only // that data. - if($revvals && !$pagevals) + if($revvals && !$pagevals) { $data[] = $revvals; + } //If we got data on the page only, use only // that data. - else if($pagevals && !$revvals) + else if($pagevals && !$revvals) { $data[] = $pagevals; + } //... and if we got data on both the revision and // the page, merge the data and send it out. - else if($pagevals && $revvals) + else if($pagevals && $revvals) { $data[] = array_merge($revvals, $pagevals); + } } //Free the database record so the connection can get on with other stuff diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 595cb7518d..dbe01c98f6 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -59,7 +59,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $user = (false !== array_search('user', $prop)); $comment = (false !== array_search('comment', $prop)); - $timestamp = (false !== array_search('timestamp', $prop)); + $timestamp = (false !== array_search('timestamp', $prop)); // TODO: $timestamp not currently being used. $patrol = (false !== array_search('patrol', $prop)); if ($patrol) { diff --git a/includes/cbt/CBTCompiler.php b/includes/cbt/CBTCompiler.php index 4ef8ee4a95..59088bed0f 100644 --- a/includes/cbt/CBTCompiler.php +++ b/includes/cbt/CBTCompiler.php @@ -75,7 +75,6 @@ class CBTCompiler { * Returns true on success, error message on failure */ function compile() { - $fname = 'CBTProcessor::compile'; $this->mLastError = false; $this->mOps = array(); @@ -222,7 +221,6 @@ class CBTCompiler { if ( $char == '{' ) { // Switch to text mode ++$p; - $tokenStart = $p; $this->doOpenText( $p, $end ); ++$argCount; } elseif ( $char == '}' ) { @@ -292,7 +290,7 @@ class CBTCompiler { wfProfileIn( $fname ); $stack = array(); - foreach( $this->mOps as $index => $op ) { + foreach( $this->mOps as $op ) { switch( $op->opcode ) { case CBT_PUSH: $stack[] = $this->phpQuote( $op->arg1 ); diff --git a/includes/normal/RandomTest.php b/includes/normal/RandomTest.php index e2601366df..b86ab7c32a 100644 --- a/includes/normal/RandomTest.php +++ b/includes/normal/RandomTest.php @@ -68,6 +68,7 @@ function showDiffs( $a, $b ) { $diffs = new Diff( $ota, $nta ); $formatter = new TableDiffFormatter(); $funky = $formatter->format( $diffs ); + $matches = array(); preg_match_all( '/(.*?)<\/span>/', $funky, $matches ); foreach( $matches[1] as $bit ) { $hex = bin2hex( $bit ); diff --git a/includes/normal/Utf8Test.php b/includes/normal/Utf8Test.php index 7106959832..34ab69c8c3 100644 --- a/includes/normal/Utf8Test.php +++ b/includes/normal/Utf8Test.php @@ -45,6 +45,7 @@ if( !$in ) { $columns = 0; while( false !== ( $line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^(Here come the tests:\s*)\|$/', $line, $matches ) ) { $columns = strpos( $line, '|' ); break; @@ -86,6 +87,7 @@ $failed = 0; $success = 0; $total = 0; while( false !== ( $line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^(\d+)\s+(.*?)\s*\|/', $line, $matches ) ) { $section = $matches[1]; print $line; diff --git a/includes/normal/UtfNormal.php b/includes/normal/UtfNormal.php index ae1f865a7d..d8eac7b8ad 100644 --- a/includes/normal/UtfNormal.php +++ b/includes/normal/UtfNormal.php @@ -224,8 +224,7 @@ class UtfNormal { * @static */ static function loadData() { - # fixme : are $utfCanonicalComp, $utfCanonicalDecomp really used? - global $utfCombiningClass, $utfCanonicalComp, $utfCanonicalDecomp; + global $utfCombiningClass; if( !isset( $utfCombiningClass ) ) { require_once( 'UtfNormalData.inc' ); } @@ -329,6 +328,7 @@ class UtfNormal { # large ASCII parts can be handled much more quickly. # Don't chop up Unicode areas for punctuation, though, # that wastes energy. + $matches = array(); preg_match_all( '/([\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*)/', $string, $matches ); @@ -551,7 +551,7 @@ class UtfNormal { * @return string a UTF-8 string decomposed, not yet normalized (needs sorting) * @static */ - static function fastDecompose( $string, &$map ) { + static function fastDecompose( $string, $map ) { UtfNormal::loadData(); $len = strlen( $string ); $out = ''; diff --git a/includes/normal/UtfNormalGenerate.php b/includes/normal/UtfNormalGenerate.php index 688a80f1da..f0eb5330d9 100644 --- a/includes/normal/UtfNormalGenerate.php +++ b/includes/normal/UtfNormalGenerate.php @@ -43,6 +43,7 @@ if( !$in ) { print "Initializing normalization quick check tables...\n"; $checkNFC = array(); while( false !== ($line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^([0-9A-F]+)(?:..([0-9A-F]+))?\s*;\s*(NFC_QC)\s*;\s*([MN])/', $line, $matches ) ) { list( $junk, $first, $last, $prop, $value ) = $matches; #print "$first $last $prop $value\n"; diff --git a/includes/normal/UtfNormalTest.php b/includes/normal/UtfNormalTest.php index 6d95bf85e3..1181b63315 100644 --- a/includes/normal/UtfNormalTest.php +++ b/includes/normal/UtfNormalTest.php @@ -73,6 +73,7 @@ $testedChars = array(); while( false !== ( $line = fgets( $in ) ) ) { list( $data, $comment ) = explode( '#', $line ); if( $data === '' ) continue; + $matches = array(); if( preg_match( '/@Part([\d])/', $data, $matches ) ) { if( $matches[1] > 0 ) { $ok = reportResults( $total, $success, $failure ) && $ok; @@ -236,7 +237,6 @@ function testInvariant( &$u, $char, $desc, $reportFailure = false ) { $result = verbosify( $char, $u->toNFD( $char ), 1, 'NFD', $reportFailure ) && $result; $result = verbosify( $char, $u->toNFKC( $char ), 1, 'NFKC', $reportFailure ) && $result; $result = verbosify( $char, $u->toNFKD( $char ), 1, 'NFKD', $reportFailure ) && $result; - $c = $char; $result = verbosify( $char, $u->cleanUp( $char ), 1, 'cleanUp', $reportFailure ) && $result; global $verbose; if( $verbose && !$result && !$reportFailure ) { -- 2.20.1