* 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.
}
} 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.
//
* @return Return the text of this revision
*/
function getContent() {
- global $wgRequest, $wgUser, $wgOut;
+ global $wgUser, $wgOut;
wfProfileIn( __METHOD__ );
# 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 );
}
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();
if( !$wasRedirected && $this->isCurrent() ) {
$wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
}
- $targetUrl = $rt->escapeLocalURL();
- #Â fixme unused $titleText :
- $titleText = htmlspecialchars( $rt->getPrefixedText() );
$link = $sk->makeLinkObj( $rt );
$wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT" />' .
*/
function doDeleteArticle( $reason ) {
global $wgUseSquid, $wgDeferredUpdateList;
- global $wgPostCommitUpdateList, $wgUseTrackbacks;
+ global $wgUseTrackbacks;
wfDebug( __METHOD__."\n" );
$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 );
'comment' => $comment,
'minor_edit' => $minor ? 1 : 0,
) );
- # fixme : $revisionId never used
- $revisionId = $revision->insertOn( $dbw );
+ $revision->insertOn( $dbw );
$this->updateRevisionOn( $dbw, $revision );
$dbw->commit();
static function onArticleEdit( $title ) {
global $wgDeferredUpdateList, $wgUseFileCache;
- $urls = array();
-
// Invalidate caches of articles which include this page
$update = new HTMLCacheUpdate( $title, 'templatelinks' );
$wgDeferredUpdateList[] = $update;
* @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 ) );
$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" );
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;
return false;
$i = 0;
$ret = array();
- foreach ($r as $key => $value) {
+ foreach ($r as $value) {
wfdebug("ret[$i]=[$value]\n");
$ret[$i++] = $value;
}
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", '<br />', $this->mErr);
}
$this->mMetaData = '' ;
# Check for spam
+ $matches = array();
if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
$this->spamPage ( $matches[0] );
wfProfileOut( "$fname-checks" );
$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,
}
$currentText = $currentRevision->getText();
+ $result = '';
if( wfMerge( $baseText, $editText, $currentText, $result ) ){
$editText = $result;
wfProfileOut( $fname );
return false;
}
- if ( preg_match( "/^\s*$/", $in ) ) {
+ if ( preg_match( '/^\s*$/', $in ) ) {
$this->debug( $in, __FUNCTION__, 'input consisted solely of whitespace' );
return false;
}
}
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' );
}
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 {
}
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' );
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;
* @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
* @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] );
# 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 ) {
*/
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] );
}
* @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;
* <i>parsemag<i>: ??
*/
function wfMsgExt( $key, $options ) {
- global $wgOut, $wgMsgParserOptions, $wgParser;
+ global $wgOut, $wgParser;
$args = func_get_args();
array_shift( $args );
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'],
}
// 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] );
}
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 ) ) {
$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)) {
# 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]);
$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 );
}
* @return string
*/
function wfBaseName( $path ) {
+ $matches = array();
if( preg_match( '#([^/\\\\]*)[/\\\\]*$#', $path, $matches ) ) {
return $matches[1];
} else {
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";
}
}
$fields = array();
$lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
foreach( $lines as $line ) {
+ $matches = array();
if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
$fields[] = $matches[1];
}
* @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) );
$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;
+ }
}
}
}
// 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;
*/
function doQuery() {
$fname = 'LinkBatch::doQuery';
- $namespaces = array();
if ( $this->isEmpty() ) {
return false;
$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 {
function getInterwikiLinkAttributes( $link, $text, $class='' ) {
global $wgContLang;
- $same = ($link == $text);
$link = urldecode( $link );
$link = $wgContLang->checkTitleEncoding( $link );
$link = preg_replace( '/[\\x00-\\x1f]/', ' ', $link );
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
- $ns = $nt->getNamespace();
- $dbkey = $nt->getDBkey();
if ( $nt->isExternal() ) {
$u = $nt->getFullURL();
$link = $nt->getPrefixedURL();
$inside = '';
if ( '' != $trail ) {
+ $m = array();
if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
$inside = $m[1];
$trail = $m[2];
* the end of the link.
*/
function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- $link = $nt->getPrefixedURL();
-
$u = $nt->escapeLocalURL( $query );
if ( '' == $text ) {
### HOTFIX. Instead of breaking, return empty string.
return $text;
} else {
- $name = $title->getDBKey();
$img = new Image( $title );
if( $img->exists() ) {
$url = $img->getURL();
# 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];
} else {
$text = $match[1];
}
+ $submatch = array();
if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
# Media link; trail not supported.
$linkRegexp = '/\[\[(.*?)\]\]/';
}
$inside = '';
if ( '' != $trail ) {
+ $m = array();
if ( preg_match( $regex, $trail, $m ) ) {
$inside = $m[1];
$trail = $m[2];
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',
# 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;
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'] ) ) ) {
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 );
}
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;
}
}
$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 );
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 ){
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;
*/
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;
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 ;
}
* @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 );
}
}
function getCallTreeLine($entry) {
- list ($fname, $level, $start, $x, $end) = $entry;
+ list ($fname, $level, $start, /* $x */, $end) = $entry;
$delta = $end - $start;
$space = str_repeat(' ', $level);
# First, subtract the overhead!
foreach ($this->mStack as $entry) {
$fname = $entry[0];
- $thislevel = $entry[1];
$start = $entry[2];
$end = $entry[4];
$elapsed = $end - $start;
# Collate
foreach ($this->mStack as $index => $entry) {
$fname = $entry[0];
- $thislevel = $entry[1];
$start = $entry[2];
$end = $entry[4];
$elapsed = $end - $start;
$out .= "<table id='mwProtectSet'>";
$out .= "<tbody>";
$out .= "<tr>\n";
- foreach( $this->mRestrictions as $action => $required ) {
+ foreach( array_keys($this->mRestrictions) as $action ) {
/* Not all languages have V_x <-> N_x relation */
$out .= "<th>" . wfMsgHtml( 'restriction-' . $action ) . "</th>\n";
}
# 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 );
$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 ;
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 ) );
$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
}
# Quoted term? Try without the quotes...
+ $matches = array();
if( preg_match( '/^"([^"]+)"$/', $searchterm, $matches ) ) {
return SearchEngine::getNearMatch( $matches[1] );
}
$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 ) {
$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" );
}
* @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
*/
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 ) );
$n = 0;
$out = '<table style="background: inherit;" border="0" width="100%">';
- $namespaces = $wgContLang->getFormattedNamespaces();
while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title );
if( $t ) {
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;
+ }
}
}
}
$scBlockAddress = htmlspecialchars( $this->BlockAddress );
- $scBlockExpiry = htmlspecialchars( $this->BlockExpiry );
$scBlockReason = htmlspecialchars( $this->BlockReason );
$scBlockOtherTime = htmlspecialchars( $this->BlockOther );
$scBlockExpiryOptions = htmlspecialchars( wfMsgForContent( 'ipboptions' ) );
# 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 ) {
*/
function wfSpecialContributions( $par = null ) {
global $wgUser, $wgOut, $wgLang, $wgRequest;
- $fname = 'wfSpecialContributions';
$target = isset( $par ) ? $par : $wgRequest->getVal( 'target' );
if ( !strlen( $target ) ) {
$dbw = wfGetDB( DB_MASTER );
$nullRevision = Revision::newNullRevision(
$dbw, $title->getArticleId(), $comment, true );
- $nullRevId = $nullRevision->insertOn( $dbw );
+ $nullRevision->insertOn( $dbw );
}
}
}
function importOldRevision() {
- $fname = "WikiImporter::importOldRevision";
$dbw =& wfGetDB( DB_MASTER );
# Sneak a single revision into place
* Constructor
*/
function wfSpecialMovepage( $par = null ) {
- global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
+ global $wgUser, $wgOut, $wgRequest, $action;
# Check rights
if ( !$wgUser->isAllowed( 'move' ) ) {
function doSubmit() {
global $wgOut, $wgUser, $wgRequest;
- $fname = "MovePageForm::doSubmit";
if ( $wgUser->pingLimiter( 'move' ) ) {
$wgOut->rateLimited();
*
*/
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 );
/** 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 = '';
htmlspecialchars( $wpIlMatch ) . "\" /> " .
"<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
}
- $here = $wgContLang->specialPage( 'Newimages' );
/**
* Paging controls...
* Constructor
*/
function wfSpecialRecentchanges( $par, $specialPage ) {
- global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol, $wgDBtype;
+ global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol;
global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
global $wgAllowCategorizedRecentChanges ;
$fname = 'wfSpecialRecentchanges';
if ( is_numeric( $bit ) ) {
$limit = $bit;
}
-
+
+ $m = array();
if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
$limit = $m[1];
}
}
// And now for the content
- $sk = $wgUser->getSkin();
$wgOut->setSyndicated( true );
$list = ChangesList::newFromUser( $wgUser );
$sorted[$n] = $obj;
$n++;
}
- $first = false;
}
foreach( $sorted as $obj ) {
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 ) );
*/
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 ) ) {
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;
}
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 );
}
}
}
/**
- * 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
*/
$this->setupPage( $term );
# Try to go to page as entered.
- #
$t = Title::newFromText( $term );
# If the string cannot be used to create a title
* @access private
*/
function initializeFromUrl( $request ) {
- global $wgTmpDirectory, $wgMaxUploadSize;
+ global $wgTmpDirectory;
$url = $request->getText( 'wpUploadFileURL' );
$local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' );
* 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' );
$wgOut->addHTML( '<div id="uploadtext">' );
$wgOut->addWikiText( wfMsg( 'uploadtext' ) );
$wgOut->addHTML( '</div>' );
- $sk = $wgUser->getSkin();
-
$sourcefilename = wfMsgHtml( 'sourcefilename' );
$destfilename = wfMsgHtml( 'destfilename' );
// Prepare form for upload or upload/copy
if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
- $source_comment = wfMsgHtml( 'upload_source_url' );
$filename_form =
"<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" .
"<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' onfocus='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" .
$chunk = Sanitizer::decodeCharReferences( $chunk );
#look for script-types
- if (preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim",$chunk)) return true;
+ if (preg_match('!type\s*=\s*[\'"]?\s*(\w*/)?(ecma|java)!sim',$chunk)) return true;
#look for html-style script-urls
- if (preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim",$chunk)) return true;
+ if (preg_match('!(href|src|data)\s*=\s*[\'"]?\s*(ecma|java)script:!sim',$chunk)) return true;
#look for css-style script-urls
- if (preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim",$chunk)) return true;
+ if (preg_match('!url\s*\(\s*[\'"]?\s*(ecma|java)script:!sim',$chunk)) return true;
wfDebug("SpecialUpload::detectScript: no scripts found\n");
return false;
#NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
# that does not seem to be worth the pain.
# Ask me (Duesentrieb) about it if it's ever needed.
+ $output = array();
if (wfIsWindows()) exec("$scanner",$output,$code);
else exec("$scanner 2>&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");
$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)) {
} else {
# Confirm that the account was created
global $wgOut;
- $skin = $wgUser->getSkin();
$self = SpecialPage::getTitleFor( 'Userlogin' );
$wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
$wgOut->setArticleRelated( false );
$oldGroups = $u->getGroups();
$newGroups = $oldGroups;
- $logcomment = ' ';
// remove then add groups
if(isset($removegroup)) {
$newGroups = array_diff($newGroups, $removegroup);
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 */
} else {
global $wgContLang;
$toolLinks = array();
- $titleText = $titleObj->getPrefixedText();
$pageLink = $sk->makeLinkObj( $titleObj );
$toolLinks[] = $sk->makeLinkObj( $titleObj->getTalkPage(), $wgLang->getNsText( NS_TALK ) );
if( $titleObj->exists() )
# 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' );
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 );
$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' )."<br />\n");
$this->showIndirectLinks( 0, $this->target, $this->limit, $this->from, $this->dir );
* @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]))\.
$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-- ) {
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'];
* @todo FIXME : need to check the old failback system [AV]
*/
function &getSkin() {
- global $IP, $wgRequest;
+ global $wgRequest;
if ( ! isset( $this->mSkin ) ) {
wfProfileIn( __METHOD__ );
// any matching rows
if ( $watched ) {
$dbw =& wfGetDB( DB_MASTER );
- $success = $dbw->update( 'watchlist',
+ $dbw->update( 'watchlist',
array( /* SET */
'wl_notificationtimestamp' => NULL
), array( /* WHERE */
if( $currentUser != 0 ) {
$dbw =& wfGetDB( DB_MASTER );
- $success = $dbw->update( 'watchlist',
+ $dbw->update( 'watchlist',
array( /* SET */
'wl_notificationtimestamp' => NULL
), array( /* WHERE */
$this->mOptions = array();
$a = explode( "\n", $str );
foreach ( $a as $s ) {
+ $m = array();
if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) {
$this->mOptions[$m[1]] = $m[2];
}
* 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;
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 );
*/
function connect() {
wfSuppressWarnings();
+ $errno = $errstr = '';
$this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
wfRestoreWarnings();
if(!$this->mFP) {
foreach($info as $variant) {
list($code, $len) = explode(' ', $variant);
$ret[strtolower($code)] = substr($data, $i, $len);
- $r = $ret[strtolower($code)];
$i+=$len;
}
return $ret;
$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);
$data = $module->getResultData();
$feedItems = array ();
- foreach ($data['query']['watchlist'] as $index => $info) {
+ foreach ($data['query']['watchlist'] as $info) {
$feedItems[] = $this->createFeedItem($info);
}
}
private function createFeedItem($info) {
- global $wgUser;
-
$titleStr = $info['title'];
$title = Title :: newFromText($titleStr);
$titleUrl = $title->getFullUrl();
* @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],' ');
} 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];
* @return mixed
*/
function _toType($value) {
+ $matches = array();
if (preg_match('/^("(.*)"|\'(.*)\')/',$value,$matches)) {
$value = (string)preg_replace('/(\'\'|\\\\\')/',"'",end($matches));
$value = preg_replace('/\\\\"/','"',$value);
// 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);
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];
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);
$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)) {
$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();
}
$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();
// 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'];
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;
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');
$this->parseContinueParam($continue, $redirect);
// Skip all completed links
- $db = & $this->getDB();
} else {
if ($count !== 1)
$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])
}
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');
//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
$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) {
* Returns true on success, error message on failure
*/
function compile() {
- $fname = 'CBTProcessor::compile';
$this->mLastError = false;
$this->mOps = array();
if ( $char == '{' ) {
// Switch to text mode
++$p;
- $tokenStart = $p;
$this->doOpenText( $p, $end );
++$argCount;
} elseif ( $char == '}' ) {
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 );
$diffs = new Diff( $ota, $nta );
$formatter = new TableDiffFormatter();
$funky = $formatter->format( $diffs );
+ $matches = array();
preg_match_all( '/<span class="diffchange">(.*?)<\/span>/', $funky, $matches );
foreach( $matches[1] as $bit ) {
$hex = bin2hex( $bit );
$columns = 0;
while( false !== ( $line = fgets( $in ) ) ) {
+ $matches = array();
if( preg_match( '/^(Here come the tests:\s*)\|$/', $line, $matches ) ) {
$columns = strpos( $line, '|' );
break;
$success = 0;
$total = 0;
while( false !== ( $line = fgets( $in ) ) ) {
+ $matches = array();
if( preg_match( '/^(\d+)\s+(.*?)\s*\|/', $line, $matches ) ) {
$section = $matches[1];
print $line;
* @static
*/
static function loadData() {
- # fixme : are $utfCanonicalComp, $utfCanonicalDecomp really used?
- global $utfCombiningClass, $utfCanonicalComp, $utfCanonicalDecomp;
+ global $utfCombiningClass;
if( !isset( $utfCombiningClass ) ) {
require_once( 'UtfNormalData.inc' );
}
# 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 );
* @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 = '';
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";
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;
$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 ) {