From b4cee86beb9fd88563a1de4184c41053ace34d99 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Sat, 12 Feb 2011 04:06:22 +0000 Subject: [PATCH] w/s fixups --- includes/Article.php | 4 +- includes/ConfEditor.php | 66 +++++++++--------- includes/DefaultSettings.php | 50 +++++++------- includes/EditPage.php | 58 ++++++++-------- includes/LinkCache.php | 4 +- includes/QueryPage.php | 4 +- includes/SpecialPage.php | 2 +- includes/Title.php | 43 ++++++------ includes/WatchlistEditor.php | 2 +- includes/diff/DifferenceEngine.php | 4 +- includes/installer/DatabaseInstaller.php | 10 +-- includes/installer/WebInstallerPage.php | 1 + includes/job/UploadFromUrlJob.php | 54 +++++++-------- includes/libs/JavaScriptDistiller.php | 74 ++++++++++----------- includes/parser/CoreLinkFunctions.php | 4 +- includes/parser/LinkHolderArray.php | 6 +- includes/parser/Preprocessor_DOM.php | 28 ++++---- includes/specials/SpecialRevisiondelete.php | 18 ++--- languages/Language.php | 4 +- tests/phpunit/includes/api/ApiQueryTest.php | 40 +++++------ 20 files changed, 239 insertions(+), 237 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 48516e5f12..82bef47720 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1765,7 +1765,7 @@ class Article { * * @param $dbw DatabaseBase: object * @param $revision Revision: For ID number, and text used to set - length and redirect status fields + length and redirect status fields * @param $lastRevision Integer: if given, will not overwrite the page field * when different from the currently set value. * Giving 0 indicates the new page flag should be set @@ -4403,7 +4403,7 @@ class Article { $parserOptions = new ParserOptions( $user ); $parserOptions->setTidy( true ); $parserOptions->enableLimitReport(); - + if ( $canonical ) { $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely return $parserOptions; diff --git a/includes/ConfEditor.php b/includes/ConfEditor.php index b08b77df22..c9fd2079da 100644 --- a/includes/ConfEditor.php +++ b/includes/ConfEditor.php @@ -1,6 +1,6 @@ 'delete', 'path' => '$foo/bar/baz' ) * is equivalent to the runtime PHP code: * unset( $foo['bar']['baz'] ); * * set - * Sets the value of an array element. If the element doesn't exist, it - * is appended to the array. If it does exist, the value is set, with + * Sets the value of an array element. If the element doesn't exist, it + * is appended to the array. If it does exist, the value is set, with * comments and indenting preserved. * * append * Appends a new element to the end of the array. Adds a trailing comma. * e.g. - * array( 'type' => 'append', 'path', '$foo/bar', + * array( 'type' => 'append', 'path', '$foo/bar', * 'key' => 'baz', 'value' => "'x'" ) * is like the PHP code: * $foo['bar']['baz'] = 'x'; @@ -187,7 +187,7 @@ class ConfEditor { list( $indent, ) = $this->getIndent( $start ); $textToInsert = "$indent$value,"; } else { - list( $indent, $arrowIndent ) = + list( $indent, $arrowIndent ) = $this->getIndent( $start, $key, $lastEltInfo['arrowByte'] ); $textToInsert = "$indent$key$arrowIndent=> $value,"; } @@ -210,7 +210,7 @@ class ConfEditor { list( $indent, ) = $this->getIndent( $start ); $textToInsert = "$indent$value,"; } else { - list( $indent, $arrowIndent ) = + list( $indent, $arrowIndent ) = $this->getIndent( $start, $key, $info['arrowByte'] ); $textToInsert = "$indent$key$arrowIndent=> $value,"; } @@ -239,13 +239,13 @@ class ConfEditor { try { $this->parse(); } catch ( ConfEditorParseError $e ) { - throw new MWException( + throw new MWException( "Sorry, ConfEditor broke the file during editing and it won't parse anymore: " . $e->getMessage() ); } return $out; } - + /** * Get the variables defined in the text * @return array( varname => value ) @@ -266,7 +266,7 @@ class ConfEditor { strlen( $trimmedPath ) - strlen( $name ) ); if( substr( $parentPath, -1 ) == '/' ) $parentPath = substr( $parentPath, 0, -1 ); - + $value = substr( $this->text, $data['valueStartByte'], $data['valueEndByte'] - $data['valueStartByte'] ); @@ -275,7 +275,7 @@ class ConfEditor { } return $vars; } - + /** * Set a value in an array, unless it's set already. For instance, * setVar( $arr, 'foo/bar', 'baz', 3 ); will set @@ -298,7 +298,7 @@ class ConfEditor { if ( !isset( $target[$key] ) ) $target[$key] = $value; } - + /** * Parse a scalar value in PHP * @return mixed Parsed value @@ -364,8 +364,8 @@ class ConfEditor { } /** - * Finds the source byte region which you would want to delete, if $pathName - * was to be deleted. Includes the leading spaces and tabs, the trailing line + * Finds the source byte region which you would want to delete, if $pathName + * was to be deleted. Includes the leading spaces and tabs, the trailing line * break, and any comments in between. */ function findDeletionRegion( $pathName ) { @@ -419,9 +419,9 @@ class ConfEditor { } /** - * Find the byte region in the source corresponding to the value part. - * This includes the quotes, but does not include the trailing comma - * or semicolon. + * Find the byte region in the source corresponding to the value part. + * This includes the quotes, but does not include the trailing comma + * or semicolon. * * The end position is the past-the-end (end + 1) value as per convention. */ @@ -519,7 +519,7 @@ class ConfEditor { } /** - * Run the parser on the text. Throws an exception if the string does not + * Run the parser on the text. Throws an exception if the string does not * match our defined subset of PHP syntax. */ public function parse() { @@ -706,7 +706,7 @@ class ConfEditor { } /** - * Set the parse position. Do not call this except from firstToken() and + * Set the parse position. Do not call this except from firstToken() and * nextToken(), there is more to update than just the position. */ protected function setPos( $pos ) { @@ -800,7 +800,7 @@ class ConfEditor { if ( $this->currentToken && $this->currentToken->type == $type ) { return $this->nextToken(); } else { - $this->error( "expected " . $this->getTypeName( $type ) . + $this->error( "expected " . $this->getTypeName( $type ) . ", got " . $this->getTypeName( $this->currentToken->type ) ); } } @@ -875,7 +875,7 @@ class ConfEditor { } /** - * Go to the next path on the same level. This ends the current path and + * Go to the next path on the same level. This ends the current path and * starts a new one. If $path is \@next, the new path is set to the next * numeric array element. */ @@ -889,7 +889,7 @@ class ConfEditor { } else { $this->pathStack[$i]['name'] = $path; } - $this->pathStack[$i] = + $this->pathStack[$i] = array( 'startByte' => $this->byteNum, 'startToken' => $this->pos, @@ -955,8 +955,8 @@ class ConfEditor { } /** - * Looks ahead to see if the given type is the next token type, starting - * from the current position plus the given offset. Skips any intervening + * Looks ahead to see if the given type is the next token type, starting + * from the current position plus the given offset. Skips any intervening * whitespace. */ function isAhead( $type, $offset = 0 ) { @@ -992,8 +992,8 @@ class ConfEditor { $out = ''; foreach ( $this->tokens as $token ) { $obj = $this->newTokenObj( $token ); - $out .= sprintf( "%-28s %s\n", - $this->getTypeName( $obj->type ), + $out .= sprintf( "%-28s %s\n", + $this->getTypeName( $obj->type ), addcslashes( $obj->text, "\0..\37" ) ); } echo "
" . htmlspecialchars( $out ) . "
"; @@ -1008,7 +1008,7 @@ class ConfEditorParseError extends MWException { function __construct( $editor, $msg ) { $this->lineNum = $editor->lineNum; $this->colNum = $editor->colNum; - parent::__construct( "Parse error on line {$editor->lineNum} " . + parent::__construct( "Parse error on line {$editor->lineNum} " . "col {$editor->colNum}: $msg" ); } @@ -1028,7 +1028,7 @@ class ConfEditorParseError extends MWException { */ class ConfEditorToken { var $type, $text; - + static $scalarTypes = array( T_LNUMBER, T_DNUMBER, T_STRING, T_CONSTANT_ENCAPSED_STRING ); static $skipTypes = array( T_WHITESPACE, T_COMMENT, T_DOC_COMMENT ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8a84e7f641..a05259cc7e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -443,11 +443,11 @@ $wgAllowCopyUploads = false; $wgAllowAsyncCopyUploads = false; /** - * Max size for uploads, in bytes. If not set to an array, applies to all + * Max size for uploads, in bytes. If not set to an array, applies to all * uploads. If set to an array, per upload type maximums can be set, using the * file and url keys. If the * key is set this value will be used as maximum * for non-specified types. - * + * * For example: * $wgUploadSize = array( * '*' => 250 * 1024, @@ -455,7 +455,7 @@ $wgAllowAsyncCopyUploads = false; * ); * Sets the maximum for all uploads to 250 kB except for upload-by-url, which * will have a maximum of 500 kB. - * + * */ $wgMaxUploadSize = 1024*1024*100; # 100MB @@ -559,7 +559,7 @@ $wgMimeTypeBlacklist = array( # MS Office OpenXML and other Open Package Conventions files are zip files # and thus blacklisted just as other zip files. If you remove these entries # from the blacklist in your local configuration, a malicious file upload - # will be able to compromise the wiki's user accounts, and the user + # will be able to compromise the wiki's user accounts, and the user # accounts of any other website in the same cookie domain. 'application/x-opc+zip', 'application/msword', @@ -1697,9 +1697,9 @@ $wgClockSkewFudge = 5; * to setting $wgCacheEpoch to the modification time of LocalSettings.php, as * was previously done in the default LocalSettings.php file. * - * On high-traffic wikis, this should be set to false, to avoid the need to + * On high-traffic wikis, this should be set to false, to avoid the need to * check the file modification time, and to avoid the performance impact of - * unnecessary cache invalidations. + * unnecessary cache invalidations. */ $wgInvalidateCacheOnLocalSettingsChange = true; @@ -2293,7 +2293,7 @@ $wgEnableTooltipsAndAccesskeys = true; $wgBreakFrames = false; /** - * The X-Frame-Options header to send on pages sensitive to clickjacking + * The X-Frame-Options header to send on pages sensitive to clickjacking * attacks, such as edit pages. This prevents those pages from being displayed * in a frame or iframe. The options are: * @@ -2303,9 +2303,9 @@ $wgBreakFrames = false; * to allow framing within a trusted domain. This is insecure if there * is a page on the same domain which allows framing of arbitrary URLs. * - * - false: Allow all framing. This opens up the wiki to XSS attacks and thus - * full compromise of local user accounts. Private wikis behind a - * corporate firewall are especially vulnerable. This is not + * - false: Allow all framing. This opens up the wiki to XSS attacks and thus + * full compromise of local user accounts. Private wikis behind a + * corporate firewall are especially vulnerable. This is not * recommended. * * For extra safety, set $wgBreakFrames = true, to prevent framing on all pages, @@ -2334,17 +2334,17 @@ $wgExperimentalHtmlIds = true; * You can add new icons to the built in copyright or poweredby, or you can create * a new block. Though note that you may need to add some custom css to get good styling * of new blocks in monobook. vector and modern should work without any special css. - * + * * $wgFooterIcons itself is a key/value array. - * The key is the name of a block that the icons will be wrapped in. The final id varies - * by skin; Monobook and Vector will turn poweredby into f-poweredbyico while Modern + * The key is the name of a block that the icons will be wrapped in. The final id varies + * by skin; Monobook and Vector will turn poweredby into f-poweredbyico while Modern * turns it into mw_poweredby. * The value is either key/value array of icons or a string. * In the key/value array the key may or may not be used by the skin but it can * be used to find the icon and unset it or change the icon if needed. * This is useful for disabling icons that are set by extensions. - * The value should be either a string or an array. If it is a string it will be output - * directly as html, however some skins may choose to ignore it. An array is the preferred format + * The value should be either a string or an array. If it is a string it will be output + * directly as html, however some skins may choose to ignore it. An array is the preferred format * for the icon, the following keys are used: * src: An absolute url to the image to use for the icon, this is recommended * but not required, however some skins will ignore icons without an image @@ -3373,7 +3373,7 @@ $wgGroupsRemoveFromSelf = array(); * Set of available actions that can be restricted via action=protect * You probably shouldn't change this. * Translated through restriction-* messages. - * Title::getRestrictionTypes() will remove restrictions that are not + * Title::getRestrictionTypes() will remove restrictions that are not * applicable to a specific title (upload currently) */ $wgRestrictionTypes = array( 'edit', 'move', 'upload' ); @@ -4185,12 +4185,12 @@ $wgReadOnly = null; $wgReadOnlyFile = false; /** - * When you run the web-based upgrade utility, it will tell you what to set + * When you run the web-based upgrade utility, it will tell you what to set * this to in order to authorize the upgrade process. It will subsequently be * used as a password, to authorize further upgrades. * - * For security, do not set this to a guessable string. Use the value supplied - * by the install/upgrade process. To cause the upgrader to generate a new key, + * For security, do not set this to a guessable string. Use the value supplied + * by the install/upgrade process. To cause the upgrader to generate a new key, * delete the old key from LocalSettings.php. */ $wgUpgradeKey = false; @@ -4636,24 +4636,24 @@ $wgCategoryMagicGallery = true; $wgCategoryPagingLimit = 200; /** - * Specify how category names should be sorted, when listed on a category page. + * Specify how category names should be sorted, when listed on a category page. * A sorting scheme is also known as a collation. * * Available values are: * * - uppercase: Converts the category name to upper case, and sorts by that. * - * - uca-default: Provides access to the Unicode Collation Algorithm with + * - uca-default: Provides access to the Unicode Collation Algorithm with * the default element table. This is a compromise collation which sorts * all languages in a mediocre way. However, it is better than "uppercase". * - * To use the uca-default collation, you must have PHP's intl extension - * installed. See http://php.net/manual/en/intl.setup.php . The details of the - * resulting collation will depend on the version of ICU installed on the + * To use the uca-default collation, you must have PHP's intl extension + * installed. See http://php.net/manual/en/intl.setup.php . The details of the + * resulting collation will depend on the version of ICU installed on the * server. * * After you change this, you must run maintenance/updateCollation.php to fix - * the sort keys in the database. + * the sort keys in the database. */ $wgCategoryCollation = 'uppercase'; diff --git a/includes/EditPage.php b/includes/EditPage.php index bab93b0a77..fb245c8d34 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1333,7 +1333,7 @@ HTML if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) { $username = $this->lastDelete->user_name; $comment = $this->lastDelete->log_comment; - + // It is better to not parse the comment at all than to have templates expanded in the middle // TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used? $wgOut->addHTML( @@ -1878,20 +1878,20 @@ HTML $data = $dbr->selectRow( array( 'logging', 'user' ), array( 'log_type', - 'log_action', - 'log_timestamp', - 'log_user', - 'log_namespace', - 'log_title', - 'log_comment', - 'log_params', - 'log_deleted', - 'user_name' ), + 'log_action', + 'log_timestamp', + 'log_user', + 'log_namespace', + 'log_title', + 'log_comment', + 'log_params', + 'log_deleted', + 'user_name' ), array( 'log_namespace' => $this->mTitle->getNamespace(), - 'log_title' => $this->mTitle->getDBkey(), - 'log_type' => 'delete', - 'log_action' => 'delete', - 'user_id=log_user' ), + 'log_title' => $this->mTitle->getDBkey(), + 'log_type' => 'delete', + 'log_action' => 'delete', + 'user_id=log_user' ), __METHOD__, array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' ) ); @@ -2379,11 +2379,11 @@ HTML array_map( array( 'Xml', 'encodeJsVar' ), $params ) ); $script .= "addButton($paramList);\n"; } - + $wgOut->addScript( Html::inlineScript( "if ( window.mediaWiki ) { jQuery(function(){{$script}}); }" ) ); - + $toolbar .= "\n"; wfRunHooks( 'EditPageBeforeEditToolbar', array( &$toolbar ) ); @@ -2715,7 +2715,7 @@ HTML switch ( $value ) { case self::AS_HOOK_ERROR_EXPECTED: case self::AS_CONTENT_TOO_BIG: - case self::AS_ARTICLE_WAS_DELETED: + case self::AS_ARTICLE_WAS_DELETED: case self::AS_CONFLICT_DETECTED: case self::AS_SUMMARY_NEEDED: case self::AS_TEXTBOX_EMPTY: @@ -2765,22 +2765,22 @@ HTML $this->userNotLoggedInPage(); return false; - case self::AS_READ_ONLY_PAGE_LOGGED: - case self::AS_READ_ONLY_PAGE: - $wgOut->readOnlyPage(); - return false; + case self::AS_READ_ONLY_PAGE_LOGGED: + case self::AS_READ_ONLY_PAGE: + $wgOut->readOnlyPage(); + return false; - case self::AS_RATE_LIMITED: - $wgOut->rateLimited(); - return false; + case self::AS_RATE_LIMITED: + $wgOut->rateLimited(); + return false; - case self::AS_NO_CREATE_PERMISSION: - $this->noCreatePermission(); - return; + case self::AS_NO_CREATE_PERMISSION: + $this->noCreatePermission(); + return; case self::AS_BLANK_ARTICLE: - $wgOut->redirect( $this->getContextTitle()->getFullURL() ); - return false; + $wgOut->redirect( $this->getContextTitle()->getFullURL() ); + return false; case self::AS_IMAGE_REDIRECT_LOGGED: $wgOut->permissionRequired( 'upload' ); diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 767b32372c..e2db69a74a 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -150,7 +150,7 @@ class LinkCache { wfProfileOut( __METHOD__ ); return 0; } - + # Some fields heavily used for linking... if ( $this->mForUpdate ) { $db = wfGetDB( DB_MASTER ); @@ -164,7 +164,7 @@ class LinkCache { $options = array(); } - $s = $db->selectRow( 'page', + $s = $db->selectRow( 'page', array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ), array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ), __METHOD__, $options ); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 9078e63e7e..7edc7db68c 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -130,7 +130,7 @@ abstract class QueryPage extends SpecialPage { function getQueryInfo() { return null; } - + /** * For back-compat, subclasses may return a raw SQL query here, as a string. * This is stronly deprecated; getQueryInfo() should be overridden instead. @@ -274,7 +274,7 @@ abstract class QueryPage extends SpecialPage { if ( !$this->isCacheable() ) { return 0; } - + $fname = get_class( $this ) . '::recache'; $dbw = wfGetDB( DB_MASTER ); $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) ); diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index d220990ee5..cfd880321e 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -660,7 +660,7 @@ class SpecialPage { } } if ( !$found ) { - wfWarn( "Did not find alias for special page '$name'. " . + wfWarn( "Did not find alias for special page '$name'. " . "Perhaps no aliases are defined for it?" ); } } diff --git a/includes/Title.php b/includes/Title.php index a0b36e83cd..54e2dce3a3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -76,7 +76,7 @@ class Title { # Don't change the following default, NS_MAIN is hardcoded in several # places. See bug 696. var $mDefaultNamespace = NS_MAIN; // /< Namespace index when there is no namespace - # Zero except in {{transclusion}} tags + # Zero except in {{transclusion}} tags var $mWatched = null; // /< Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() var $mLength = -1; // /< The page length, 0 for special pages var $mRedirect = null; // /< Is the article at this title a redirect? @@ -226,7 +226,7 @@ class Title { return array(); } $dbr = wfGetDB( DB_SLAVE ); - + $res = $dbr->select( 'page', array( @@ -1427,7 +1427,7 @@ class Title { /** * Check restrictions on cascading pages. - * + * * @param $action String the action to check * @param $user User to check * @param $errors Array list of current errors @@ -1841,7 +1841,7 @@ class Title { * cache that we don't need to over-optimize by doing direct comparisons and * acidentally creating new bugs where $title->equals( Title::newFromText() ) * ends up reporting something differently than $title->isMainPage(); - * + * * @return Bool */ public function isMainPage() { @@ -2004,7 +2004,7 @@ class Title { public function userCanEditJsSubpage() { global $wgUser; return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'edituserjs' ) ) - || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) ); + || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) ); } /** @@ -2503,6 +2503,7 @@ class Title { if ( $this->mInterwiki != '' ) { $p = $this->mInterwiki . ':'; } + if ( 0 != $this->mNamespace ) { $p .= $this->getNsText() . ':'; } @@ -2640,7 +2641,7 @@ class Title { # Redundant interwiki prefix to the local wiki if ( $wgLocalInterwiki !== false - && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) + && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) { if ( $dbkey == '' ) { # Can't have an empty self-link @@ -2687,13 +2688,13 @@ class Title { # reachable due to the way web browsers deal with 'relative' URLs. # Also, they conflict with subpage syntax. Forbid them explicitly. if ( strpos( $dbkey, '.' ) !== false && - ( $dbkey === '.' || $dbkey === '..' || - strpos( $dbkey, './' ) === 0 || - strpos( $dbkey, '../' ) === 0 || - strpos( $dbkey, '/./' ) !== false || - strpos( $dbkey, '/../' ) !== false || - substr( $dbkey, -2 ) == '/.' || - substr( $dbkey, -3 ) == '/..' ) ) + ( $dbkey === '.' || $dbkey === '..' || + strpos( $dbkey, './' ) === 0 || + strpos( $dbkey, '../' ) === 0 || + strpos( $dbkey, '/./' ) !== false || + strpos( $dbkey, '/../' ) !== false || + substr( $dbkey, -2 ) == '/.' || + substr( $dbkey, -3 ) == '/..' ) ) { return false; } @@ -2972,7 +2973,7 @@ class Title { } if ( ( $this->getDBkey() == '' ) || ( !$oldid ) || - ( $nt->getDBkey() == '' ) ) { + ( $nt->getDBkey() == '' ) ) { $errors[] = array( 'badarticleerror' ); } @@ -3092,7 +3093,7 @@ class Title { ); $dbw->update( 'categorylinks', array( - 'cl_sortkey' => Collation::singleton()->getSortKey( + 'cl_sortkey' => Collation::singleton()->getSortKey( $nt->getCategorySortkey( $prefix ) ), 'cl_timestamp=cl_timestamp' ), array( 'cl_from' => $pageid ), @@ -3694,7 +3695,7 @@ class Title { /** * Callback for usort() to do title sorts by (namespace, title) - * + * * @return Integer: result of string comparison, or namespace comparison */ public static function compare( $a, $b ) { @@ -3922,8 +3923,8 @@ class Title { // Spec: http://www.sixapart.com/pronet/docs/trackback_spec return "