From 6c38a5eb723fedbc38d6fba7ea650885375fb4dd Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 20 Apr 2013 17:38:24 +0200 Subject: [PATCH] Fixed spacing in logging/parser/profiler/rl/revdel/search folder Added spaces before if, foreach Added some braces for one line statements Change-Id: I11bbcfa351e945b7bde10c2105d61a3cf5622205 --- includes/logging/DeleteLogFormatter.php | 6 +- includes/logging/LogEntry.php | 6 +- includes/logging/LogEventsList.php | 63 +++++----- includes/logging/LogFormatter.php | 4 +- includes/logging/LogPage.php | 44 +++---- includes/logging/LogPager.php | 57 ++++----- includes/logging/MoveLogFormatter.php | 2 +- includes/parser/CacheTime.php | 2 +- includes/parser/CoreParserFunctions.php | 108 +++++++++++------- includes/parser/CoreTagHooks.php | 2 +- includes/parser/DateFormatter.php | 14 ++- includes/parser/LinkHolderArray.php | 28 ++--- includes/parser/Parser.php | 104 ++++++++++------- includes/parser/ParserCache.php | 6 +- includes/parser/ParserOptions.php | 5 +- includes/parser/ParserOutput.php | 12 +- includes/parser/Parser_DiffTest.php | 2 +- includes/parser/Preprocessor_DOM.php | 6 +- includes/parser/Preprocessor_Hash.php | 2 +- includes/parser/Tidy.php | 2 +- includes/profiler/Profiler.php | 66 ++++++----- includes/profiler/ProfilerSimpleUDP.php | 2 +- .../ResourceLoaderStartUpModule.php | 2 +- .../ResourceLoaderUserGroupsModule.php | 2 +- includes/revisiondelete/RevisionDelete.php | 38 +++--- .../RevisionDeleteAbstracts.php | 10 +- .../revisiondelete/RevisionDeleteUser.php | 2 +- includes/revisiondelete/RevisionDeleter.php | 9 +- includes/search/SearchEngine.php | 84 +++++++++----- includes/search/SearchMssql.php | 6 +- includes/search/SearchMySQL.php | 46 ++++---- includes/search/SearchOracle.php | 24 ++-- includes/search/SearchPostgres.php | 15 +-- includes/search/SearchSqlite.php | 35 +++--- includes/search/SearchUpdate.php | 6 +- 35 files changed, 457 insertions(+), 365 deletions(-) diff --git a/includes/logging/DeleteLogFormatter.php b/includes/logging/DeleteLogFormatter.php index 1e0e54fced..ef9a2d4092 100644 --- a/includes/logging/DeleteLogFormatter.php +++ b/includes/logging/DeleteLogFormatter.php @@ -101,7 +101,7 @@ class DeleteLogFormatter extends LogFormatter { switch ( $this->entry->getSubtype() ) { case 'delete': // Show undelete link - if( $user->isAllowed( 'undelete' ) ) { + if ( $user->isAllowed( 'undelete' ) ) { $message = 'undeletelink'; } else { $message = 'undeleteviewlink'; @@ -147,8 +147,8 @@ class DeleteLogFormatter extends LogFormatter { $this->msg( 'diff' )->escaped(), array(), array( - 'target' => $this->entry->getTarget()->getPrefixedDBkey(), - 'diff' => 'prev', + 'target' => $this->entry->getTarget()->getPrefixedDBkey(), + 'diff' => 'prev', 'timestamp' => $ids[0] ) ); diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 0f20ed16a8..b99f16bd09 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -151,7 +151,7 @@ class DatabaseLogEntry extends LogEntryBase { return array( 'tables' => $tables, 'fields' => $fields, - 'conds' => array(), + 'conds' => array(), 'options' => array(), 'join_conds' => $joins, ); @@ -233,7 +233,7 @@ class DatabaseLogEntry extends LogEntryBase { } public function getPerformer() { - if( !$this->performer ) { + if ( !$this->performer ) { $userId = (int) $this->row->log_user; if ( $userId !== 0 ) { // logged-in users if ( isset( $this->row->user_name ) ) { @@ -291,7 +291,7 @@ class RCDatabaseLogEntry extends DatabaseLogEntry { } public function getPerformer() { - if( !$this->performer ) { + if ( !$this->performer ) { $userId = (int) $this->row->rc_user; if ( $userId !== 0 ) { $this->performer = User::newFromId( $userId ); diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index fd598dff87..ba48bd72e0 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -76,7 +76,7 @@ class LogEventsList extends ContextSource { // If only one log type is used, then show a special message... $headerType = (count( $type ) == 1) ? $type[0] : ''; $out = $this->getOutput(); - if( LogPage::isLogType( $headerType ) ) { + if ( LogPage::isLogType( $headerType ) ) { $page = new LogPage( $headerType ); $out->setPageTitle( $page->getName()->text() ); $out->addHTML( $page->getDescription()->parseAsBlock() ); @@ -104,7 +104,7 @@ class LogEventsList extends ContextSource { $title = SpecialPage::getTitleFor( 'Log' ); // For B/C, we take strings, but make sure they are converted... - $types = ($types === '') ? array() : (array)$types; + $types = ( $types === '' ) ? array() : (array)$types; $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); @@ -156,7 +156,7 @@ class LogEventsList extends ContextSource { // Option value -> message mapping $links = array(); $hiddens = ''; // keep track for "go" button - foreach( $filter as $type => $val ) { + foreach ( $filter as $type => $val ) { // Should the below assignment be outside the foreach? // Then it would have to be copied. Not certain what is more expensive. $query = $this->getDefaultQuery(); @@ -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 ) ) { @@ -229,7 +229,7 @@ class LogEventsList extends ContextSource { $typesByName = array( '' => $public ) + $typesByName; $select = new XmlSelect( 'type' ); - foreach( $typesByName as $type => $name ) { + foreach ( $typesByName as $type => $name ) { $select->addOption( $name, $type ); } @@ -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 ); } @@ -342,16 +342,16 @@ class LogEventsList extends ContextSource { * @return string */ private function getShowHideLinks( $row ) { - if( ( $this->flags == self::NO_ACTION_LINK ) // we don't want to see the links + if ( ( $this->flags == self::NO_ACTION_LINK ) // we don't want to see the links || $row->log_type == 'suppress' ) { // no one can hide items from the suppress log return ''; } $del = ''; $user = $this->getUser(); // Don't show useless checkbox to people who cannot hide log entries - if( $user->isAllowed( 'deletedhistory' ) ) { + if ( $user->isAllowed( 'deletedhistory' ) ) { $canHide = $user->isAllowed( 'deletelogentry' ); - if( $row->log_deleted || $canHide ) { + if ( $row->log_deleted || $canHide ) { if ( $canHide && $this->flags & self::USE_REVDEL_CHECKBOXES ) { // Show checkboxes instead of links. if ( !self::userCan( $row, LogPage::DELETED_RESTRICTED, $user ) ) { // If event was hidden from sysops $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); @@ -364,8 +364,8 @@ class LogEventsList extends ContextSource { } else { $query = array( 'target' => SpecialPage::getTitleFor( 'Log', $row->log_type )->getPrefixedDBkey(), - 'type' => 'logging', - 'ids' => $row->log_id, + 'type' => 'logging', + 'ids' => $row->log_id, ); $del = Linker::revDeleteLink( $query, self::isDeleted( $row, LogPage::DELETED_RESTRICTED ), $canHide ); } @@ -385,10 +385,10 @@ class LogEventsList extends ContextSource { public static function typeAction( $row, $type, $action, $right = '' ) { $match = is_array( $type ) ? in_array( $row->log_type, $type ) : $row->log_type == $type; - if( $match ) { + if ( $match ) { $match = is_array( $action ) ? in_array( $row->log_action, $action ) : $row->log_action == $action; - if( $match && $right ) { + if ( $match && $right ) { global $wgUser; $match = $wgUser->isAllowed( $right ); } @@ -419,7 +419,7 @@ class LogEventsList extends ContextSource { * @return Boolean */ public static function userCanBitfield( $bitfield, $field, User $user = null ) { - if( $bitfield & $field ) { + if ( $bitfield & $field ) { if ( $bitfield & LogPage::DELETED_RESTRICTED ) { $permission = 'suppressrevision'; } else { @@ -503,10 +503,12 @@ class LogEventsList extends ContextSource { if ( isset( $param['offset'] ) ) { # Tell pager to ignore WebRequest offset $pager->setOffset( $param['offset'] ); } - if( $lim > 0 ) $pager->mLimit = $lim; + if ( $lim > 0 ) { + $pager->mLimit = $lim; + } $logBody = $pager->getBody(); $s = ''; - if( $logBody ) { + if ( $logBody ) { if ( $msgKey[0] ) { $s = '
'; @@ -521,26 +523,27 @@ class LogEventsList extends ContextSource { $s .= $loglist->beginLogEventsList() . $logBody . $loglist->endLogEventsList(); - } else { - if ( $showIfEmpty ) { - $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ), - $context->msg( 'logempty' )->parse() ); - } + } elseif ( $showIfEmpty ) { + $s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ), + $context->msg( 'logempty' )->parse() ); } - if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link + if ( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link $urlParam = array(); if ( $page instanceof Title ) { $urlParam['page'] = $page->getPrefixedDBkey(); } elseif ( $page != '' ) { $urlParam['page'] = $page; } - if ( $user != '' ) + if ( $user != '' ) { $urlParam['user'] = $user; - if ( !is_array( $types ) ) # Make it an array, if it isn't + } + if ( !is_array( $types ) ) { # Make it an array, if it isn't $types = array( $types ); + } # If there is exactly one log type, we can link to Special:Log?type=foo - if ( count( $types ) == 1 ) + if ( count( $types ) == 1 ) { $urlParam['type'] = $types[0]; + } $s .= Linker::link( SpecialPage::getTitleFor( 'Log' ), $context->msg( 'log-fulllog' )->escaped(), @@ -589,14 +592,14 @@ class LogEventsList extends ContextSource { $hiddenLogs = array(); // Don't show private logs to unprivileged users - foreach( $wgLogRestrictions as $logType => $right ) { - if( $audience == 'public' || !$user->isAllowed( $right ) ) { + foreach ( $wgLogRestrictions as $logType => $right ) { + if ( $audience == 'public' || !$user->isAllowed( $right ) ) { $hiddenLogs[] = $logType; } } - if( count( $hiddenLogs ) == 1 ) { + if ( count( $hiddenLogs ) == 1 ) { return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] ); - } elseif( $hiddenLogs ) { + } elseif ( $hiddenLogs ) { return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) . ')'; } return false; diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 683dc03a3c..27526f591f 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -320,7 +320,7 @@ class LogFormatter { // case 'suppress' --private log -- aaron (sign your messages so we know who to blame in a few years :-D) // default: } - if( is_null( $text ) ) { + if ( is_null( $text ) ) { $text = $this->getPlainActionText(); } @@ -775,7 +775,7 @@ class LegacyLogFormatter extends LogFormatter { return $this->msg( 'parentheses' )->rawParams( $this->context->getLanguage()->pipeList( $links ) )->escaped(); // Show unmerge link - } elseif( $type == 'merge' && $subtype == 'merge' ) { + } elseif ( $type == 'merge' && $subtype == 'merge' ) { if ( !$this->context->getUser()->isAllowed( 'mergehistory' ) ) { return ''; } diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 36ba200961..3fe91fc1e2 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -94,7 +94,7 @@ class LogPage { $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); # And update recentchanges - if( $this->updateRecentChanges ) { + if ( $this->updateRecentChanges ) { $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); RecentChange::notifyLog( @@ -102,9 +102,9 @@ class LogPage { $this->type, $this->action, $this->target, $this->comment, $this->params, $newId, $this->getRcCommentIRC() ); - } elseif( $this->sendToUDP ) { + } elseif ( $this->sendToUDP ) { # Don't send private logs to UDP - if( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) { + if ( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) { return $newId; } @@ -129,7 +129,7 @@ class LogPage { public function getRcComment() { $rcComment = $this->actionText; - if( $this->comment != '' ) { + if ( $this->comment != '' ) { if ( $rcComment == '' ) { $rcComment = $this->comment; } else { @@ -149,7 +149,7 @@ class LogPage { public function getRcCommentIRC() { $rcComment = $this->ircActionText; - if( $this->comment != '' ) { + if ( $this->comment != '' ) { if ( $rcComment == '' ) { $rcComment = $this->comment; } else { @@ -198,7 +198,7 @@ class LogPage { public static function logName( $type ) { global $wgLogNames; - if( isset( $wgLogNames[$type] ) ) { + if ( isset( $wgLogNames[$type] ) ) { return str_replace( '_', ' ', wfMessage( $wgLogNames[$type] )->text() ); } else { // Bogus log types? Perhaps an extension was removed. @@ -247,13 +247,13 @@ class LogPage { $key = "$type/$action"; - if( isset( $wgLogActions[$key] ) ) { - if( is_null( $title ) ) { + if ( isset( $wgLogActions[$key] ) ) { + if ( is_null( $title ) ) { $rv = wfMessage( $wgLogActions[$key] )->inLanguage( $langObj )->escaped(); } else { $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params ); - if( count( $params ) == 0 ) { + if ( count( $params ) == 0 ) { $rv = wfMessage( $wgLogActions[$key] )->rawParams( $titleLink )->inLanguage( $langObj )->escaped(); } else { $details = ''; @@ -273,14 +273,14 @@ class LogPage { // Page protections } elseif ( $type == 'protect' && count( $params ) == 3 ) { // Restrictions and expiries - if( $skin ) { + if ( $skin ) { $details .= $wgLang->getDirMark() . htmlspecialchars( " {$params[1]}" ); } else { $details .= " {$params[1]}"; } // Cascading flag... - if( $params[2] ) { + if ( $params[2] ) { $details .= ' [' . wfMessage( 'protect-summary-cascade' )->inLanguage( $langObj )->text() . ']'; } } @@ -291,7 +291,7 @@ class LogPage { } else { global $wgLogActionsHandlers; - if( isset( $wgLogActionsHandlers[$key] ) ) { + if ( isset( $wgLogActionsHandlers[$key] ) ) { $args = func_get_args(); $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args ); } else { @@ -310,7 +310,7 @@ class LogPage { // you want to link to something OTHER than the title of the log entry. // The real problem, which Erik was trying to fix (and it sort-of works now) is // that the same messages are being treated as both wikitext *and* HTML. - if( $filterWikilinks ) { + if ( $filterWikilinks ) { $rv = str_replace( '[[', '', $rv ); $rv = str_replace( ']]', '', $rv ); } @@ -327,7 +327,7 @@ class LogPage { * @return String */ protected static function getTitleLink( $type, $lang, $title, &$params ) { - if( !$lang ) { + if ( !$lang ) { return $title->getPrefixedText(); } @@ -353,7 +353,7 @@ class LogPage { } break; case 'block': - if( substr( $title->getText(), 0, 1 ) == '#' ) { + if ( substr( $title->getText(), 0, 1 ) == '#' ) { $titleLink = $title->getText(); } else { // @todo Store the user identifier in the parameters @@ -377,11 +377,11 @@ class LogPage { $params[1] = $lang->timeanddate( $params[1] ); break; default: - if( $title->isSpecialPage() ) { + if ( $title->isSpecialPage() ) { list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); # Use the language name for log titles, rather than Log/X - if( $name == 'Log' ) { + if ( $name == 'Log' ) { $logPage = new LogPage( $par ); $titleLink = Linker::link( $title, $logPage->getName()->escaped() ); $titleLink = wfMessage( 'parentheses' ) @@ -465,13 +465,13 @@ class LogPage { * @return Boolean */ public function addRelations( $field, $values, $logid ) { - if( !strlen( $field ) || empty( $values ) ) { + if ( !strlen( $field ) || empty( $values ) ) { return false; // nothing } $data = array(); - foreach( $values as $value ) { + foreach ( $values as $value ) { $data[] = array( 'ls_field' => $field, 'ls_value' => $value, @@ -520,8 +520,8 @@ class LogPage { public static function formatBlockFlags( $flags, $lang ) { $flags = explode( ',', trim( $flags ) ); - if( count( $flags ) > 0 ) { - for( $i = 0; $i < count( $flags ); $i++ ) { + if ( count( $flags ) > 0 ) { + for ( $i = 0; $i < count( $flags ); $i++ ) { $flags[$i] = self::formatBlockFlag( $flags[$i], $lang ); } return wfMessage( 'parentheses' )->inLanguage( $lang ) @@ -541,7 +541,7 @@ class LogPage { public static function formatBlockFlag( $flag, $lang ) { static $messages = array(); - if( !isset( $messages[$flag] ) ) { + if ( !isset( $messages[$flag] ) ) { $messages[$flag] = htmlspecialchars( $flag ); // Fallback // For grepping. The following core messages can be used here: diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 908755ed8a..5ffad43a7b 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -71,16 +71,17 @@ 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 ) { + foreach ( $wgFilterLogTypes as $type => $default ) { // Avoid silly filtering - if( $type !== 'patrol' || $this->getUser()->useNPPatrol() ) { + if ( $type !== 'patrol' || $this->getUser()->useNPPatrol() ) { $hide = $this->getRequest()->getInt( "hide_{$type}_log", $default ); $filters[$type] = $hide; - if( $hide ) + if ( $hide ) { $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type ); + } } } return $filters; @@ -98,11 +99,11 @@ class LogPager extends ReverseChronologicalPager { $user = $this->getUser(); // If $types is not an array, make it an array - $types = ($types === '') ? array() : (array)$types; + $types = ( $types === '' ) ? array() : (array)$types; // Don't even show header for private logs; don't recognize it... $needReindex = false; foreach ( $types as $type ) { - if( isset( $wgLogRestrictions[$type] ) + if ( isset( $wgLogRestrictions[$type] ) && !$user->isAllowed( $wgLogRestrictions[$type] ) ) { $needReindex = true; @@ -119,13 +120,15 @@ class LogPager extends ReverseChronologicalPager { // Also, only show them upon specific request to avoid suprises. $audience = $types ? 'user' : 'public'; $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience, $user ); - if( $hideLogs !== false ) { + 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]; + } } } @@ -136,16 +139,16 @@ class LogPager extends ReverseChronologicalPager { * @return bool */ private function limitPerformer( $name ) { - if( $name == '' ) { + if ( $name == '' ) { 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 */ $userid = User::idFromName( $name ); - if( !$userid ) { + if ( !$userid ) { /* It should be nicer to abort query at all, but for now it won't pass anywhere behind the optimizer */ $this->mConds[] = "NULL"; @@ -153,9 +156,9 @@ class LogPager extends ReverseChronologicalPager { $this->mConds['log_user'] = $userid; // Paranoia: avoid brute force searches (bug 17342) $user = $this->getUser(); - if( !$user->isAllowed( 'deletedhistory' ) ) { + if ( !$user->isAllowed( 'deletedhistory' ) ) { $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0'; - } elseif( !$user->isAllowed( 'suppressrevision' ) ) { + } elseif ( !$user->isAllowed( 'suppressrevision' ) ) { $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) . ' != ' . LogPage::SUPPRESSED_USER; } @@ -178,7 +181,7 @@ class LogPager extends ReverseChronologicalPager { $title = $page; } else { $title = Title::newFromText( $page ); - if( strlen( $page ) == 0 || !$title instanceof Title ) { + if ( strlen( $page ) == 0 || !$title instanceof Title ) { return false; } } @@ -198,7 +201,7 @@ class LogPager extends ReverseChronologicalPager { # use the page_time index. That should have no more than a few hundred # log entries for even the busiest pages, so it can be safely scanned # in full to satisfy an impossible condition on user or similar. - if( $pattern && !$wgMiserMode ) { + if ( $pattern && !$wgMiserMode ) { $this->mConds['log_namespace'] = $ns; $this->mConds[] = 'log_title ' . $db->buildLike( $title->getDBkey(), $db->anyString() ); $this->pattern = $pattern; @@ -208,9 +211,9 @@ class LogPager extends ReverseChronologicalPager { } // Paranoia: avoid brute force searches (bug 17342) $user = $this->getUser(); - if( !$user->isAllowed( 'deletedhistory' ) ) { + if ( !$user->isAllowed( 'deletedhistory' ) ) { $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::DELETED_ACTION) . ' = 0'; - } elseif( !$user->isAllowed( 'suppressrevision' ) ) { + } elseif ( !$user->isAllowed( 'suppressrevision' ) ) { $this->mConds[] = $db->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION) . ' != ' . LogPage::SUPPRESSED_ACTION; } @@ -234,7 +237,7 @@ class LogPager extends ReverseChronologicalPager { # Add log_search table if there are conditions on it. # This filters the results to only include log rows that have # log_search records with the specified ls_field and ls_value values. - if( array_key_exists( 'ls_field', $this->mConds ) ) { + if ( array_key_exists( 'ls_field', $this->mConds ) ) { $tables[] = 'log_search'; $index['log_search'] = 'ls_field_val'; $index['logging'] = 'PRIMARY'; @@ -249,12 +252,12 @@ class LogPager extends ReverseChronologicalPager { # Avoid usage of the wrong index by limiting # the choices of available indexes. This mainly # avoids site-breaking filesorts. - } elseif( $this->title || $this->pattern || $this->performer ) { + } 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'; @@ -264,10 +267,10 @@ class LogPager extends ReverseChronologicalPager { $joins['log_search'] = array( 'INNER JOIN', 'ls_log_id=log_id' ); $info = array( - 'tables' => $tables, - 'fields' => $fields, - 'conds' => array_merge( $conds, $this->mConds ), - 'options' => $options, + 'tables' => $tables, + 'fields' => $fields, + 'conds' => array_merge( $conds, $this->mConds ), + 'options' => $options, 'join_conds' => $joins, ); # Add ChangeTags filter query @@ -295,7 +298,7 @@ class LogPager extends ReverseChronologicalPager { public function getStartBody() { wfProfileIn( __METHOD__ ); # Do a link batch query - if( $this->getNumRows() > 0 ) { + if ( $this->getNumRows() > 0 ) { $lb = new LinkBatch; foreach ( $this->mResult as $row ) { $lb->add( $row->log_namespace, $row->log_title ); diff --git a/includes/logging/MoveLogFormatter.php b/includes/logging/MoveLogFormatter.php index 8dafb4aae1..589b1ba467 100644 --- a/includes/logging/MoveLogFormatter.php +++ b/includes/logging/MoveLogFormatter.php @@ -73,7 +73,7 @@ class MoveLogFormatter extends LogFormatter { array( 'wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), - 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), + 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), 'wpMovetalk' => 0 ) ); diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php index 6b70e1da96..8190a8a09a 100644 --- a/includes/parser/CacheTime.php +++ b/includes/parser/CacheTime.php @@ -93,7 +93,7 @@ class CacheTime { $expire = min( $expire, $wgParserCacheExpireTime ); } - if( $this->containsOldMagic() ) { //compatibility hack + if ( $this->containsOldMagic() ) { //compatibility hack $expire = min( $expire, 3600 ); # 1 hour } diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 36bfb48770..5b02e1947d 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -138,8 +138,9 @@ class CoreParserFunctions { // Specify a different default date format other than the the normal default // iff the user has 'default' for their setting - if ( $pref == 'default' && $defaultPref ) + if ( $pref == 'default' && $defaultPref ) { $pref = $defaultPref; + } $date = $df->reformat( $pref, $date, array( 'match-whole' ) ); return $date; @@ -248,14 +249,15 @@ class CoreParserFunctions { # before arriving here; if that's true, then the title can't be created # and the variable will fail. If we can't get a decent title from the first # attempt, url-decode and try for a second. - if( is_null( $title ) ) + if ( is_null( $title ) ) { $title = Title::newFromURL( urldecode( $s ) ); - if( !is_null( $title ) ) { + } + if ( !is_null( $title ) ) { # Convert NS_MEDIA -> NS_FILE - if( $title->getNamespace() == NS_MEDIA ) { + if ( $title->getNamespace() == NS_MEDIA ) { $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); } - if( !is_null( $arg ) ) { + if ( !is_null( $arg ) ) { $text = $title->$func( $arg ); } else { $text = $title->$func(); @@ -377,12 +379,10 @@ class CoreParserFunctions { $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $text, null, array(), array(), $bad ) ); $title = Title::newFromText( Sanitizer::stripAllTags( $text ) ); - if( !$wgRestrictDisplayTitle ) { + if ( !$wgRestrictDisplayTitle ) { + $parser->mOutput->setDisplayTitle( $text ); + } elseif ( $title instanceof Title && $title->getFragment() == '' && $title->equals( $parser->mTitle ) ) { $parser->mOutput->setDisplayTitle( $text ); - } else { - if ( $title instanceof Title && $title->getFragment() == '' && $title->equals( $parser->mTitle ) ) { - $parser->mOutput->setDisplayTitle( $text ); - } } return ''; @@ -404,7 +404,7 @@ class CoreParserFunctions { } static function formatRaw( $num, $raw ) { - if( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) { + if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) { return $num; } else { global $wgContLang; @@ -451,44 +451,51 @@ class CoreParserFunctions { */ static function mwnamespace( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return str_replace( '_', ' ', $t->getNsText() ); } static function namespacee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfUrlencode( $t->getNsText() ); } static function namespacenumber( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return $t->getNamespace(); } static function talkspace( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return str_replace( '_', ' ', $t->getTalkNsText() ); } static function talkspacee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return wfUrlencode( $t->getTalkNsText() ); } static function subjectspace( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return str_replace( '_', ' ', $t->getSubjectNsText() ); } static function subjectspacee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfUrlencode( $t->getSubjectNsText() ); } @@ -499,74 +506,86 @@ class CoreParserFunctions { */ static function pagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getText() ); } static function pagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getPartialURL() ); } static function fullpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return wfEscapeWikiText( $t->getPrefixedText() ); } static function fullpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return wfEscapeWikiText( $t->getPrefixedURL() ); } static function subpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getSubpageText() ); } static function subpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getSubpageUrlForm() ); } static function basepagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getBaseText() ); } static function basepagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ) ); } static function talkpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() ); } static function talkpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) + if ( is_null( $t ) || !$t->canTalk() ) { return ''; + } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() ); } static function subjectpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() ); } static function subjectpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) ) + if ( is_null( $t ) ) { return ''; + } return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedURL() ); } @@ -589,7 +608,7 @@ class CoreParserFunctions { static $cache = array(); // split the given option to its variable - if( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) { + if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) { //{{pagesincategory:|raw[|type]}} $raw = $arg1; $type = $magicWords->matchStartToEnd( $arg2 ); @@ -598,23 +617,23 @@ class CoreParserFunctions { $type = $magicWords->matchStartToEnd( $arg1 ); $raw = $arg2; } - if( !$type ) { //backward compatibility + if ( !$type ) { //backward compatibility $type = 'pagesincategory_all'; } $title = Title::makeTitleSafe( NS_CATEGORY, $name ); - if( !$title ) { # invalid title + if ( !$title ) { # invalid title return self::formatRaw( 0, $raw ); } // Normalize name for cache $name = $title->getDBkey(); - if( !isset( $cache[$name] ) ) { + if ( !isset( $cache[$name] ) ) { $category = Category::newFromTitle( $title ); $allCount = $subcatCount = $fileCount = $pagesCount = 0; - if( $parser->incrementExpensiveFunctionCount() ) { + if ( $parser->incrementExpensiveFunctionCount() ) { // $allCount is the total number of cat members, // not the count of how many members are normal pages. $allCount = (int)$category->getPageCount(); @@ -653,7 +672,7 @@ class CoreParserFunctions { static $cache = array(); $title = Title::newFromText( $page ); - if( !is_object( $title ) ) { + if ( !is_object( $title ) ) { $cache[$page] = 0; return self::formatRaw( 0, $raw ); } @@ -662,9 +681,9 @@ class CoreParserFunctions { $page = $title->getPrefixedText(); $length = 0; - if( isset( $cache[$page] ) ) { + if ( isset( $cache[$page] ) ) { $length = $cache[$page]; - } elseif( $parser->incrementExpensiveFunctionCount() ) { + } elseif ( $parser->incrementExpensiveFunctionCount() ) { $rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL ); $pageID = $rev ? $rev->getPage() : 0; $revID = $rev ? $rev->getId() : 0; @@ -717,7 +736,9 @@ class CoreParserFunctions { static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { $padding = $parser->killMarkers( $padding ); $lengthOfPadding = mb_strlen( $padding ); - if ( $lengthOfPadding == 0 ) return $string; + if ( $lengthOfPadding == 0 ) { + return $string; + } # The remaining length to add counts down to 0 as padding is added $length = min( $length, 500 ) - mb_strlen( $string ); @@ -786,14 +807,15 @@ class CoreParserFunctions { $arg = $magicWords->matchStartToEnd( $uarg ); $text = trim( $text ); - if( strlen( $text ) == 0 ) + if ( strlen( $text ) == 0 ) { return ''; + } $old = $parser->getCustomDefaultSort(); if ( $old === false || $arg !== 'defaultsort_noreplace' ) { $parser->setDefaultSort( $text ); } - if( $old === false || $old == $text || $arg ) { + if ( $old === false || $old == $text || $arg ) { return ''; } else { return( '' . @@ -807,14 +829,14 @@ class CoreParserFunctions { public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) { $file = wfFindFile( $name ); - if( $argA == 'nowiki' ) { + if ( $argA == 'nowiki' ) { // {{filepath: | option [| size] }} $isNowiki = true; $parsedWidthParam = $parser->parseWidthParam( $argB ); } else { // {{filepath: [| size [|option]] }} $parsedWidthParam = $parser->parseWidthParam( $argA ); - $isNowiki = ($argB == 'nowiki'); + $isNowiki = ( $argB == 'nowiki' ); } if ( $file ) { diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php index 6505183958..a2eb69877e 100644 --- a/includes/parser/CoreTagHooks.php +++ b/includes/parser/CoreTagHooks.php @@ -77,7 +77,7 @@ class CoreTagHooks { */ static function html( $content, $attributes, $parser ) { global $wgRawHtml; - if( $wgRawHtml ) { + if ( $wgRawHtml ) { return array( $content, 'markerType' => 'nowiki' ); } else { throw new MWException( ' extension tag encountered unexpectedly' ); diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index 8103b60529..c5dd09b7d7 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -198,8 +198,9 @@ class DateFormatter { function replace( $matches ) { # Extract information from $matches $linked = true; - if ( isset( $this->mLinked ) ) + if ( isset( $this->mLinked ) ) { $linked = $this->mLinked; + } $bits = array(); $key = $this->keys[$this->mSource]; @@ -232,10 +233,12 @@ class DateFormatter { $fail = false; // Pre-generate y/Y stuff because we need the year for the title. - if ( !isset( $bits['y'] ) && isset( $bits['Y'] ) ) + if ( !isset( $bits['y'] ) && isset( $bits['Y'] ) ) { $bits['y'] = $this->makeIsoYear( $bits['Y'] ); - if ( !isset( $bits['Y'] ) && isset( $bits['y'] ) ) + } + if ( !isset( $bits['Y'] ) && isset( $bits['y'] ) ) { $bits['Y'] = $this->makeNormalYear( $bits['y'] ); + } if ( !isset( $bits['m'] ) ) { $m = $this->makeIsoMonth( $bits['F'] ); @@ -293,8 +296,9 @@ class DateFormatter { } $isoBits = array(); - if ( isset( $bits['y'] ) ) + if ( isset( $bits['y'] ) ) { $isoBits[] = $bits['y']; + } $isoBits[] = $bits['m']; $isoBits[] = $bits['d']; $isoDate = implode( '-', $isoBits ); @@ -312,7 +316,7 @@ class DateFormatter { */ function getMonthRegex() { $names = array(); - for( $i = 1; $i <= 12; $i++ ) { + for ( $i = 1; $i <= 12; $i++ ) { $names[] = $this->lang->getMonthName( $i ); $names[] = $this->lang->getMonthAbbreviation( $i ); } diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index f125510073..6fc457d741 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -322,7 +322,7 @@ class LinkHolderArray { } if ( $queries ) { $where = array(); - foreach( $queries as $ns => $pages ) { + foreach ( $queries as $ns => $pages ) { $where[] = $dbr->makeList( array( 'page_namespace' => $ns, @@ -362,7 +362,7 @@ class LinkHolderArray { wfProfileOut( __METHOD__ . '-check' ); # Do a second query for different language variants of links and categories - if( $wgContLang->hasVariants() ) { + if ( $wgContLang->hasVariants() ) { $this->doVariants( $colours ); } @@ -425,7 +425,7 @@ class LinkHolderArray { # Make interwiki link HTML $output = $this->parent->getOutput(); $replacePairs = array(); - foreach( $this->interwikis as $key => $link ) { + foreach ( $this->interwikis as $key => $link ) { $replacePairs[$key] = Linker::link( $link['title'], $link['text'] ); $output->addInterwikiLink( $link['title'] ); } @@ -486,7 +486,7 @@ class LinkHolderArray { $textVariant = $titlesAllVariants[$variantName][$i]; if ( $textVariant != $titlesAttrs[$i]['titleText'] ) { $variantTitle = Title::makeTitle( $titlesAttrs[$i]['ns'], $textVariant ); - if( is_null( $variantTitle ) ) { + if ( is_null( $variantTitle ) ) { continue; } $linkBatch->addObj( $variantTitle ); @@ -514,7 +514,7 @@ class LinkHolderArray { } } - if( !$linkBatch->isEmpty() ) { + if ( !$linkBatch->isEmpty() ) { // construct query $dbr = wfGetDB( DB_SLAVE ); $varRes = $dbr->select( 'page', @@ -533,14 +533,14 @@ class LinkHolderArray { $vardbk = $variantTitle->getDBkey(); $holderKeys = array(); - if( isset( $variantMap[$varPdbk] ) ) { + if ( isset( $variantMap[$varPdbk] ) ) { $holderKeys = $variantMap[$varPdbk]; $linkCache->addGoodLinkObjFromRow( $variantTitle, $s ); $output->addLink( $variantTitle, $s->page_id ); } // loop over link holders - foreach( $holderKeys as $key ) { + foreach ( $holderKeys as $key ) { list( $ns, $index ) = explode( ':', $key, 2 ); $entry =& $this->internals[$ns][$index]; $pdbk = $entry['pdbk']; @@ -570,12 +570,12 @@ class LinkHolderArray { wfRunHooks( 'GetLinkColours', array( $linkcolour_ids, &$colours ) ); // rebuild the categories in original order (if there are replacements) - if( count( $varCategories ) > 0 ) { + if ( count( $varCategories ) > 0 ) { $newCats = array(); $originalCats = $output->getCategories(); - foreach( $originalCats as $cat => $sortkey ) { + foreach ( $originalCats as $cat => $sortkey ) { // make the replacement - if( array_key_exists( $cat, $varCategories ) ) { + if ( array_key_exists( $cat, $varCategories ) ) { $newCats[$varCategories[$cat]] = $sortkey; } else { $newCats[$cat] = $sortkey; @@ -615,13 +615,13 @@ class LinkHolderArray { function replaceTextCallback( $matches ) { $type = $matches[1]; $key = $matches[2]; - if( $type == 'LINK' ) { + if ( $type == 'LINK' ) { list( $ns, $index ) = explode( ':', $key, 2 ); - if( isset( $this->internals[$ns][$index]['text'] ) ) { + if ( isset( $this->internals[$ns][$index]['text'] ) ) { return $this->internals[$ns][$index]['text']; } - } elseif( $type == 'IWLINK' ) { - if( isset( $this->interwikis[$key]['text'] ) ) { + } elseif ( $type == 'IWLINK' ) { + if ( isset( $this->interwikis[$key]['text'] ) ) { return $this->interwikis[$key]['text']; } } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 3ada925a14..b51ef38a72 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -769,9 +769,9 @@ class Parser { if ( $target !== null ) { return $target; - } elseif( $this->mOptions->getInterfaceMessage() ) { + } elseif ( $this->mOptions->getInterfaceMessage() ) { return $this->mOptions->getUserLangObj(); - } elseif( is_null( $this->mTitle ) ) { + } elseif ( is_null( $this->mTitle ) ) { throw new MWException( __METHOD__ . ': $this->mTitle is null' ); } @@ -1256,7 +1256,7 @@ class Parser { 'x' => 'X', )); $titleObj = SpecialPage::getTitleFor( 'Booksources', $num ); - return'getLocalURL() ) . "\" class=\"internal mw-magiclink-isbn\">ISBN $isbn"; } else { @@ -1462,41 +1462,57 @@ class Parser { } else { if ( strlen( $r ) == 2 ) { if ( $state === 'i' ) { - $output .= ''; $state = ''; + $output .= ''; + $state = ''; } elseif ( $state === 'bi' ) { - $output .= ''; $state = 'b'; + $output .= ''; + $state = 'b'; } elseif ( $state === 'ib' ) { - $output .= ''; $state = 'b'; + $output .= ''; + $state = 'b'; } elseif ( $state === 'both' ) { - $output .= '' . $buffer . ''; $state = 'b'; + $output .= '' . $buffer . ''; + $state = 'b'; } else { # $state can be 'b' or '' - $output .= ''; $state .= 'i'; + $output .= ''; + $state .= 'i'; } } elseif ( strlen( $r ) == 3 ) { if ( $state === 'b' ) { - $output .= ''; $state = ''; + $output .= ''; + $state = ''; } elseif ( $state === 'bi' ) { - $output .= ''; $state = 'i'; + $output .= ''; + $state = 'i'; } elseif ( $state === 'ib' ) { - $output .= ''; $state = 'i'; + $output .= ''; + $state = 'i'; } elseif ( $state === 'both' ) { - $output .= '' . $buffer . ''; $state = 'i'; + $output .= '' . $buffer . ''; + $state = 'i'; } else { # $state can be 'i' or '' - $output .= ''; $state .= 'b'; + $output .= ''; + $state .= 'b'; } } elseif ( strlen( $r ) == 5 ) { if ( $state === 'b' ) { - $output .= ''; $state = 'i'; + $output .= ''; + $state = 'i'; } elseif ( $state === 'i' ) { - $output .= ''; $state = 'b'; + $output .= ''; + $state = 'b'; } elseif ( $state === 'bi' ) { - $output .= ''; $state = ''; + $output .= ''; + $state = ''; } elseif ( $state === 'ib' ) { - $output .= ''; $state = ''; + $output .= ''; + $state = ''; } elseif ( $state === 'both' ) { - $output .= '' . $buffer . ''; $state = ''; + $output .= '' . $buffer . ''; + $state = ''; } else { # ($state == '') - $buffer = ''; $state = 'both'; + $buffer = ''; + $state = 'both'; } } } @@ -2491,7 +2507,7 @@ class Parser { $state = self::COLON_STATE_TEXT; $stack = 0; $len = strlen( $str ); - for( $i = 0; $i < $len; $i++ ) { + for ( $i = 0; $i < $len; $i++ ) { $c = $str[$i]; switch( $state ) { @@ -2778,7 +2794,7 @@ class Parser { break; case 'pageid': // requested in bug 23427 $pageid = $this->getTitle()->getArticleID(); - if( $pageid == 0 ) { + if ( $pageid == 0 ) { # 0 means the page doesn't exist in the database, # which means the user is previewing a new page. # The vary-revision flag must be set, because the magic word @@ -3662,9 +3678,9 @@ class Parser { if ( $skip ) { $text = false; $deps[] = array( - 'title' => $title, - 'page_id' => $title->getArticleID(), - 'rev_id' => null + 'title' => $title, + 'page_id' => $title->getArticleID(), + 'rev_id' => null ); break; } @@ -3680,15 +3696,15 @@ class Parser { } $deps[] = array( - 'title' => $title, - 'page_id' => $title->getArticleID(), - 'rev_id' => $rev_id ); + 'title' => $title, + 'page_id' => $title->getArticleID(), + 'rev_id' => $rev_id ); if ( $rev && !$title->equals( $rev->getTitle() ) ) { # We fetched a rev from a different title; register it too... $deps[] = array( - 'title' => $rev->getTitle(), - 'page_id' => $rev->getPage(), - 'rev_id' => $rev_id ); + 'title' => $rev->getTitle(), + 'page_id' => $rev->getPage(), + 'rev_id' => $rev_id ); } if ( $rev ) { @@ -4233,7 +4249,7 @@ class Parser { # count number of headlines for each level $sublevelCount[$toclevel]++; $dot = 0; - for( $i = 1; $i <= $toclevel; $i++ ) { + for ( $i = 1; $i <= $toclevel; $i++ ) { if ( !empty( $sublevelCount[$i] ) ) { if ( $dot ) { $numbering .= '.'; @@ -4486,7 +4502,7 @@ class Parser { "\r\n" => "\n", ); $text = str_replace( array_keys( $pairs ), array_values( $pairs ), $text ); - if( $options->getPreSaveTransform() ) { + if ( $options->getPreSaveTransform() ) { $text = $this->pstPass2( $text, $user ); } $text = $this->mStripState->unstripBoth( $text ); @@ -4605,8 +4621,9 @@ class Parser { $username = $user->getName(); # If not given, retrieve from the user object. - if ( $nickname === false ) + if ( $nickname === false ) { $nickname = $user->getOption( 'nickname' ); + } if ( is_null( $fancySig ) ) { $fancySig = $user->getBoolOption( 'fancysig' ); @@ -4885,8 +4902,9 @@ class Parser { # Add to function cache $mw = MagicWord::get( $id ); - if ( !$mw ) + if ( !$mw ) { throw new MWException( __METHOD__ . '() expecting a magic word identifier.' ); + } $synonyms = $mw->getSynonyms(); $sensitive = intval( $mw->isCaseSensitive() ); @@ -4930,7 +4948,9 @@ class Parser { */ function setFunctionTagHook( $tag, $callback, $flags ) { $tag = strtolower( $tag ); - if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" ); + if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { + throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" ); + } $old = isset( $this->mFunctionTagHooks[$tag] ) ? $this->mFunctionTagHooks[$tag] : null; $this->mFunctionTagHooks[$tag] = array( $callback, $flags ); @@ -5049,7 +5069,7 @@ class Parser { if ( $match = $magicWordAlt->matchVariableStartToEnd( $parameterMatch ) ) { $alt = $this->stripAltText( $match, false ); } - elseif( $match = $magicWordLink->matchVariableStartToEnd( $parameterMatch ) ) { + elseif ( $match = $magicWordLink->matchVariableStartToEnd( $parameterMatch ) ) { $linkValue = strip_tags( $this->replaceLinkHoldersText( $match ) ); $chars = self::EXT_LINK_URL_CLASS; $prots = $this->mUrlProtocols; @@ -5189,14 +5209,14 @@ class Parser { # Special case; width and height come in one variable together if ( $type === 'handler' && $paramName === 'width' ) { $parsedWidthParam = $this->parseWidthParam( $value ); - if( isset( $parsedWidthParam['width'] ) ) { + if ( isset( $parsedWidthParam['width'] ) ) { $width = $parsedWidthParam['width']; if ( $handler->validateParam( 'width', $width ) ) { $params[$type]['width'] = $width; $validated = true; } } - if( isset( $parsedWidthParam['height'] ) ) { + if ( isset( $parsedWidthParam['height'] ) ) { $height = $parsedWidthParam['height']; if ( $handler->validateParam( 'height', $height ) ) { $params[$type]['height'] = $height; @@ -5648,14 +5668,14 @@ class Parser { * @return String: user name */ function getRevisionUser() { - if( is_null( $this->mRevisionUser ) ) { + if ( is_null( $this->mRevisionUser ) ) { $revObject = $this->getRevisionObject(); # if this template is subst: the revision id will be blank, # so just use the current user's name - if( $revObject ) { + if ( $revObject ) { $this->mRevisionUser = $revObject->getUserText(); - } elseif( $this->ot['wiki'] || $this->mOptions->getIsPreview() ) { + } elseif ( $this->ot['wiki'] || $this->mOptions->getIsPreview() ) { $this->mRevisionUser = $this->getUser()->getName(); } } @@ -5935,7 +5955,7 @@ class Parser { */ public function parseWidthParam( $value ) { $parsedWidthParam = array(); - if( $value === '' ) { + if ( $value === '' ) { return $parsedWidthParam; } $m = array(); diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 0faa40a839..7c5eeb4a8f 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -67,7 +67,7 @@ class ParserCache { // idhash seem to mean 'page id' + 'rendering hash' (r3710) $pageid = $article->getID(); - $renderkey = (int)($wgRequest->getVal( 'action' ) == 'render'); + $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' ); $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" ); return $key; @@ -128,7 +128,7 @@ class ParserCache { public function getKey( $article, $popts, $useOutdated = true ) { global $wgCacheEpoch; - if( $popts instanceof User ) { + if ( $popts instanceof User ) { wfWarn( "Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" ); $popts = ParserOptions::newFromUser( $popts ); } @@ -227,7 +227,7 @@ class ParserCache { public function save( $parserOutput, $article, $popts ) { $expire = $parserOutput->getCacheExpiry(); - if( $expire > 0 ) { + if ( $expire > 0 ) { $now = wfTimestampNow(); $optionsKey = new CacheTime; diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 3eb83e367e..2bd5a5d2eb 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -538,7 +538,7 @@ class ParserOptions { // add in language specific options, if any // @todo FIXME: This is just a way of retrieving the url/user preferred variant - if( !is_null( $title ) ) { + if ( !is_null( $title ) ) { $confstr .= $title->getPageLanguage()->getExtraHashOptions(); } else { global $wgContLang; @@ -557,8 +557,9 @@ class ParserOptions { $confstr .= '!printable=1'; } - if ( $this->mExtraKey != '' ) + if ( $this->mExtraKey != '' ) { $confstr .= $this->mExtraKey; + } // Give a chance for extensions to modify the hash, if they have // extra options or other effects on the parser cache. diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 3af3b7aca0..c5e42a4d2d 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -176,10 +176,10 @@ class ParserOutput extends CacheTime { global $wgServer, $wgRegisterInternalExternals; $registerExternalLink = true; - if( !$wgRegisterInternalExternals ) { + if ( !$wgRegisterInternalExternals ) { $registerExternalLink = !self::isLinkInternal( $wgServer, $url ); } - if( $registerExternalLink ) { + if ( $registerExternalLink ) { $this->mExternalLinks[$url] = 1; } } @@ -201,11 +201,11 @@ class ParserOutput extends CacheTime { if ( $ns == NS_MEDIA ) { // Normalize this pseudo-alias if it makes it down here... $ns = NS_FILE; - } elseif( $ns == NS_SPECIAL ) { + } elseif ( $ns == NS_SPECIAL ) { // We don't record Special: links currently // It might actually be wise to, but we'd need to do some normalization. return; - } elseif( $dbk === '' ) { + } elseif ( $dbk === '' ) { // Don't record self links - [[#Foo]] return; } @@ -258,7 +258,7 @@ class ParserOutput extends CacheTime { */ function addInterwikiLink( $title ) { $prefix = $title->getInterwiki(); - if( $prefix == '' ) { + if ( $prefix == '' ) { throw new MWException( 'Non-interwiki link passed, internal parser error.' ); } if ( !isset( $this->mInterwikiLinks[$prefix] ) ) { @@ -329,7 +329,7 @@ class ParserOutput extends CacheTime { */ public function getDisplayTitle() { $t = $this->getTitleText(); - if( $t === '' ) { + if ( $t === '' ) { return false; } return $t; diff --git a/includes/parser/Parser_DiffTest.php b/includes/parser/Parser_DiffTest.php index f25340fa72..aeae234ace 100644 --- a/includes/parser/Parser_DiffTest.php +++ b/includes/parser/Parser_DiffTest.php @@ -122,7 +122,7 @@ class Parser_DiffTest function setFunctionHook( $id, $callback, $flags = 0 ) { $this->init(); - foreach ( $this->parsers as $parser ) { + foreach ( $this->parsers as $parser ) { $parser->setFunctionHook( $id, $callback, $flags ); } } diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 1e9092855d..4ea7dd4029 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -577,7 +577,7 @@ class Preprocessor_DOM implements Preprocessor { 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, - 'lineStart' => ($i > 0 && $text[$i - 1] == "\n"), + 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), ); $stack->push( $piece ); @@ -1214,7 +1214,9 @@ class PPFrame_DOM implements PPFrame { $first = true; $s = ''; foreach ( $args as $root ) { - if ( $root instanceof PPNode_DOM ) $root = $root->node; + if ( $root instanceof PPNode_DOM ) { + $root = $root->node; + } if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) { $root = array( $root ); } diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 465c5a6cfe..654a66e797 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -515,7 +515,7 @@ class Preprocessor_Hash implements Preprocessor { 'open' => $curChar, 'close' => $rule['end'], 'count' => $count, - 'lineStart' => ($i > 0 && $text[$i - 1] == "\n"), + 'lineStart' => ( $i > 0 && $text[$i - 1] == "\n" ), ); $stack->push( $piece ); diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index 0f7e0d31b1..e3ea40b0a9 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -158,7 +158,7 @@ class MWTidy { global $wgTidyInternal; $retval = 0; - if( $wgTidyInternal ) { + if ( $wgTidyInternal ) { $errorStr = self::execInternalTidy( $text, true, $retval ); } else { $errorStr = self::execExternalTidy( $text, true, $retval ); diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index e39a7b238b..49d961ef16 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -75,10 +75,10 @@ class Profiler { * @return Profiler */ public static function instance() { - if( is_null( self::$__instance ) ) { + if ( is_null( self::$__instance ) ) { global $wgProfiler; - if( is_array( $wgProfiler ) ) { - if( !isset( $wgProfiler['class'] ) ) { + if ( is_array( $wgProfiler ) ) { + if ( !isset( $wgProfiler['class'] ) ) { wfDebug( __METHOD__ . " called without \$wgProfiler['class']" . " set, falling back to ProfilerStub for safety\n" ); $class = 'ProfilerStub'; @@ -86,7 +86,7 @@ class Profiler { $class = $wgProfiler['class']; } self::$__instance = new $class( $wgProfiler ); - } elseif( $wgProfiler instanceof Profiler ) { + } elseif ( $wgProfiler instanceof Profiler ) { self::$__instance = $wgProfiler; // back-compat } else { wfDebug( __METHOD__ . ' called with bogus $wgProfiler setting,' @@ -157,7 +157,7 @@ class Profiler { */ public function profileIn( $functionname ) { global $wgDebugFunctionEntry; - if( $wgDebugFunctionEntry ) { + if ( $wgDebugFunctionEntry ) { $this->debug( str_repeat( ' ', count( $this->mWorkStack ) ) . 'Entering ' . $functionname . "\n" ); } @@ -174,7 +174,7 @@ class Profiler { $memory = memory_get_usage(); $time = $this->getTime(); - if( $wgDebugFunctionEntry ) { + if ( $wgDebugFunctionEntry ) { $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" ); } @@ -184,12 +184,11 @@ class Profiler { $this->debug( "Profiling error, !\$bit: $functionname\n" ); } else { //if( $wgDebugProfiling ) { - if( $functionname == 'close' ) { + if ( $functionname == 'close' ) { $message = "Profile section ended by close(): {$bit[0]}"; $this->debug( "$message\n" ); $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); - } - elseif( $bit[0] != $functionname ) { + } elseif ( $bit[0] != $functionname ) { $message = "Profiling error: in({$bit[0]}), out($functionname)"; $this->debug( "$message\n" ); $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 ); @@ -205,7 +204,7 @@ class Profiler { * Close opened profiling sections */ public function close() { - while( count( $this->mWorkStack ) ) { + while ( count( $this->mWorkStack ) ) { $this->profileOut( 'close' ); } } @@ -228,11 +227,11 @@ class Profiler { global $wgDebugFunctionEntry, $wgProfileCallTree; $wgDebugFunctionEntry = false; - if( !count( $this->mStack ) && !count( $this->mCollated ) ) { + if ( !count( $this->mStack ) && !count( $this->mCollated ) ) { return "No profiling output\n"; } - if( $wgProfileCallTree ) { + if ( $wgProfileCallTree ) { return $this->getCallTree(); } else { return $this->getFunctionReport(); @@ -254,16 +253,16 @@ class Profiler { * @return array */ function remapCallTree( $stack ) { - if( count( $stack ) < 2 ) { + if ( count( $stack ) < 2 ) { return $stack; } $outputs = array(); - for( $max = count( $stack ) - 1; $max > 0; ) { + for ( $max = count( $stack ) - 1; $max > 0; ) { /* Find all items under this entry */ $level = $stack[$max][1]; $working = array(); - for( $i = $max -1; $i >= 0; $i-- ) { - if( $stack[$i][1] > $level ) { + for ( $i = $max -1; $i >= 0; $i-- ) { + if ( $stack[$i][1] > $level ) { $working[] = $stack[$i]; } else { break; @@ -271,7 +270,7 @@ class Profiler { } $working = $this->remapCallTree( array_reverse( $working ) ); $output = array(); - foreach( $working as $item ) { + foreach ( $working as $item ) { array_push( $output, $item ); } array_unshift( $output, $stack[$max] ); @@ -280,8 +279,8 @@ class Profiler { array_unshift( $outputs, $output ); } $final = array(); - foreach( $outputs as $output ) { - foreach( $output as $item ) { + foreach ( $outputs as $output ) { + foreach ( $output as $item ) { $final[] = $item; } } @@ -391,18 +390,17 @@ class Profiler { # First, subtract the overhead! $overheadTotal = $overheadMemory = $overheadInternal = array(); - foreach( $this->mStack as $entry ) { + foreach ( $this->mStack as $entry ) { $fname = $entry[0]; $start = $entry[2]; $end = $entry[4]; $elapsed = $end - $start; $memory = $entry[5] - $entry[3]; - if( $fname == '-overhead-total' ) { + if ( $fname == '-overhead-total' ) { $overheadTotal[] = $elapsed; $overheadMemory[] = $memory; - } - elseif( $fname == '-overhead-internal' ) { + } elseif ( $fname == '-overhead-internal' ) { $overheadInternal[] = $elapsed; } } @@ -411,7 +409,7 @@ class Profiler { $overheadInternal = $overheadInternal ? array_sum( $overheadInternal ) / count( $overheadInternal ) : 0; # Collate - foreach( $this->mStack as $index => $entry ) { + foreach ( $this->mStack as $index => $entry ) { $fname = $entry[0]; $start = $entry[2]; $end = $entry[4]; @@ -420,16 +418,16 @@ class Profiler { $memory = $entry[5] - $entry[3]; $subcalls = $this->calltreeCount( $this->mStack, $index ); - if( !preg_match( '/^-overhead/', $fname ) ) { + if ( !preg_match( '/^-overhead/', $fname ) ) { # Adjust for profiling overhead (except special values with elapsed=0 - if( $elapsed ) { + if ( $elapsed ) { $elapsed -= $overheadInternal; $elapsed -= ($subcalls * $overheadTotal); $memory -= ($subcalls * $overheadMemory); } } - if( !array_key_exists( $fname, $this->mCollated ) ) { + if ( !array_key_exists( $fname, $this->mCollated ) ) { $this->mCollated[$fname] = 0; $this->mCalls[$fname] = 0; $this->mMemory[$fname] = 0; @@ -467,7 +465,7 @@ class Profiler { $total = isset( $this->mCollated['-total'] ) ? $this->mCollated['-total'] : 0; - foreach( $this->mCollated as $fname => $elapsed ) { + foreach ( $this->mCollated as $fname => $elapsed ) { $calls = $this->mCalls[$fname]; $percent = $total ? 100. * $elapsed / $total : 0; $memory = $this->mMemory[$fname]; @@ -483,7 +481,7 @@ class Profiler { */ protected static function calculateOverhead( $profileCount ) { wfProfileIn( '-overhead-total' ); - for( $i = 0; $i < $profileCount; $i++ ) { + for ( $i = 0; $i < $profileCount; $i++ ) { wfProfileIn( '-overhead-internal' ); wfProfileOut( '-overhead-internal' ); } @@ -515,16 +513,16 @@ class Profiler { global $wgProfilePerHost, $wgProfileToDatabase; # Do not log anything if database is readonly (bug 5375) - if( wfReadOnly() || !$wgProfileToDatabase ) { + if ( wfReadOnly() || !$wgProfileToDatabase ) { return; } $dbw = wfGetDB( DB_MASTER ); - if( !is_object( $dbw ) ) { + if ( !is_object( $dbw ) ) { return; } - if( $wgProfilePerHost ) { + if ( $wgProfilePerHost ) { $pfhost = wfHostname(); } else { $pfhost = ''; @@ -533,7 +531,7 @@ class Profiler { try { $this->collateData(); - foreach( $this->mCollated as $name => $elapsed ) { + foreach ( $this->mCollated as $name => $elapsed ) { $eventCount = $this->mCalls[$name]; $timeSum = (float) ($elapsed * 1000); $memorySum = (float)$this->mMemory[$name]; @@ -585,7 +583,7 @@ class Profiler { * @param string $s to output */ function debug( $s ) { - if( defined( 'MW_COMPILED' ) || function_exists( 'wfDebug' ) ) { + if ( defined( 'MW_COMPILED' ) || function_exists( 'wfDebug' ) ) { wfDebug( $s ); } } diff --git a/includes/profiler/ProfilerSimpleUDP.php b/includes/profiler/ProfilerSimpleUDP.php index 1cf4fa7c23..83bdf71eb9 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/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 5919cde518..861ff18c29 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -52,7 +52,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { */ $namespaceIds = $wgContLang->getNamespaceIds(); $caseSensitiveNamespaces = array(); - foreach( MWNamespace::getCanonicalNamespaces() as $index => $name ) { + foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) { $namespaceIds[$wgContLang->lc( $name )] = $index; if ( !MWNamespace::isCapitalized( $index ) ) { $caseSensitiveNamespaces[] = $index; diff --git a/includes/resourceloader/ResourceLoaderUserGroupsModule.php b/includes/resourceloader/ResourceLoaderUserGroupsModule.php index 7586bb7fac..9064263fef 100644 --- a/includes/resourceloader/ResourceLoaderUserGroupsModule.php +++ b/includes/resourceloader/ResourceLoaderUserGroupsModule.php @@ -54,7 +54,7 @@ class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule { } $pages = array(); - foreach( $user->getEffectiveGroups() as $group ) { + foreach ( $user->getEffectiveGroups() as $group ) { if ( in_array( $group, array( '*', 'user' ) ) ) { continue; } diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index d2ce0b7bd8..ac722769b8 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -52,7 +52,7 @@ class RevDel_RevisionList extends RevDel_List { array_merge( Revision::selectFields(), Revision::selectUserFields() ), array( 'rev_page' => $this->title->getArticleID(), - 'rev_id' => $ids, + 'rev_id' => $ids, ), __METHOD__, array( 'ORDER BY' => 'rev_id DESC' ), @@ -292,7 +292,7 @@ class RevDel_ArchiveList extends RevDel_RevisionList { return $db->select( 'archive', '*', array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey(), + 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps ), __METHOD__, @@ -349,12 +349,12 @@ class RevDel_ArchiveItem extends RevDel_RevisionItem { $dbw->update( 'archive', array( 'ar_deleted' => $bits ), array( - 'ar_namespace' => $this->list->title->getNamespace(), - 'ar_title' => $this->list->title->getDBkey(), + 'ar_namespace' => $this->list->title->getNamespace(), + 'ar_title' => $this->list->title->getDBkey(), // use timestamp for index - 'ar_timestamp' => $this->row->ar_timestamp, - 'ar_rev_id' => $this->row->ar_rev_id, - 'ar_deleted' => $this->getBits() + 'ar_timestamp' => $this->row->ar_timestamp, + 'ar_rev_id' => $this->row->ar_rev_id, + 'ar_deleted' => $this->getBits() ), __METHOD__ ); return (bool)$dbw->affectedRows(); @@ -449,14 +449,14 @@ class RevDel_FileList extends RevDel_List { */ public function doQuery( $db ) { $archiveNames = array(); - foreach( $this->ids as $timestamp ) { + foreach ( $this->ids as $timestamp ) { $archiveNames[] = $timestamp . '!' . $this->title->getDBkey(); } return $db->select( 'oldimage', OldLocalFile::selectFields(), array( - 'oi_name' => $this->title->getDBkey(), + 'oi_name' => $this->title->getDBkey(), 'oi_archive_name' => $archiveNames ), __METHOD__, @@ -623,8 +623,8 @@ class RevDel_FileItem extends RevDel_Item { array(), array( 'target' => $this->list->title->getPrefixedText(), - 'file' => $this->file->getArchiveName(), - 'token' => $this->list->getUser()->getEditToken( + 'file' => $this->file->getArchiveName(), + 'token' => $this->list->getUser()->getEditToken( $this->file->getArchiveName() ) ) ); @@ -636,13 +636,13 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getUserTools() { - if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { + if ( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) { $link = Linker::userLink( $this->file->user, $this->file->user_text ) . Linker::userToolLinks( $this->file->user, $this->file->user_text ); } else { $link = $this->list->msg( 'rev-deleted-user' )->escaped(); } - if( $this->file->isDeleted( Revision::DELETED_USER ) ) { + if ( $this->file->isDeleted( Revision::DELETED_USER ) ) { return '' . $link . ''; } return $link; @@ -655,12 +655,12 @@ class RevDel_FileItem extends RevDel_Item { * @return string HTML */ protected function getComment() { - if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { + if ( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) { $block = Linker::commentBlock( $this->file->description ); } else { $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped(); } - if( $this->file->isDeleted( File::DELETED_COMMENT ) ) { + if ( $this->file->isDeleted( File::DELETED_COMMENT ) ) { return "$block"; } return $block; @@ -700,7 +700,7 @@ class RevDel_ArchivedFileList extends RevDel_FileList { ArchivedFile::selectFields(), array( 'fa_name' => $this->title->getDBkey(), - 'fa_id' => $ids + 'fa_id' => $ids ), __METHOD__, array( 'ORDER BY' => 'fa_id DESC' ) @@ -759,7 +759,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { $this->file->getTimestamp(), $this->list->getUser() ) ); # Hidden files... - if( !$this->canViewContent() ) { + if ( !$this->canViewContent() ) { $link = $date; } else { $undelete = SpecialPage::getTitleFor( 'Undelete' ); @@ -772,7 +772,7 @@ class RevDel_ArchivedFileItem extends RevDel_FileItem { ) ); } - if( $this->isDeleted() ) { + if ( $this->isDeleted() ) { $link = '' . $link . ''; } return $link; @@ -901,7 +901,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/revisiondelete/RevisionDeleteAbstracts.php b/includes/revisiondelete/RevisionDeleteAbstracts.php index fcbec9e891..9ace35a8b6 100644 --- a/includes/revisiondelete/RevisionDeleteAbstracts.php +++ b/includes/revisiondelete/RevisionDeleteAbstracts.php @@ -94,14 +94,14 @@ abstract class RevDel_List extends RevisionListBase { } if ( !$item->canView() ) { // Cannot access this revision - $msg = ($opType == 'show') ? + $msg = ( $opType == 'show' ) ? 'revdelete-show-no-access' : 'revdelete-modify-no-access'; $status->error( $msg, $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; } // Cannot just "hide from Sysops" without hiding any fields - if( $newBits == Revision::DELETED_RESTRICTED ) { + if ( $newBits == Revision::DELETED_RESTRICTED ) { $status->warning( 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; @@ -113,9 +113,9 @@ abstract class RevDel_List extends RevisionListBase { if ( $ok ) { $idsForLog[] = $item->getId(); $status->successCount++; - if( $item->getAuthorId() > 0 ) { + if ( $item->getAuthorId() > 0 ) { $authorIds[] = $item->getAuthorId(); - } elseif( IP::isIPAddress( $item->getAuthorName() ) ) { + } elseif ( IP::isIPAddress( $item->getAuthorName() ) ) { $authorIPs[] = $item->getAuthorName(); } } else { @@ -189,7 +189,7 @@ abstract class RevDel_List extends RevisionListBase { protected function updateLog( $params ) { // Get the URL param's corresponding DB field $field = RevisionDeleter::getRelationType( $this->getType() ); - if( !$field ) { + if ( !$field ) { throw new MWException( "Bad log URL param type!" ); } // Put things hidden from sysops in the oversight log diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php index c02e9c7608..4505ee10c2 100644 --- a/includes/revisiondelete/RevisionDeleteUser.php +++ b/includes/revisiondelete/RevisionDeleteUser.php @@ -54,7 +54,7 @@ class RevisionDeleteUser { # The same goes for the sysop-restricted *_deleted bit. $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; $delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED; - if( $op == '&' ) { + if ( $op == '&' ) { $delUser = "~{$delUser}"; $delAction = "~{$delAction}"; } diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index d2e10e1a27..2de19acf39 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -39,7 +39,7 @@ class RevisionDeleter { * @param array $arr the array to update. */ protected static function checkItem( $desc, $field, $diff, $new, &$arr ) { - if( $diff & $field ) { + if ( $diff & $field ) { $arr[( $new & $field ) ? 0 : 1][] = $desc; } } @@ -73,11 +73,12 @@ class RevisionDeleter { self::checkItem( 'revdelete-uname', Revision::DELETED_USER, $diff, $n, $ret ); // Restriction application to sysops - if( $diff & Revision::DELETED_RESTRICTED ) { - if( $n & Revision::DELETED_RESTRICTED ) + if ( $diff & Revision::DELETED_RESTRICTED ) { + if ( $n & Revision::DELETED_RESTRICTED ) { $ret[2][] = 'revdelete-restricted'; - else + } else { $ret[2][] = 'revdelete-unrestricted'; + } } return $ret; } diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index cfd941a324..de9e99cdf9 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -331,8 +331,9 @@ class SearchEngine { $parsed = substr( $query, strlen( $prefix ) + 1 ); } } - if ( trim( $parsed ) == '' ) + if ( trim( $parsed ) == '' ) { $parsed = $query; // prefix was the whole query + } wfRunHooks( 'SearchEngineReplacePrefixesComplete', array( $this, $query, &$parsed ) ); @@ -420,8 +421,9 @@ class SearchEngine { $formatted = array_map( array( $wgContLang, 'getFormattedNsText' ), $namespaces ); foreach ( $formatted as $key => $ns ) { - if ( empty( $ns ) ) + if ( empty( $ns ) ) { $formatted[$key] = wfMessage( 'blanknamespace' )->text(); + } } return $formatted; } @@ -641,26 +643,30 @@ class SqlSearchResultSet extends SearchResultSet { } function numRows() { - if ( $this->mResultSet === false ) + if ( $this->mResultSet === false ) { return false; + } return $this->mResultSet->numRows(); } function next() { - if ( $this->mResultSet === false ) + if ( $this->mResultSet === false ) { return false; + } $row = $this->mResultSet->fetchObject(); - if ( $row === false ) + if ( $row === false ) { return false; + } return SearchResult::newFromRow( $row ); } function free() { - if ( $this->mResultSet === false ) + if ( $this->mResultSet === false ) { return false; + } $this->mResultSet->free(); } @@ -750,8 +756,9 @@ class SearchResult { wfRunHooks( 'SearchResultInitFromTitle', array( $title, &$id ) ); $this->mRevision = Revision::newFromTitle( $this->mTitle, $id, Revision::READ_NORMAL ); - if ( $this->mTitle->getNamespace() === NS_FILE ) + if ( $this->mTitle->getNamespace() === NS_FILE ) { $this->mImage = wfFindFile( $this->mTitle ); + } } } @@ -761,8 +768,9 @@ class SearchResult { * @return Boolean */ function isBrokenTitle() { - if ( is_null( $this->mTitle ) ) + if ( is_null( $this->mTitle ) ) { return true; + } return false; } @@ -816,10 +824,11 @@ class SearchResult { // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter. list( $contextlines, $contextchars ) = SearchEngine::userHighlightPrefs( $wgUser ); $h = new SearchHighlighter(); - if ( $wgAdvancedSearchHighlighting ) + if ( $wgAdvancedSearchHighlighting ) { return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars ); - else + } else { return $h->highlightSimple( $this->mText, $terms, $contextlines, $contextchars ); + } } /** @@ -863,10 +872,11 @@ class SearchResult { * @return String: timestamp */ function getTimestamp() { - if ( $this->mRevision ) + if ( $this->mRevision ) { return $this->mRevision->getTimestamp(); - elseif ( $this->mImage ) + } elseif ( $this->mImage ) { return $this->mImage->getTimestamp(); + } return ''; } @@ -952,8 +962,9 @@ class SearchHighlighter { global $wgSearchHighlightBoundaries; $fname = __METHOD__; - if ( $text == '' ) + if ( $text == '' ) { return ''; + } // spli text into text + templates/links/tables $spat = "/(\\{\\{)|(\\[\\[[^\\]:]+:)|(\n\\{\\|)"; @@ -984,8 +995,9 @@ class SearchHighlighter { if ( $key == 2 ) { // see if this is an image link $ns = substr( $val[0], 2, - 1 ); - if ( $wgContLang->getNsIndex( $ns ) != NS_FILE ) + if ( $wgContLang->getNsIndex( $ns ) != NS_FILE ) { break; + } } $epat = $endPatterns[$key]; @@ -1155,17 +1167,19 @@ class SearchHighlighter { $last = - 1; $extract = ''; foreach ( $snippets as $index => $line ) { - if ( $last == - 1 ) + if ( $last == - 1 ) { $extract .= $line; // first line - elseif ( $last + 1 == $index && $offsets[$last] + strlen( $snippets[$last] ) >= strlen( $all[$last] ) ) + } elseif ( $last + 1 == $index && $offsets[$last] + strlen( $snippets[$last] ) >= strlen( $all[$last] ) ) { $extract .= " " . $line; // continous lines - else + } else { $extract .= ' ... ' . $line; + } $last = $index; } - if ( $extract ) + if ( $extract ) { $extract .= ' ... '; + } $processed = array(); foreach ( $terms as $term ) { @@ -1193,8 +1207,9 @@ class SearchHighlighter { $split = explode( "\n", $this->mCleanWikitext ? $this->removeWiki( $text ) : $text ); foreach ( $split as $line ) { $tt = trim( $line ); - if ( $tt ) + if ( $tt ) { $extracts[$count++] = $tt; + } } } @@ -1268,8 +1283,9 @@ class SearchHighlighter { while ( $char >= 0x80 && $char < 0xc0 ) { // skip trailing bytes $point++; - if ( $point >= strlen( $text ) ) + if ( $point >= strlen( $text ) ) { return strlen( $text ); + } $char = ord( $text[$point] ); } return $point; @@ -1289,24 +1305,28 @@ class SearchHighlighter { * @protected */ function process( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets ) { - if ( $linesleft == 0 ) + if ( $linesleft == 0 ) { return; // nothing to do + } foreach ( $extracts as $index => $line ) { - if ( array_key_exists( $index, $out ) ) + if ( array_key_exists( $index, $out ) ) { continue; // this line already highlighted + } $m = array(); - if ( !preg_match( $pattern, $line, $m, PREG_OFFSET_CAPTURE ) ) + if ( !preg_match( $pattern, $line, $m, PREG_OFFSET_CAPTURE ) ) { continue; + } $offset = $m[0][1]; $len = strlen( $m[0][0] ); - if ( $offset + $len < $contextchars ) + if ( $offset + $len < $contextchars ) { $begin = 0; - elseif ( $len > $contextchars ) + } elseif ( $len > $contextchars ) { $begin = $offset; - else + } else { $begin = $offset + intval( ( $len - $contextchars ) / 2 ); + } $end = $begin + $contextchars; @@ -1315,8 +1335,9 @@ class SearchHighlighter { $out[$index] = $this->extract( $line, $begin, $end, $posBegin ); $offsets[$index] = $posBegin; $linesleft--; - if ( $linesleft == 0 ) + if ( $linesleft == 0 ) { return; + } } } @@ -1357,16 +1378,17 @@ class SearchHighlighter { */ function linkReplace( $matches ) { $colon = strpos( $matches[1], ':' ); - if ( $colon === false ) + if ( $colon === false ) { return $matches[2]; // replace with caption + } global $wgContLang; $ns = substr( $matches[1], 0, $colon ); $index = $wgContLang->getNsIndex( $ns ); - if ( $index !== false && ( $index == NS_FILE || $index == NS_CATEGORY ) ) + if ( $index !== false && ( $index == NS_FILE || $index == NS_CATEGORY ) ) { return $matches[0]; // return the whole thing - else + } else { return $matches[2]; - + } } /** diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index 163d9dc3d7..cbc1a7a7f1 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -170,8 +170,9 @@ class SearchMssql extends SearchEngine { 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] ), '/' ); } @@ -247,8 +248,9 @@ class MssqlSearchResultSet extends SearchResultSet { function next() { $row = $this->mResultSet->fetchObject(); - if ( $row === false ) + if ( $row === false ) { return false; + } return new SearchResult( $row ); } } diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index ddfd1b3049..f63931dc44 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -57,12 +57,12 @@ class SearchMySQL extends SearchEngine { # @todo FIXME: This doesn't handle parenthetical expressions. $m = array(); - if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { - foreach( $m as $bits ) { + foreach ( $m as $bits ) { @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - if( $nonQuoted != '' ) { + if ( $nonQuoted != '' ) { $term = $nonQuoted; $quote = ''; } else { @@ -70,8 +70,10 @@ class SearchMySQL extends SearchEngine { $quote = '"'; } - if( $searchon !== '' ) $searchon .= ' '; - if( $this->strictMatching && ($modifier == '') ) { + if ( $searchon !== '' ) { + $searchon .= ' '; + } + if ( $this->strictMatching && ( $modifier == '' ) ) { // If we leave this out, boolean op defaults to OR which is rarely helpful. $modifier = '+'; } @@ -79,7 +81,7 @@ class SearchMySQL extends SearchEngine { // Some languages such as Serbian store the input form in the search index, // so we may need to search for matches in multiple writing system variants. $convertedVariants = $wgContLang->autoConvertToAllVariants( $term ); - if( is_array( $convertedVariants ) ) { + if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { $variants = array( $term ); @@ -99,11 +101,12 @@ class SearchMySQL extends SearchEngine { $strippedVariants = array_unique( $strippedVariants ); $searchon .= $modifier; - if( count( $strippedVariants ) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= '('; - foreach( $strippedVariants as $stripped ) { + } + foreach ( $strippedVariants as $stripped ) { $stripped = $this->normalizeText( $stripped ); - if( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { + if ( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { // Hack for Chinese: we need to toss in quotes for // multiple-character phrases since normalizeForSearch() // added spaces between them to make word breaks. @@ -111,8 +114,9 @@ class SearchMySQL extends SearchEngine { } $searchon .= "$quote$stripped$quote$wildcard "; } - if( count( $strippedVariants ) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= ')'; + } // Match individual terms or quoted phrase in result highlighting... // Note that variants will be introduced in a later stage for highlighting! @@ -134,8 +138,8 @@ class SearchMySQL extends SearchEngine { global $wgContLang; $regex = preg_quote( $string, '/' ); - if( $wgContLang->hasWordBreaks() ) { - if( $wildcard ) { + if ( $wgContLang->hasWordBreaks() ) { + if ( $wildcard ) { // Don't cut off the final bit! $regex = "\b$regex"; } else { @@ -177,7 +181,9 @@ class SearchMySQL extends SearchEngine { global $wgCountTotalSearchHits; // This seems out of place, why is this called with empty term? - if ( trim( $term ) === '' ) return null; + if ( trim( $term ) === '' ) { + return null; + } $filteredTerm = $this->filter( $term ); $query = $this->getQuery( $filteredTerm, $fulltext ); @@ -187,7 +193,7 @@ class SearchMySQL extends SearchEngine { ); $total = null; - if( $wgCountTotalSearchHits ) { + if ( $wgCountTotalSearchHits ) { $query = $this->getCountQuery( $filteredTerm, $fulltext ); $totalResult = $this->db->select( $query['tables'], $query['fields'], $query['conds'], @@ -195,7 +201,7 @@ class SearchMySQL extends SearchEngine { ); $row = $totalResult->fetchObject(); - if( $row ) { + if ( $row ) { $total = intval( $row->c ); } $totalResult->free(); @@ -223,7 +229,7 @@ class SearchMySQL extends SearchEngine { foreach ( $this->features as $feature => $value ) { if ( $feature === 'list-redirects' && !$value ) { $query['conds']['page_is_redirect'] = 0; - } elseif( $feature === 'title-suffix-filter' && $value ) { + } elseif ( $feature === 'title-suffix-filter' && $value ) { $query['conds'][] = 'page_title' . $this->db->buildLike( $this->db->anyString(), $value ); } } @@ -358,7 +364,7 @@ class SearchMySQL extends SearchEngine { $dbw->update( 'searchindex', array( 'si_title' => $this->normalizeText( $title ) ), - array( 'si_page' => $id ), + array( 'si_page' => $id ), __METHOD__, array( $dbw->lowPriorityOption() ) ); } @@ -386,7 +392,7 @@ class SearchMySQL extends SearchEngine { // ignores short words... Pad them so we can pass them // through without reconfiguring the server... $minLength = $this->minSearchLength(); - if( $minLength > 1 ) { + if ( $minLength > 1 ) { $n = $minLength - 1; $out = preg_replace( "/\b(\w{1,$n})\b/", @@ -427,7 +433,7 @@ class SearchMySQL extends SearchEngine { * @return int */ protected function minSearchLength() { - if( is_null( self::$mMinSearchLength ) ) { + if ( is_null( self::$mMinSearchLength ) ) { $sql = "SHOW GLOBAL VARIABLES LIKE 'ft\\_min\\_word\\_len'"; $dbr = wfGetDB( DB_SLAVE ); @@ -435,7 +441,7 @@ class SearchMySQL extends SearchEngine { $row = $result->fetchObject(); $result->free(); - if( $row && $row->Variable_name == 'ft_min_word_len' ) { + if ( $row && $row->Variable_name == 'ft_min_word_len' ) { self::$mMinSearchLength = intval( $row->Value ); } else { self::$mMinSearchLength = 0; diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index dd152f7341..a84796542f 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -74,8 +74,9 @@ class SearchOracle extends SearchEngine { * @return SqlSearchResultSet */ function searchText( $term ) { - if ( $term == '' ) + 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 ); @@ -88,8 +89,9 @@ class SearchOracle extends SearchEngine { * @return SqlSearchResultSet */ function searchTitle( $term ) { - if ( $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 ); @@ -112,8 +114,9 @@ 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'; } else { @@ -197,23 +200,24 @@ class SearchOracle extends SearchEngine { $searchon = ''; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { - foreach( $m as $terms ) { + foreach ( $m as $terms ) { // Search terms in all variant forms, only // apply on wiki with LanguageConverter $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] ); - if( is_array( $temp_terms ) ) { + if ( is_array( $temp_terms ) ) { $temp_terms = array_unique( array_values( $temp_terms ) ); - foreach( $temp_terms as $t ) { - $searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $t ); + foreach ( $temp_terms as $t ) { + $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $t ); } } else { - $searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $terms[2] ); + $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $terms[2] ); } 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] ), '/' ); } @@ -275,7 +279,7 @@ class SearchOracle extends SearchEngine { $dbw->update( 'searchindex', array( 'si_title' => $title ), - array( 'si_page' => $id ), + array( 'si_page' => $id ), 'SearchOracle::updateTitle', array() ); } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 148a657492..2fe31c9ec9 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -97,8 +97,8 @@ class SearchPostgres extends SearchEngine { $searchstring = ''; $m = array(); - if( preg_match_all( '/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) { - foreach( $m as $terms ) { + if ( preg_match_all( '/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) { + foreach ( $m as $terms ) { if ( strlen( $terms[1] ) ) { $searchstring .= ' & !'; } @@ -169,8 +169,8 @@ class SearchPostgres extends SearchEngine { } else { $m = array(); - if( preg_match_all( "/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) { - foreach( $m as $terms ) { + if ( preg_match_all( "/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) { + foreach ( $m as $terms ) { $this->searchTerms[$terms[1]] = $terms[1]; } } @@ -182,11 +182,12 @@ class SearchPostgres extends SearchEngine { } ## Redirects - if ( !$this->showRedirects ) + if ( !$this->showRedirects ) { $query .= ' AND page_is_redirect = 0'; + } ## Namespaces - defaults to 0 - if( !is_null( $this->namespaces ) ) { // null -> search all + if ( !is_null( $this->namespaces ) ) { // null -> search all if ( count( $this->namespaces ) < 1 ) { $query .= ' AND page_namespace = 0'; } else { @@ -244,7 +245,7 @@ class PostgresSearchResultSet extends SqlSearchResultSet { function next() { $row = $this->mResultSet->fetchObject(); - if( $row === false ) { + if ( $row === false ) { return false; } else { return new PostgresSearchResult( $row ); diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index 5b0b7f7e76..71fd021fc1 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -61,12 +61,12 @@ class SearchSqlite extends SearchEngine { $this->searchTerms = array(); $m = array(); - if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { - foreach( $m as $bits ) { + foreach ( $m as $bits ) { @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - if( $nonQuoted != '' ) { + if ( $nonQuoted != '' ) { $term = $nonQuoted; $quote = ''; } else { @@ -74,14 +74,14 @@ class SearchSqlite extends SearchEngine { $quote = '"'; } - if( $searchon !== '' ) { + if ( $searchon !== '' ) { $searchon .= ' '; } // Some languages such as Serbian store the input form in the search index, // so we may need to search for matches in multiple writing system variants. $convertedVariants = $wgContLang->autoConvertToAllVariants( $term ); - if( is_array( $convertedVariants ) ) { + if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { $variants = array( $term ); @@ -101,10 +101,11 @@ class SearchSqlite extends SearchEngine { $strippedVariants = array_unique( $strippedVariants ); $searchon .= $modifier; - if( count( $strippedVariants ) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= '('; - foreach( $strippedVariants as $stripped ) { - if( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { + } + foreach ( $strippedVariants as $stripped ) { + if ( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { // Hack for Chinese: we need to toss in quotes for // multiple-character phrases since normalizeForSearch() // added spaces between them to make word breaks. @@ -112,8 +113,9 @@ class SearchSqlite extends SearchEngine { } $searchon .= "$quote$stripped$quote$wildcard "; } - if( count( $strippedVariants ) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= ')'; + } // Match individual terms or quoted phrase in result highlighting... // Note that variants will be introduced in a later stage for highlighting! @@ -134,8 +136,8 @@ class SearchSqlite extends SearchEngine { global $wgContLang; $regex = preg_quote( $string, '/' ); - if( $wgContLang->hasWordBreaks() ) { - if( $wildcard ) { + if ( $wgContLang->hasWordBreaks() ) { + if ( $wildcard ) { // Don't cut off the final bit! $regex = "\b$regex"; } else { @@ -184,10 +186,10 @@ class SearchSqlite extends SearchEngine { $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) ); $total = null; - if( $wgCountTotalSearchHits ) { + if ( $wgCountTotalSearchHits ) { $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, $fulltext ) ); $row = $totalResult->fetchObject(); - if( $row ) { + if ( $row ) { $total = intval( $row->c ); } $totalResult->free(); @@ -201,7 +203,7 @@ class SearchSqlite extends SearchEngine { * @return String */ function queryRedirect() { - if( $this->showRedirects ) { + if ( $this->showRedirects ) { return ''; } else { return 'AND page_is_redirect=0'; @@ -213,8 +215,9 @@ 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'; } else { @@ -324,7 +327,7 @@ class SearchSqlite extends SearchEngine { $dbw->update( 'searchindex', array( 'si_title' => $title ), - array( 'rowid' => $id ), + array( 'rowid' => $id ), __METHOD__ ); } } diff --git a/includes/search/SearchUpdate.php b/includes/search/SearchUpdate.php index 35199d6abc..8c1bda21a8 100644 --- a/includes/search/SearchUpdate.php +++ b/includes/search/SearchUpdate.php @@ -40,7 +40,7 @@ class SearchUpdate implements DeferrableUpdate { $nt = $title; } - if( $nt ) { + if ( $nt ) { $this->mId = $id; $this->mText = $text; @@ -56,7 +56,7 @@ class SearchUpdate implements DeferrableUpdate { function doUpdate() { global $wgContLang, $wgDisableSearchUpdate; - if( $wgDisableSearchUpdate || !$this->mId ) { + if ( $wgDisableSearchUpdate || !$this->mId ) { return; } @@ -65,7 +65,7 @@ class SearchUpdate implements DeferrableUpdate { $search = SearchEngine::create(); $lc = SearchEngine::legalSearchChars() . '&#;'; - if( $this->mText === false ) { + if ( $this->mText === false ) { $search->updateTitle( $this->mId, $search->normalizeText( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) ); wfProfileOut( __METHOD__ ); -- 2.20.1