From be90ce07b38e5891cee4afe447d5a5f924bb46fe Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 3 Feb 2013 19:30:03 +0100 Subject: [PATCH] fix some spacing Change-Id: I93f0a87ba7129bc336083e7289247d3150feb606 --- includes/cache/CacheDependency.php | 2 +- includes/cache/HTMLFileCache.php | 4 +- includes/cache/MessageCache.php | 2 +- includes/content/AbstractContent.php | 2 +- includes/content/ContentHandler.php | 2 +- includes/content/WikitextContent.php | 2 +- includes/logging/LogEventsList.php | 40 ++++----- includes/logging/LogFormatter.php | 12 +-- includes/logging/LogPage.php | 2 +- includes/logging/LogPager.php | 20 ++--- includes/profiler/Profiler.php | 24 +++--- includes/profiler/ProfilerSimple.php | 26 +++--- includes/profiler/ProfilerSimpleText.php | 4 +- includes/profiler/ProfilerSimpleTrace.php | 12 +-- includes/profiler/ProfilerSimpleUDP.php | 2 +- .../ResourceLoaderFileModule.php | 8 +- .../ResourceLoaderWikiModule.php | 2 +- includes/revisiondelete/RevisionDelete.php | 4 +- includes/search/SearchEngine.php | 20 ++--- includes/search/SearchIBM_DB2.php | 78 +++++++++--------- includes/search/SearchMySQL.php | 4 +- includes/search/SearchOracle.php | 82 +++++++++---------- includes/search/SearchPostgres.php | 26 +++--- includes/search/SearchSqlite.php | 8 +- includes/search/SearchUpdate.php | 6 +- 25 files changed, 197 insertions(+), 197 deletions(-) diff --git a/includes/cache/CacheDependency.php b/includes/cache/CacheDependency.php index 5cdc867b63..c67b655efa 100644 --- a/includes/cache/CacheDependency.php +++ b/includes/cache/CacheDependency.php @@ -404,7 +404,7 @@ class GlobalDependency extends CacheDependency { * @return bool */ function isExpired() { - if( !isset($GLOBALS[$this->name]) ) { + if( !isset( $GLOBALS[$this->name] ) ) { return true; } return $GLOBALS[$this->name] != $this->value; diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php index fca071a120..64766466ad 100644 --- a/includes/cache/HTMLFileCache.php +++ b/includes/cache/HTMLFileCache.php @@ -168,10 +168,10 @@ class HTMLFileCache extends FileCacheBase { $now = wfTimestampNow(); if ( $this->useGzip() ) { $text = str_replace( - '', '\n", $text ); + '', '\n", $text ); } else { $text = str_replace( - '', '\n", $text ); + '', '\n", $text ); } // Store text to FS... diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index e2cf1b42e9..bd4ce227ba 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -545,7 +545,7 @@ class MessageCache { $serialized = serialize( $cache ); $hash = md5( $serialized ); $this->mMemc->set( wfMemcKey( 'messages', $code, 'hash' ), $hash, $this->mExpiry ); - if ($wgLocalMessageCacheSerialized) { + if ( $wgLocalMessageCacheSerialized ) { $this->saveToLocal( $serialized, $hash, $code ); } else { $this->saveToScript( $cache, $hash, $code ); diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php index 926dea746d..7341602e70 100644 --- a/includes/content/AbstractContent.php +++ b/includes/content/AbstractContent.php @@ -75,7 +75,7 @@ abstract class AbstractContent implements Content { if ( $modelId !== $this->model_id ) { throw new MWException( "Bad content model: " . - "expected {$this->model_id} " . + "expected {$this->model_id} " . "but got $modelId." ); } diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index b49371545b..5e0447f101 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -1074,7 +1074,7 @@ abstract class ContentHandler { wfRestoreWarnings(); - wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " . implode(', ', $handlerInfo), 2 ); + wfWarn( "Using obsolete hook $event via ContentHandler::runLegacyHooks()! Handlers: " . implode( ', ', $handlerInfo ), 2 ); } // convert Content objects to text diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 8d778f53d1..89aac20a4b 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -241,7 +241,7 @@ class WikitextContent extends TextContent { case 'any': return true; case 'comma': - return strpos( $text, ',' ) !== false; + return strpos( $text, ',' ) !== false; case 'link': if ( $hasLinks === null ) { # not known, find out if ( !$title ) { diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index 03d527667e..d34bf6e244 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -74,7 +74,7 @@ class LogEventsList extends ContextSource { public function showHeader( $type ) { wfDeprecated( __METHOD__, '1.19' ); // If only one log type is used, then show a special message... - $headerType = (count($type) == 1) ? $type[0] : ''; + $headerType = (count( $type ) == 1) ? $type[0] : ''; $out = $this->getOutput(); if( LogPage::isLogType( $headerType ) ) { $page = new LogPage( $headerType ); @@ -97,8 +97,8 @@ class LogEventsList extends ContextSource { * @param $filter: array * @param $tagFilter: array? */ - public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='', - $month = '', $filter = null, $tagFilter='' ) { + public function showOptions( $types=array(), $user = '', $page = '', $pattern = '', $year = '', + $month = '', $filter = null, $tagFilter = '' ) { global $wgScript, $wgMiserMode; $title = SpecialPage::getTitleFor( 'Log' ); @@ -117,7 +117,7 @@ class LogEventsList extends ContextSource { $html .= $this->getExtraInputs( $types ) . "\n"; // Title pattern, if allowed - if (!$wgMiserMode) { + if ( !$wgMiserMode ) { $html .= $this->getTitlePattern( $pattern ) . "\n"; } @@ -125,12 +125,12 @@ class LogEventsList extends ContextSource { $html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) ); // Tag filter - if ($tagSelector) { + if ( $tagSelector ) { $html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) ); } // Filter links - if ($filter) { + if ( $filter ) { $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) ); } @@ -162,7 +162,7 @@ class LogEventsList extends ContextSource { $query = $this->getDefaultQuery(); $queryKey = "hide_{$type}_log"; - $hideVal = 1 - intval($val); + $hideVal = 1 - intval( $val ); $query[$queryKey] = $hideVal; $link = Linker::linkKnown( @@ -176,7 +176,7 @@ class LogEventsList extends ContextSource { $hiddens .= Html::hidden( "hide_{$type}_log", $val ) . "\n"; } // Build links - return ''.$this->getLanguage()->pipeList( $links ) . '' . $hiddens; + return '' . $this->getLanguage()->pipeList( $links ) . '' . $hiddens; } private function getDefaultQuery() { @@ -198,7 +198,7 @@ class LogEventsList extends ContextSource { * @return String: Formatted HTML */ private function getTypeMenu( $queryTypes ) { - $queryType = count($queryTypes) == 1 ? $queryTypes[0] : ''; + $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] : ''; $selector = $this->getTypeSelector(); $selector->setDefault( $queryType ); return $selector->getHtml(); @@ -212,7 +212,7 @@ class LogEventsList extends ContextSource { public function getTypeSelector() { $typesByName = array(); // Temporary array // First pass to load the log names - foreach( LogPage::validTypes() as $type ) { + foreach( LogPage::validTypes() as $type ) { $page = new LogPage( $type ); $restriction = $page->getRestriction(); if ( $this->getUser()->isAllowed( $restriction ) ) { @@ -221,7 +221,7 @@ class LogEventsList extends ContextSource { } // Second pass to sort by name - asort($typesByName); + asort( $typesByName ); // Always put "All public logs" on top $public = $typesByName['']; @@ -273,10 +273,10 @@ class LogEventsList extends ContextSource { private function getExtraInputs( $types ) { $offender = $this->getRequest()->getVal( 'offender' ); $user = User::newFromName( $offender, false ); - if( !$user || ($user->getId() == 0 && !IP::isIPAddress($offender) ) ) { + if( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) { $offender = ''; // Blank field if invalid } - if( count($types) == 1 && $types[0] == 'suppress' ) { + if( count( $types ) == 1 && $types[0] == 'suppress' ) { return Xml::inputLabel( $this->msg( 'revdelete-offender' )->text(), 'offender', 'mw-log-offender', 20, $offender ); } @@ -383,8 +383,8 @@ class LogEventsList extends ContextSource { * @param $right string * @return Boolean */ - public static function typeAction( $row, $type, $action, $right='' ) { - $match = is_array($type) ? + public static function typeAction( $row, $type, $action, $right = '' ) { + $match = is_array( $type ) ? in_array( $row->log_type, $type ) : $row->log_type == $type; if( $match ) { $match = is_array( $action ) ? @@ -468,13 +468,13 @@ class LogEventsList extends ContextSource { * @return Integer Number of total log items (not limited by $lim) */ public static function showLogExtract( - &$out, $types=array(), $page='', $user='', $param = array() + &$out, $types=array(), $page = '', $user = '', $param = array() ) { $defaultParameters = array( 'lim' => 25, 'conds' => array(), 'showIfEmpty' => true, - 'msgKey' => array(''), + 'msgKey' => array( '' ), 'wrap' => "$1", 'flags' => 0 ); @@ -520,8 +520,8 @@ class LogEventsList extends ContextSource { } } $s .= $loglist->beginLogEventsList() . - $logBody . - $loglist->endLogEventsList(); + $logBody . + $loglist->endLogEventsList(); } else { if ( $showIfEmpty ) { $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ), @@ -602,4 +602,4 @@ class LogEventsList extends ContextSource { } return false; } - } +} diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index ce5b053ac3..5ff0434433 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -198,12 +198,12 @@ class LogFormatter { case 'move': switch( $entry->getSubtype() ) { case 'move': - $movesource = $parameters['4::target']; + $movesource = $parameters['4::target']; $text = wfMessage( '1movedto2' ) ->rawParams( $target, $movesource )->inContentLanguage()->escaped(); break; case 'move_redir': - $movesource = $parameters['4::target']; + $movesource = $parameters['4::target']; $text = wfMessage( '1movedto2_redir' ) ->rawParams( $target, $movesource )->inContentLanguage()->escaped(); break; @@ -588,7 +588,7 @@ class LogFormatter { return $this->msg( $message )->text(); } - $content = $this->msg( $message )->escaped(); + $content = $this->msg( $message )->escaped(); $attribs = array( 'class' => 'history-deleted' ); return Html::rawElement( 'span', $attribs, $content ); } @@ -713,7 +713,7 @@ class LegacyLogFormatter extends LogFormatter { $performer = $this->getPerformerElement(); if ( !$this->irctext ) { - $action = $performer . $this->msg( 'word-separator' )->text() . $action; + $action = $performer . $this->msg( 'word-separator' )->text() . $action; } return $action; @@ -913,7 +913,7 @@ class DeleteLogFormatter extends LogFormatter { foreach ( $extra as $v ) { $changes[] = $this->msg( $v )->plain(); } - $changeText = $this->context->getLanguage()->listToText( $changes ); + $changeText = $this->context->getLanguage()->listToText( $changes ); $newParams = array_slice( $params, 0, 3 ); @@ -957,7 +957,7 @@ class DeleteLogFormatter extends LogFormatter { $this->msg( $message )->escaped(), array(), array( 'target' => $this->entry->getTarget()->getPrefixedDBkey() ) - ); + ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); case 'revision': // If an edit was hidden from a page give a review link to the history diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 5854e99b77..9778f273a5 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -271,7 +271,7 @@ class LogPage { $params[2] = isset( $params[2] ) ? self::formatBlockFlags( $params[2], $langObj ) : ''; // Page protections - } elseif ( $type == 'protect' && count($params) == 3 ) { + } elseif ( $type == 'protect' && count( $params ) == 3 ) { // Restrictions and expiries if( $skin ) { $details .= $wgLang->getDirMark() . htmlspecialchars( " {$params[1]}" ); diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index af62ce3b2d..fad1058916 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -71,7 +71,7 @@ class LogPager extends ReverseChronologicalPager { public function getFilterParams() { global $wgFilterLogTypes; $filters = array(); - if( count($this->types) ) { + if( count( $this->types ) ) { return $filters; } foreach( $wgFilterLogTypes as $type => $default ) { @@ -122,10 +122,10 @@ class LogPager extends ReverseChronologicalPager { if( $hideLogs !== false ) { $this->mConds[] = $hideLogs; } - if( count($types) ) { + if( count( $types ) ) { $this->mConds['log_type'] = $types; // Set typeCGI; used in url param for paging - if( count($types) == 1 ) $this->typeCGI = $types[0]; + if( count( $types ) == 1 ) $this->typeCGI = $types[0]; } } @@ -140,7 +140,7 @@ class LogPager extends ReverseChronologicalPager { return false; } $usertitle = Title::makeTitleSafe( NS_USER, $name ); - if( is_null($usertitle) ) { + if( is_null( $usertitle ) ) { return false; } /* Fetch userid at first, if known, provides awesome query plan afterwards */ @@ -154,9 +154,9 @@ class LogPager extends ReverseChronologicalPager { // Paranoia: avoid brute force searches (bug 17342) $user = $this->getUser(); if( !$user->isAllowed( 'deletedhistory' ) ) { - $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0'; + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0'; } elseif( !$user->isAllowed( 'suppressrevision' ) ) { - $this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) . + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) . ' != ' . LogPage::SUPPRESSED_USER; } $this->performer = $usertitle->getText(); @@ -209,9 +209,9 @@ class LogPager extends ReverseChronologicalPager { // Paranoia: avoid brute force searches (bug 17342) $user = $this->getUser(); if( !$user->isAllowed( 'deletedhistory' ) ) { - $this->mConds[] = $db->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0'; + $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION) . ' = 0'; } elseif( !$user->isAllowed( 'suppressrevision' ) ) { - $this->mConds[] = $db->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) . + $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION) . ' != ' . LogPage::SUPPRESSED_ACTION; } } @@ -251,10 +251,10 @@ class LogPager extends ReverseChronologicalPager { # avoids site-breaking filesorts. } elseif( $this->title || $this->pattern || $this->performer ) { $index['logging'] = array( 'page_time', 'user_time' ); - if( count($this->types) == 1 ) { + if( count( $this->types ) == 1 ) { $index['logging'][] = 'log_user_type_time'; } - } elseif( count($this->types) == 1 ) { + } elseif( count( $this->types ) == 1 ) { $index['logging'] = 'type_time'; } else { $index['logging'] = 'times'; diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index b30b03138d..1ead836b26 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -178,10 +178,10 @@ class Profiler { $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); } - $bit = array_pop($this->mWorkStack); + $bit = array_pop( $this->mWorkStack ); - if (!$bit) { - $this->debug("Profiling error, !\$bit: $functionname\n"); + if ( !$bit ) { + $this->debug( "Profiling error, !\$bit: $functionname\n" ); } else { //if( $wgDebugProfiling ) { if( $functionname == 'close' ) { @@ -293,9 +293,9 @@ class Profiler { * @return string */ function getCallTreeLine( $entry ) { - list( $fname, $level, $start, /* $x */, $end) = $entry; + list( $fname, $level, $start, /* $x */, $end ) = $entry; $delta = $end - $start; - $space = str_repeat(' ', $level); + $space = str_repeat( ' ', $level ); # The ugly double sprintf is to work around a PHP bug, # which has been fixed in recent releases. return sprintf( "%10s %s %s\n", trim( sprintf( "%7.3f", $delta * 1000.0 ) ), $space, $fname ); @@ -386,7 +386,7 @@ class Profiler { $this->mMemory = array(); # Estimate profiling overhead - $profileCount = count($this->mStack); + $profileCount = count( $this->mStack ); self::calculateOverhead( $profileCount ); # First, subtract the overhead! @@ -441,8 +441,8 @@ class Profiler { $this->mCollated[$fname] += $elapsed; $this->mCalls[$fname]++; $this->mMemory[$fname] += $memory; - $this->mMin[$fname] = min($this->mMin[$fname], $elapsed); - $this->mMax[$fname] = max($this->mMax[$fname], $elapsed); + $this->mMin[$fname] = min( $this->mMin[$fname], $elapsed ); + $this->mMax[$fname] = max( $this->mMax[$fname], $elapsed ); $this->mOverhead[$fname] += $subcalls; } @@ -499,10 +499,10 @@ class Profiler { * @return Integer * @private */ - function calltreeCount($stack, $start) { + function calltreeCount( $stack, $start ) { $level = $stack[$start][1]; $count = 0; - for ($i = $start -1; $i >= 0 && $stack[$i][1] > $level; $i --) { + for ( $i = $start -1; $i >= 0 && $stack[$i][1] > $level; $i-- ) { $count ++; } return $count; @@ -557,9 +557,9 @@ class Profiler { $rc = $dbw->affectedRows(); if ( $rc == 0 ) { - $dbw->insert('profiling', array ('pf_name' => $name, 'pf_count' => $eventCount, + $dbw->insert( 'profiling', array ( 'pf_name' => $name, 'pf_count' => $eventCount, 'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost ), - __METHOD__, array ('IGNORE')); + __METHOD__, array ( 'IGNORE' ) ); } // When we upgrade to mysql 4.1, the insert+update // can be merged into just a insert with this construct added: diff --git a/includes/profiler/ProfilerSimple.php b/includes/profiler/ProfilerSimple.php index d1d1c5d901..1322e47a52 100644 --- a/includes/profiler/ProfilerSimple.php +++ b/includes/profiler/ProfilerSimple.php @@ -29,7 +29,7 @@ class ProfilerSimple extends Profiler { var $mMinimumTime = 0; - var $zeroEntry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); + var $zeroEntry = array( 'cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0 ); var $errorEntry; public function isPersistent() { @@ -57,33 +57,33 @@ class ProfilerSimple extends Profiler { $this->mMinimumTime = $min; } - function profileIn($functionname) { + function profileIn( $functionname ) { global $wgDebugFunctionEntry; - if ($wgDebugFunctionEntry) { - $this->debug(str_repeat(' ', count($this->mWorkStack)).'Entering '.$functionname."\n"); + if ( $wgDebugFunctionEntry ) { + $this->debug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering ' . $functionname . "\n" ); } $this->mWorkStack[] = array( $functionname, count( $this->mWorkStack ), $this->getTime(), $this->getTime( 'cpu' ) ); } - function profileOut($functionname) { + function profileOut( $functionname ) { global $wgDebugFunctionEntry; - if ($wgDebugFunctionEntry) { - $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); + if ( $wgDebugFunctionEntry ) { + $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); } - list($ofname, /* $ocount */ ,$ortime,$octime) = array_pop($this->mWorkStack); + list( $ofname, /* $ocount */, $ortime, $octime ) = array_pop( $this->mWorkStack ); - if (!$ofname) { - $this->debug("Profiling error: $functionname\n"); + if ( !$ofname ) { + $this->debug( "Profiling error: $functionname\n" ); } else { - if ($functionname == 'close') { + if ( $functionname == 'close' ) { $message = "Profile section ended by close(): {$ofname}"; $functionname = $ofname; $this->debug( "$message\n" ); $this->mCollated[$message] = $this->errorEntry; } - elseif ($ofname != $functionname) { + elseif ( $ofname != $functionname ) { $message = "Profiling error: in({$ofname}), out($functionname)"; $this->debug( "$message\n" ); $this->mCollated[$message] = $this->errorEntry; @@ -91,7 +91,7 @@ class ProfilerSimple extends Profiler { $entry =& $this->mCollated[$functionname]; $elapsedcpu = $this->getTime( 'cpu' ) - $octime; $elapsedreal = $this->getTime() - $ortime; - if (!is_array($entry)) { + if ( !is_array( $entry ) ) { $entry = $this->zeroEntry; $this->mCollated[$functionname] =& $entry; } diff --git a/includes/profiler/ProfilerSimpleText.php b/includes/profiler/ProfilerSimpleText.php index e62622f603..847e34ff40 100644 --- a/includes/profiler/ProfilerSimpleText.php +++ b/includes/profiler/ProfilerSimpleText.php @@ -48,8 +48,8 @@ class ProfilerSimpleText extends ProfilerSimple { $totalReal = isset( $this->mCollated['-total'] ) ? $this->mCollated['-total']['real'] : 0; // profiling mismatch error? - uasort( $this->mCollated, array('self','sort') ); - array_walk( $this->mCollated, array('self','format'), $totalReal ); + uasort( $this->mCollated, array( 'self', 'sort' ) ); + array_walk( $this->mCollated, array( 'self', 'format' ), $totalReal ); if ( php_sapi_name() === 'cli' ) { print "\n"; } elseif ( $this->getContentType() === 'text/html' ) { diff --git a/includes/profiler/ProfilerSimpleTrace.php b/includes/profiler/ProfilerSimpleTrace.php index 017e135248..f766a39be1 100644 --- a/includes/profiler/ProfilerSimpleTrace.php +++ b/includes/profiler/ProfilerSimpleTrace.php @@ -32,18 +32,18 @@ class ProfilerSimpleTrace extends ProfilerSimple { function profileIn( $functionname ) { parent::profileIn( $functionname ); - $this->trace .= " " . sprintf("%6.1f",$this->memoryDiff()) . - str_repeat( " ", count($this->mWorkStack)) . " > " . $functionname . "\n"; + $this->trace .= " " . sprintf( "%6.1f", $this->memoryDiff() ) . + str_repeat( " ", count( $this->mWorkStack ) ) . " > " . $functionname . "\n"; } - function profileOut($functionname) { + function profileOut( $functionname ) { global $wgDebugFunctionEntry; if ( $wgDebugFunctionEntry ) { - $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); + $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); } - list( $ofname, /* $ocount */ , $ortime ) = array_pop( $this->mWorkStack ); + list( $ofname, /* $ocount */, $ortime ) = array_pop( $this->mWorkStack ); if ( !$ofname ) { $this->trace .= "Profiling error: $functionname\n"; @@ -58,7 +58,7 @@ class ProfilerSimpleTrace extends ProfilerSimple { } $elapsedreal = $this->getTime() - $ortime; $this->trace .= sprintf( "%03.6f %6.1f", $elapsedreal, $this->memoryDiff() ) . - str_repeat(" ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; + str_repeat( " ", count( $this->mWorkStack ) + 1 ) . " < " . $functionname . "\n"; } } diff --git a/includes/profiler/ProfilerSimpleUDP.php b/includes/profiler/ProfilerSimpleUDP.php index a95ccb0d2c..abefa81148 100644 --- a/includes/profiler/ProfilerSimpleUDP.php +++ b/includes/profiler/ProfilerSimpleUDP.php @@ -50,7 +50,7 @@ class ProfilerSimpleUDP extends ProfilerSimple { $plength = 0; $packet = ""; foreach ( $this->mCollated as $entry => $pfdata ) { - if( !isset($pfdata['count']) + if( !isset( $pfdata['count'] ) || !isset( $pfdata['cpu'] ) || !isset( $pfdata['cpu_sq'] ) || !isset( $pfdata['real'] ) diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index fad00274cd..99041073d9 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -441,9 +441,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { return $this->modifiedTime[$context->getHash()] = 1; } - wfProfileIn( __METHOD__.'-filemtime' ); + wfProfileIn( __METHOD__ . '-filemtime' ); $filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) ); - wfProfileOut( __METHOD__.'-filemtime' ); + wfProfileOut( __METHOD__ . '-filemtime' ); $this->modifiedTime[$context->getHash()] = max( $filesMtime, $this->getMsgBlobMtime( $context->getLanguage() ) ); @@ -571,7 +571,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { foreach ( array_unique( $scripts ) as $fileName ) { $localPath = $this->getLocalPath( $fileName ); if ( !file_exists( $localPath ) ) { - throw new MWException( __METHOD__.": script file not found: \"$localPath\"" ); + throw new MWException( __METHOD__ . ": script file not found: \"$localPath\"" ); } $contents = file_get_contents( $localPath ); if ( $wgResourceLoaderValidateStaticJS ) { @@ -628,7 +628,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { protected function readStyleFile( $path, $flip ) { $localPath = $this->getLocalPath( $path ); if ( !file_exists( $localPath ) ) { - $msg = __METHOD__.": style file not found: \"$localPath\""; + $msg = __METHOD__ . ": style file not found: \"$localPath\""; wfDebugLog( 'resourceloader', $msg ); throw new MWException( $msg ); } diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index b85da16f32..4ea9f4e49e 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -147,7 +147,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { continue; } $title = Title::newFromText( $titleText ); - if ( !$title || $title->isRedirect() ) { + if ( !$title || $title->isRedirect() ) { continue; } $media = isset( $options['media'] ) ? $options['media'] : 'all'; diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 6ceadff4c5..5340cb9ec0 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -424,7 +424,7 @@ class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem { $dbw->update( 'archive', array( 'ar_deleted' => $bits ), array( 'ar_rev_id' => $this->row->ar_rev_id, - 'ar_deleted' => $this->getBits() + 'ar_deleted' => $this->getBits() ), __METHOD__ ); return (bool)$dbw->affectedRows(); @@ -899,7 +899,7 @@ class RevDel_LogItem extends RevDel_Item { $action = $formatter->getActionText(); // Comment $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $this->row->log_comment ); - if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) { + if( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) { $comment = '' . $comment . ''; } diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index e10b64271c..5e5755c679 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -45,7 +45,7 @@ class SearchEngine { */ protected $db; - function __construct($db = null) { + function __construct( $db = null ) { if ( $db ) { $this->db = $db; } else { @@ -1142,8 +1142,8 @@ class SearchHighlighter { // add more lines $add = $index + 1; while ( $len < $targetchars - 20 - && array_key_exists( $add, $all ) - && !array_key_exists( $add, $snippets ) ) { + && array_key_exists( $add, $all ) + && !array_key_exists( $add, $snippets ) ) { $offsets[$add] = 0; $tt = "\n" . $this->extract( $all[$add], 0, $targetchars - $len, $offsets[$add] ); $extended[$add] = $tt; @@ -1153,7 +1153,7 @@ class SearchHighlighter { } } - // $snippets = array_map('htmlspecialchars', $extended); + // $snippets = array_map( 'htmlspecialchars', $extended ); $snippets = $extended; $last = - 1; $extract = ''; @@ -1332,12 +1332,12 @@ class SearchHighlighter { $fname = __METHOD__; wfProfileIn( $fname ); - // $text = preg_replace("/'{2,5}/", "", $text); - // $text = preg_replace("/\[[a-z]+:\/\/[^ ]+ ([^]]+)\]/", "\\2", $text); - // $text = preg_replace("/\[\[([^]|]+)\]\]/", "\\1", $text); - // $text = preg_replace("/\[\[([^]]+\|)?([^|]]+)\]\]/", "\\2", $text); - // $text = preg_replace("/\\{\\|(.*?)\\|\\}/", "", $text); - // $text = preg_replace("/\\[\\[[A-Za-z_-]+:([^|]+?)\\]\\]/", "", $text); + // $text = preg_replace( "/'{2,5}/", "", $text ); + // $text = preg_replace( "/\[[a-z]+:\/\/[^ ]+ ([^]]+)\]/", "\\2", $text ); + // $text = preg_replace( "/\[\[([^]|]+)\]\]/", "\\1", $text ); + // $text = preg_replace( "/\[\[([^]]+\|)?([^|]]+)\]\]/", "\\2", $text ); + // $text = preg_replace( "/\\{\\|(.*?)\\|\\}/", "", $text ); + // $text = preg_replace( "/\\[\\[[A-Za-z_-]+:([^|]+?)\\]\\]/", "", $text ); $text = preg_replace( "/\\{\\{([^|]+?)\\}\\}/", "", $text ); $text = preg_replace( "/\\{\\{([^|]+\\|)(.*?)\\}\\}/", "\\2", $text ); $text = preg_replace( "/\\[\\[([^|]+?)\\]\\]/", "\\1", $text ); diff --git a/includes/search/SearchIBM_DB2.php b/includes/search/SearchIBM_DB2.php index 368d900feb..ebc9d5a054 100644 --- a/includes/search/SearchIBM_DB2.php +++ b/includes/search/SearchIBM_DB2.php @@ -34,7 +34,7 @@ class SearchIBM_DB2 extends SearchEngine { * Creates an instance of this class * @param $db DatabaseIbm_db2: database object */ - function __construct($db) { + function __construct( $db ) { parent::__construct( $db ); } @@ -45,8 +45,8 @@ class SearchIBM_DB2 extends SearchEngine { * @return SqlSearchResultSet */ function searchText( $term ) { - $resultSet = $this->db->resultObject($this->db->query($this->getQuery($this->filter($term), true))); - return new SqlSearchResultSet($resultSet, $this->searchTerms); + $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) ); + return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } /** @@ -55,9 +55,9 @@ class SearchIBM_DB2 extends SearchEngine { * @param $term String: taw search term * @return SqlSearchResultSet */ - function searchTitle($term) { - $resultSet = $this->db->resultObject($this->db->query($this->getQuery($this->filter($term), false))); - return new SqlSearchResultSet($resultSet, $this->searchTerms); + function searchTitle( $term ) { + $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) ); + return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -66,7 +66,7 @@ class SearchIBM_DB2 extends SearchEngine { * @return String */ function queryRedirect() { - if ($this->showRedirects) { + if ( $this->showRedirects ) { return ''; } else { return 'AND page_is_redirect=0'; @@ -78,10 +78,10 @@ class SearchIBM_DB2 extends SearchEngine { * @return String */ function queryNamespaces() { - if( is_null($this->namespaces) ) + if( is_null( $this->namespaces ) ) return ''; - $namespaces = implode(',', $this->namespaces); - if ($namespaces == '') { + $namespaces = implode( ',', $this->namespaces ); + if ( $namespaces == '' ) { $namespaces = '0'; } return 'AND page_namespace IN (' . $namespaces . ')'; @@ -92,7 +92,7 @@ class SearchIBM_DB2 extends SearchEngine { * @return String */ function queryLimit( $sql ) { - return $this->db->limitResult($sql, $this->limit, $this->offset); + return $this->db->limitResult( $sql, $this->limit, $this->offset ); } /** @@ -100,7 +100,7 @@ class SearchIBM_DB2 extends SearchEngine { * subclasses may define this though * @return String */ - function queryRanking($filteredTerm, $fulltext) { + function queryRanking( $filteredTerm, $fulltext ) { // requires Net Search Extender or equivalent // return ' ORDER BY score(1)'; return ''; @@ -114,10 +114,10 @@ class SearchIBM_DB2 extends SearchEngine { * @return String */ function getQuery( $filteredTerm, $fulltext ) { - return $this->queryLimit($this->queryMain($filteredTerm, $fulltext) . ' ' . + return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' . $this->queryRedirect() . ' ' . $this->queryNamespaces() . ' ' . - $this->queryRanking( $filteredTerm, $fulltext ) . ' '); + $this->queryRanking( $filteredTerm, $fulltext ) . ' ' ); } @@ -126,7 +126,7 @@ class SearchIBM_DB2 extends SearchEngine { * @param $fulltext Boolean * @return String */ - function getIndexField($fulltext) { + function getIndexField( $fulltext ) { return $fulltext ? 'si_text' : 'si_title'; } @@ -138,9 +138,9 @@ class SearchIBM_DB2 extends SearchEngine { * @return String */ function queryMain( $filteredTerm, $fulltext ) { - $match = $this->parseQuery($filteredTerm, $fulltext); - $page = $this->db->tableName('page'); - $searchindex = $this->db->tableName('searchindex'); + $match = $this->parseQuery( $filteredTerm, $fulltext ); + $page = $this->db->tableName( 'page' ); + $searchindex = $this->db->tableName( 'searchindex' ); return 'SELECT page_id, page_namespace, page_title ' . "FROM $page,$searchindex " . 'WHERE page_id=si_page AND ' . $match; @@ -149,7 +149,7 @@ class SearchIBM_DB2 extends SearchEngine { /** @todo document * @return string */ - function parseQuery($filteredText, $fulltext) { + function parseQuery( $filteredText, $fulltext ) { global $wgContLang; $lc = SearchEngine::legalSearchChars(); $this->searchTerms = array(); @@ -158,9 +158,9 @@ class SearchIBM_DB2 extends SearchEngine { $m = array(); $q = array(); - if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER)) { - foreach($m as $terms) { + if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + $filteredText, $m, PREG_SET_ORDER ) ) { + foreach( $m as $terms ) { // Search terms in all variant forms, only // apply on wiki with LanguageConverter @@ -173,19 +173,19 @@ class SearchIBM_DB2 extends SearchEngine { else $q[] = $terms[1] . $wgContLang->normalizeForSearch( $terms[2] ); - if (!empty($terms[3])) { + if ( !empty( $terms[3] ) ) { $regexp = preg_quote( $terms[3], '/' ); - if ($terms[4]) + if ( $terms[4] ) $regexp .= "[0-9A-Za-z_]+"; } else { - $regexp = preg_quote(str_replace('"', '', $terms[2]), '/'); + $regexp = preg_quote(str_replace( '"', '', $terms[2]), '/' ); } $this->searchTerms[] = $regexp; } } - $searchon = $this->db->strencode(join(',', $q)); - $field = $this->getIndexField($fulltext); + $searchon = $this->db->strencode( join( ',', $q ) ); + $field = $this->getIndexField( $fulltext ); // requires Net Search Extender or equivalent //return " CONTAINS($field, '$searchon') > 0 "; @@ -201,18 +201,18 @@ class SearchIBM_DB2 extends SearchEngine { * @param $title String * @param $text String */ - function update($id, $title, $text) { - $dbw = wfGetDB(DB_MASTER); - $dbw->replace('searchindex', - array('si_page'), + function update( $id, $title, $text ) { + $dbw = wfGetDB( DB_MASTER ); + $dbw->replace( 'searchindex', + array( 'si_page' ), array( 'si_page' => $id, 'si_title' => $title, 'si_text' => $text ), 'SearchIBM_DB2::update' ); // ? - //$dbw->query("CALL ctx_ddl.sync_index('si_text_idx')"); - //$dbw->query("CALL ctx_ddl.sync_index('si_title_idx')"); + //$dbw->query( "CALL ctx_ddl.sync_index('si_text_idx')" ); + //$dbw->query( "CALL ctx_ddl.sync_index('si_title_idx')" ); } /** @@ -222,13 +222,13 @@ class SearchIBM_DB2 extends SearchEngine { * @param $id Integer * @param $title String */ - function updateTitle($id, $title) { - $dbw = wfGetDB(DB_MASTER); + function updateTitle( $id, $title ) { + $dbw = wfGetDB( DB_MASTER ); - $dbw->update('searchindex', - array('si_title' => $title), - array('si_page' => $id), + $dbw->update( 'searchindex', + array( 'si_title' => $title ), + array( 'si_page' => $id ), 'SearchIBM_DB2::updateTitle', - array()); + array() ); } } diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index 5cee03e0fd..a76662b885 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -58,7 +58,7 @@ class SearchMySQL extends SearchEngine { # @todo FIXME: This doesn't handle parenthetical expressions. $m = array(); if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER ) ) { + $filteredText, $m, PREG_SET_ORDER ) ) { foreach( $m as $bits ) { @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; @@ -221,7 +221,7 @@ class SearchMySQL extends SearchEngine { */ protected function queryFeatures( &$query ) { foreach ( $this->features as $feature => $value ) { - if ( $feature === 'list-redirects' && !$value ) { + if ( $feature === 'list-redirects' && !$value ) { $query['conds']['page_is_redirect'] = 0; } elseif( $feature === 'title-suffix-filter' && $value ) { $query['conds'][] = 'page_title' . $this->db->buildLike( $this->db->anyString(), $value ); diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 29070e1ad1..009502b1ff 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -61,7 +61,7 @@ class SearchOracle extends SearchEngine { * Creates an instance of this class * @param $db DatabasePostgres: database object */ - function __construct($db) { + function __construct( $db ) { parent::__construct( $db ); } @@ -72,11 +72,11 @@ class SearchOracle extends SearchEngine { * @return SqlSearchResultSet */ function searchText( $term ) { - if ($term == '') - return new SqlSearchResultSet(false, ''); + if ( $term == '' ) + return new SqlSearchResultSet( false, '' ); - $resultSet = $this->db->resultObject($this->db->query($this->getQuery($this->filter($term), true))); - return new SqlSearchResultSet($resultSet, $this->searchTerms); + $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) ); + return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } /** @@ -85,12 +85,12 @@ class SearchOracle extends SearchEngine { * @param $term String: raw search term * @return SqlSearchResultSet */ - function searchTitle($term) { - if ($term == '') - return new SqlSearchResultSet(false, ''); + function searchTitle( $term ) { + if ( $term == '' ) + return new SqlSearchResultSet( false, '' ); - $resultSet = $this->db->resultObject($this->db->query($this->getQuery($this->filter($term), false))); - return new MySQLSearchResultSet($resultSet, $this->searchTerms); + $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) ); + return new MySQLSearchResultSet( $resultSet, $this->searchTerms ); } @@ -99,7 +99,7 @@ class SearchOracle extends SearchEngine { * @return String */ function queryRedirect() { - if ($this->showRedirects) { + if ( $this->showRedirects ) { return ''; } else { return 'AND page_is_redirect=0'; @@ -111,7 +111,7 @@ class SearchOracle extends SearchEngine { * @return String */ function queryNamespaces() { - if( is_null($this->namespaces) ) + if( is_null( $this->namespaces ) ) return ''; if ( !count( $this->namespaces ) ) { $namespaces = '0'; @@ -129,7 +129,7 @@ class SearchOracle extends SearchEngine { * @return String */ function queryLimit( $sql ) { - return $this->db->limitResult($sql, $this->limit, $this->offset); + return $this->db->limitResult( $sql, $this->limit, $this->offset ); } /** @@ -150,10 +150,10 @@ class SearchOracle extends SearchEngine { * @return String */ function getQuery( $filteredTerm, $fulltext ) { - return $this->queryLimit($this->queryMain($filteredTerm, $fulltext) . ' ' . + return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' . $this->queryRedirect() . ' ' . $this->queryNamespaces() . ' ' . - $this->queryRanking( $filteredTerm, $fulltext ) . ' '); + $this->queryRanking( $filteredTerm, $fulltext ) . ' ' ); } @@ -162,7 +162,7 @@ class SearchOracle extends SearchEngine { * @param $fulltext Boolean * @return String */ - function getIndexField($fulltext) { + function getIndexField( $fulltext ) { return $fulltext ? 'si_text' : 'si_title'; } @@ -174,9 +174,9 @@ class SearchOracle extends SearchEngine { * @return String */ function queryMain( $filteredTerm, $fulltext ) { - $match = $this->parseQuery($filteredTerm, $fulltext); - $page = $this->db->tableName('page'); - $searchindex = $this->db->tableName('searchindex'); + $match = $this->parseQuery( $filteredTerm, $fulltext ); + $page = $this->db->tableName( 'page' ); + $searchindex = $this->db->tableName( 'searchindex' ); return 'SELECT page_id, page_namespace, page_title ' . "FROM $page,$searchindex " . 'WHERE page_id=si_page AND ' . $match; @@ -187,7 +187,7 @@ class SearchOracle extends SearchEngine { * as part of a WHERE clause * @return string */ - function parseQuery($filteredText, $fulltext) { + function parseQuery( $filteredText, $fulltext ) { global $wgContLang; $lc = SearchEngine::legalSearchChars(); $this->searchTerms = array(); @@ -195,9 +195,9 @@ class SearchOracle extends SearchEngine { # @todo FIXME: This doesn't handle parenthetical expressions. $m = array(); $searchon = ''; - if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER)) { - foreach($m as $terms) { + if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + $filteredText, $m, PREG_SET_ORDER ) ) { + foreach( $m as $terms ) { // Search terms in all variant forms, only // apply on wiki with LanguageConverter $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] ); @@ -210,27 +210,27 @@ class SearchOracle extends SearchEngine { else { $searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $terms[2] ); } - if (!empty($terms[3])) { + if ( !empty( $terms[3] ) ) { $regexp = preg_quote( $terms[3], '/' ); - if ($terms[4]) + if ( $terms[4] ) $regexp .= "[0-9A-Za-z_]+"; } else { - $regexp = preg_quote(str_replace('"', '', $terms[2]), '/'); + $regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' ); } $this->searchTerms[] = $regexp; } } - $searchon = $this->db->addQuotes(ltrim($searchon, ' &')); - $field = $this->getIndexField($fulltext); + $searchon = $this->db->addQuotes( ltrim( $searchon, ' &' ) ); + $field = $this->getIndexField( $fulltext ); return " CONTAINS($field, $searchon, 1) > 0 "; } - private function escapeTerm($t) { + private function escapeTerm( $t ) { global $wgContLang; - $t = $wgContLang->normalizeForSearch($t); - $t = isset($this->reservedWords[strtoupper($t)]) ? '{'.$t.'}' : $t; + $t = $wgContLang->normalizeForSearch( $t ); + $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{'.$t.'}' : $t; $t = preg_replace('/^"(.*)"$/', '($1)', $t); $t = preg_replace('/([-&|])/', '\\\\$1', $t); return $t; @@ -243,10 +243,10 @@ class SearchOracle extends SearchEngine { * @param $title String * @param $text String */ - function update($id, $title, $text) { - $dbw = wfGetDB(DB_MASTER); - $dbw->replace('searchindex', - array('si_page'), + function update( $id, $title, $text ) { + $dbw = wfGetDB( DB_MASTER ); + $dbw->replace( 'searchindex', + array( 'si_page' ), array( 'si_page' => $id, 'si_title' => $title, @@ -271,14 +271,14 @@ class SearchOracle extends SearchEngine { * @param $id Integer * @param $title String */ - function updateTitle($id, $title) { - $dbw = wfGetDB(DB_MASTER); + function updateTitle( $id, $title ) { + $dbw = wfGetDB( DB_MASTER ); - $dbw->update('searchindex', - array('si_title' => $title), - array('si_page' => $id), + $dbw->update( 'searchindex', + array( 'si_title' => $title ), + array( 'si_page' => $id ), 'SearchOracle::updateTitle', - array()); + array() ); } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 9c89c3dff4..727cc16604 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -66,8 +66,8 @@ class SearchPostgres extends SearchEngine { $q = $this->searchQuery( $term, 'textvector', 'old_text' ); $olderror = error_reporting(E_ERROR); $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) ); - error_reporting($olderror); - if (!$resultSet) { + error_reporting( $olderror ); + if ( !$resultSet ) { return new SearchResultTooMany(); } return new PostgresSearchResultSet( $resultSet, $this->searchTerms ); @@ -99,16 +99,16 @@ class SearchPostgres extends SearchEngine { $m = array(); if( preg_match_all('/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) { foreach( $m as $terms ) { - if (strlen($terms[1])) { + if ( strlen( $terms[1] ) ) { $searchstring .= ' & !'; } - if (strtolower($terms[2]) === 'and') { + if ( strtolower( $terms[2] ) === 'and' ) { $searchstring .= ' & '; } - elseif (strtolower($terms[2]) === 'or' or $terms[2] === '|') { + elseif ( strtolower( $terms[2] ) === 'or' or $terms[2] === '|' ) { $searchstring .= ' | '; } - elseif (strtolower($terms[2]) === 'not') { + elseif ( strtolower( $terms[2] ) === 'not' ) { $searchstring .= ' & !'; } else { @@ -133,7 +133,7 @@ class SearchPostgres extends SearchEngine { $searchstring = preg_replace('/^[\'"](.*)[\'"]$/', "$1", $searchstring); ## Quote the whole thing - $searchstring = $this->db->addQuotes($searchstring); + $searchstring = $this->db->addQuotes( $searchstring ); wfDebug( "parseQuery returned: $searchstring \n" ); @@ -154,15 +154,15 @@ class SearchPostgres extends SearchEngine { ## We need a separate query here so gin does not complain about empty searches $SQL = "SELECT to_tsquery($searchstring)"; - $res = $this->db->query($SQL); - if (!$res) { + $res = $this->db->query( $SQL ); + if ( !$res ) { ## TODO: Better output (example to catch: one 'two) - die ("Sorry, that was not a valid search string. Please go back and try again"); + die( "Sorry, that was not a valid search string. Please go back and try again" ); } $top = $res->fetchRow(); $top = $top[0]; - if ($top === "") { ## e.g. if only stopwords are used XXX return something better + if ( $top === "" ) { ## e.g. if only stopwords are used XXX return something better $query = "SELECT page_id, page_namespace, page_title, 0 AS score ". "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " . "AND r.rev_text_id = c.old_id AND 1=0"; @@ -182,7 +182,7 @@ class SearchPostgres extends SearchEngine { } ## Redirects - if (! $this->showRedirects) + if ( !$this->showRedirects ) $query .= ' AND page_is_redirect = 0'; ## Namespaces - defaults to 0 @@ -226,7 +226,7 @@ class SearchPostgres extends SearchEngine { */ class PostgresSearchResult extends SearchResult { function __construct( $row ) { - parent::__construct($row); + parent::__construct( $row ); $this->score = $row->score; } function getScore() { diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index e52e4fe391..f91399a5d8 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -62,7 +62,7 @@ class SearchSqlite extends SearchEngine { $m = array(); if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', - $filteredText, $m, PREG_SET_ORDER ) ) { + $filteredText, $m, PREG_SET_ORDER ) ) { foreach( $m as $bits ) { @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; @@ -214,7 +214,7 @@ class SearchSqlite extends SearchEngine { * @return String */ function queryNamespaces() { - if( is_null($this->namespaces) ) + if( is_null( $this->namespaces ) ) return ''; # search all if ( !count( $this->namespaces ) ) { $namespaces = '0'; @@ -266,7 +266,7 @@ class SearchSqlite extends SearchEngine { */ function queryMain( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); - $page = $this->db->tableName( 'page' ); + $page = $this->db->tableName( 'page' ); $searchindex = $this->db->tableName( 'searchindex' ); return "SELECT $searchindex.rowid, page_namespace, page_title " . "FROM $page,$searchindex " . @@ -317,7 +317,7 @@ class SearchSqlite extends SearchEngine { * @param $id Integer * @param $title String */ - function updateTitle( $id, $title ) { + function updateTitle( $id, $title ) { if ( !$this->fulltextSearchSupported() ) { return; } diff --git a/includes/search/SearchUpdate.php b/includes/search/SearchUpdate.php index 389c317499..eabcda3e74 100644 --- a/includes/search/SearchUpdate.php +++ b/includes/search/SearchUpdate.php @@ -79,7 +79,7 @@ class SearchUpdate implements DeferrableUpdate { $text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/", ' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup $text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD", - "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings + "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings # Strip external URLs $uc = "A-Za-z0-9_\\/:.,~%\\-+&;#?!=()@\\x80-\\xFF"; @@ -97,7 +97,7 @@ class SearchUpdate implements DeferrableUpdate { $text = preg_replace( $pat2, " \\1 \\3", $text ); $text = preg_replace( "/([^{$lc}])([{$lc}]+)]]([a-z]+)/", - "\\1\\2 \\2\\3", $text ); # Handle [[game]]s + "\\1\\2 \\2\\3", $text ); # Handle [[game]]s # Strip all remaining non-search characters $text = preg_replace( "/[^{$lc}]+/", " ", $text ); @@ -127,7 +127,7 @@ class SearchUpdate implements DeferrableUpdate { wfRunHooks( 'SearchUpdate', array( $this->mId, $this->mNamespace, $this->mTitle, &$text ) ); # Perform the actual update - $search->update($this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ), + $search->update( $this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ), $search->normalizeText( $text ) ); wfProfileOut( __METHOD__ ); -- 2.20.1