From 4b8523198f177820a0ff835dc1703c6ad8711dd6 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 11 May 2014 17:34:55 +0200 Subject: [PATCH] Make phpcs-strict pass on includes/ (4/~10) Change-Id: I2767205a7059adfb8fa090a82abd332e518f2590 --- includes/WatchedItem.php | 31 +++- includes/WebRequest.php | 32 ++-- includes/WebStart.php | 5 +- includes/Wiki.php | 9 +- includes/WikiFilePage.php | 3 +- includes/WikiPage.php | 210 ++++++++++++++----------- includes/Xml.php | 75 ++++++--- includes/api/ApiWatch.php | 3 +- includes/filerepo/file/LocalFile.php | 12 +- includes/installer/PostgresUpdater.php | 3 +- 10 files changed, 251 insertions(+), 132 deletions(-) diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index 9f2b498873..f69fe6334f 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -41,8 +41,23 @@ class WatchedItem { */ const CHECK_USER_RIGHTS = 1; - var $mTitle, $mUser, $mCheckRights; - private $loaded = false, $watched, $timestamp; + /** @var Title */ + public $mTitle; + + /** @var User */ + public $mUser; + + /** @var int */ + public $mCheckRights; + + /** @var bool */ + private $loaded = false; + + /** @var bool */ + private $watched; + + /** @var string */ + private $timestamp; /** * Create a WatchedItem object with the given user and title @@ -53,7 +68,9 @@ class WatchedItem { * Pass either WatchedItem::IGNORE_USER_RIGHTS or WatchedItem::CHECK_USER_RIGHTS. * @return WatchedItem */ - public static function fromUserTitle( $user, $title, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) { + public static function fromUserTitle( $user, $title, + $checkRights = WatchedItem::CHECK_USER_RIGHTS + ) { $wl = new WatchedItem; $wl->mUser = $user; $wl->mTitle = $title; @@ -389,7 +406,13 @@ class WatchedItem { # Perform replace # Note that multi-row replace is very efficient for MySQL but may be inefficient for # some other DBMSes, mostly due to poor simulation by us - $dbw->replace( 'watchlist', array( array( 'wl_user', 'wl_namespace', 'wl_title' ) ), $values, __METHOD__ ); + $dbw->replace( + 'watchlist', + array( array( 'wl_user', 'wl_namespace', 'wl_title' ) ), + $values, + __METHOD__ + ); + return true; } } diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 12cf0d9f97..ac8e159be3 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -696,7 +696,9 @@ class WebRequest { public function getRequestURL() { if ( isset( $_SERVER['REQUEST_URI'] ) && strlen( $_SERVER['REQUEST_URI'] ) ) { $base = $_SERVER['REQUEST_URI']; - } elseif ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) && strlen( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { + } elseif ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) + && strlen( $_SERVER['HTTP_X_ORIGINAL_URL'] ) + ) { // Probably IIS; doesn't set REQUEST_URI $base = $_SERVER['HTTP_X_ORIGINAL_URL']; } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) { @@ -1010,9 +1012,9 @@ class WebRequest { We can't serve non-HTML content from the URL you have requested, because Internet Explorer would interpret it as an incorrect and potentially dangerous content type.

-

Instead, please use this URL, which is the same as the URL you have requested, except that -"&*" is appended. This prevents Internet Explorer from seeing a bogus file -extension. +

Instead, please use this URL, which is the same as the +URL you have requested, except that "&*" is appended. This prevents Internet +Explorer from seeing a bogus file extension.

@@ -1023,14 +1025,16 @@ HTML; /** * Parse the Accept-Language header sent by the client into an array - * @return array array( languageCode => q-value ) sorted by q-value in descending order then - * appearing time in the header in ascending order. + * + * @return array array( languageCode => q-value ) sorted by q-value in + * descending order then appearing time in the header in ascending order. * May contain the "language" '*', which applies to languages other than those explicitly listed. * This is aligned with rfc2616 section 14.4 * Preference for earlier languages appears in rfc3282 as an extension to HTTP/1.1. */ public function getAcceptLang() { - // Modified version of code found at http://www.thefutureoftheweb.com/blog/use-accept-language-header + // Modified version of code found at + // http://www.thefutureoftheweb.com/blog/use-accept-language-header $acceptLang = $this->getHeader( 'Accept-Language' ); if ( !$acceptLang ) { return array(); @@ -1041,8 +1045,11 @@ HTML; // Break up string into pieces (languages and q factors) $lang_parse = null; - preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})*|\*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})?)?)?/', - $acceptLang, $lang_parse ); + preg_match_all( + '/([a-z]{1,8}(-[a-z]{1,8})*|\*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})?)?)?/', + $acceptLang, + $lang_parse + ); if ( !count( $lang_parse[1] ) ) { return array(); @@ -1084,7 +1091,8 @@ HTML; } if ( is_array( $_SERVER['REMOTE_ADDR'] ) || strpos( $_SERVER['REMOTE_ADDR'], ',' ) !== false ) { - throw new MWException( __METHOD__ . " : Could not determine the remote IP address due to multiple values." ); + throw new MWException( __METHOD__ + . " : Could not determine the remote IP address due to multiple values." ); } else { $ipchain = $_SERVER['REMOTE_ADDR']; } @@ -1303,7 +1311,9 @@ class FauxRequest extends WebRequest { * @param string $protocol 'http' or 'https' * @throws MWException */ - public function __construct( $data = array(), $wasPosted = false, $session = null, $protocol = 'http' ) { + public function __construct( $data = array(), $wasPosted = false, + $session = null, $protocol = 'http' + ) { if ( is_array( $data ) ) { $this->data = $data; } else { diff --git a/includes/WebStart.php b/includes/WebStart.php index 766b3bf534..09f01c008b 100644 --- a/includes/WebStart.php +++ b/includes/WebStart.php @@ -30,8 +30,10 @@ # This must be done before any globals are set by the code if ( ini_get( 'register_globals' ) ) { if ( isset( $_REQUEST['GLOBALS'] ) || isset( $_FILES['GLOBALS'] ) ) { - die( '$GLOBALS overwrite vulnerability' ); + die( '' + . '$GLOBALS overwrite vulnerability' ); } + $verboten = array( 'GLOBALS', '_SERVER', @@ -50,6 +52,7 @@ if ( ini_get( 'register_globals' ) ) { '_SESSION', 'HTTP_SESSION_VARS' ); + foreach ( $_REQUEST as $name => $value ) { if ( in_array( $name, $verboten ) ) { header( "HTTP/1.1 500 Internal Server Error" ); diff --git a/includes/Wiki.php b/includes/Wiki.php index aed1f65cb3..eff251f6d6 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -26,9 +26,8 @@ * @internal documentation reviewed 15 Mar 2010 */ class MediaWiki { - /** - * TODO: fold $output, etc, into this + * @todo Fold $output, etc, into this * @var IContextSource */ private $context; @@ -117,7 +116,11 @@ class MediaWiki { } // Use the main page as default title if nothing else has been provided - if ( $ret === null && strval( $title ) === '' && !$request->getCheck( 'curid' ) && $action !== 'delete' ) { + if ( $ret === null + && strval( $title ) === '' + && !$request->getCheck( 'curid' ) + && $action !== 'delete' + ) { $ret = Title::newMainPage(); } diff --git a/includes/WikiFilePage.php b/includes/WikiFilePage.php index 44f0599591..34f15c3aa6 100644 --- a/includes/WikiFilePage.php +++ b/includes/WikiFilePage.php @@ -180,7 +180,8 @@ class WikiFilePage extends WikiPage { $this->mFile->upgradeRow(); $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) ); } else { - wfDebug( 'ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n" ); + wfDebug( 'ImagePage::doPurge no image for ' + . $this->mFile->getName() . "; limiting purge to cache only\n" ); // even if the file supposedly doesn't exist, force any cached information // to be updated (in case the cached information is wrong) $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index d53acd0d1a..9a26c15b05 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -352,10 +352,11 @@ class WikiPage implements Page, IDBAccessObject { * some source. * * @param object|string|int $from One of the following: - * - A DB query result object - * - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB - * - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB - * - "forupdate" or WikiPage::READ_LOCKING to get from the master DB using SELECT FOR UPDATE + * - A DB query result object. + * - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB. + * - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB. + * - "forupdate" or WikiPage::READ_LOCKING to get from the master DB + * using SELECT FOR UPDATE. * * @return void */ @@ -688,7 +689,7 @@ class WikiPage implements Page, IDBAccessObject { * @return string|bool The text of the current revision * @deprecated since 1.21, getContent() should be used instead. */ - public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { // @todo deprecated, replace usage! + public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { ContentHandler::deprecated( __METHOD__, '1.21' ); $this->loadLastEdit(); @@ -1291,9 +1292,10 @@ class WikiPage implements Page, IDBAccessObject { * @param bool $lastRevIsRedirect If given, will optimize adding and * removing rows in redirect table. * @return bool true on success, false on failure - * @private */ - public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) { + public function updateRevisionOn( $dbw, $revision, $lastRevision = null, + $lastRevIsRedirect = null + ) { global $wgContentHandlerUseDB; wfProfileIn( __METHOD__ ); @@ -1477,10 +1479,13 @@ class WikiPage implements Page, IDBAccessObject { * * @deprecated since 1.21, use replaceSectionContent() instead */ - public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { + public function replaceSection( $section, $text, $sectionTitle = '', + $edittime = null + ) { ContentHandler::deprecated( __METHOD__, '1.21' ); - if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent! + //NOTE: keep condition in sync with condition in replaceSectionContent! + if ( strval( $section ) == '' ) { // Whole-page edit; let the whole text through return $text; } @@ -1504,8 +1509,10 @@ class WikiPage implements Page, IDBAccessObject { * * @return bool * - * @todo The skin should check this and not offer section functionality if sections are not supported. - * @todo The EditPage should check this and not offer section functionality if sections are not supported. + * @todo The skin should check this and not offer section functionality if + * sections are not supported. + * @todo The EditPage should check this and not offer section functionality + * if sections are not supported. */ public function supportsSections() { return $this->getContentHandler()->supportsSections(); @@ -1606,10 +1613,11 @@ class WikiPage implements Page, IDBAccessObject { * EDIT_AUTOSUMMARY * Fill in blank summaries with generated text where possible * - * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected. - * If EDIT_UPDATE is specified and the article doesn't exist, the function will return an - * edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an - * edit-already-exists error will be returned. These two conditions are also possible with + * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the + * article will be detected. If EDIT_UPDATE is specified and the article + * doesn't exist, the function will return an edit-gone-missing error. If + * EDIT_NEW is specified and the article does exist, an edit-already-exists + * error will be returned. These two conditions are also possible with * auto-detection due to MediaWiki's performance-optimised locking strategy. * * @param bool|int $baseRevId The revision ID this edit was based off, if any @@ -1617,19 +1625,21 @@ class WikiPage implements Page, IDBAccessObject { * * @throws MWException * @return Status object. Possible errors: - * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status - * edit-gone-missing: In update mode, but the article didn't exist - * edit-conflict: In update mode, the article changed unexpectedly - * edit-no-change: Warning that the text was the same as before - * edit-already-exists: In creation mode, but the article already exists + * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't + * set the fatal flag of $status + * edit-gone-missing: In update mode, but the article didn't exist. + * edit-conflict: In update mode, the article changed unexpectedly. + * edit-no-change: Warning that the text was the same as before. + * edit-already-exists: In creation mode, but the article already exists. * - * Extensions may define additional errors. + * Extensions may define additional errors. * - * $return->value will contain an associative array with members as follows: - * new: Boolean indicating if the function attempted to create a new article - * revision: The revision object for the inserted revision, or null + * $return->value will contain an associative array with members as follows: + * new: Boolean indicating if the function attempted to create a new article. + * revision: The revision object for the inserted revision, or null. * - * Compatibility note: this function previously returned a boolean value indicating success/failure + * Compatibility note: this function previously returned a boolean value + * indicating success/failure * * @deprecated since 1.21: use doEditContent() instead. */ @@ -1663,29 +1673,32 @@ class WikiPage implements Page, IDBAccessObject { * EDIT_AUTOSUMMARY * Fill in blank summaries with generated text where possible * - * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected. - * If EDIT_UPDATE is specified and the article doesn't exist, the function will return an - * edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an - * edit-already-exists error will be returned. These two conditions are also possible with + * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the + * article will be detected. If EDIT_UPDATE is specified and the article + * doesn't exist, the function will return an edit-gone-missing error. If + * EDIT_NEW is specified and the article does exist, an edit-already-exists + * error will be returned. These two conditions are also possible with * auto-detection due to MediaWiki's performance-optimised locking strategy. * * @param bool|int $baseRevId The revision ID this edit was based off, if any * @param User $user The user doing the edit - * @param string $serialisation_format Format for storing the content in the database + * @param string $serialisation_format Format for storing the content in the + * database. * * @throws MWException * @return Status object. Possible errors: - * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status - * edit-gone-missing: In update mode, but the article didn't exist - * edit-conflict: In update mode, the article changed unexpectedly - * edit-no-change: Warning that the text was the same as before - * edit-already-exists: In creation mode, but the article already exists + * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't + * set the fatal flag of $status. + * edit-gone-missing: In update mode, but the article didn't exist. + * edit-conflict: In update mode, the article changed unexpectedly. + * edit-no-change: Warning that the text was the same as before. + * edit-already-exists: In creation mode, but the article already exists. * * Extensions may define additional errors. * * $return->value will contain an associative array with members as follows: - * new: Boolean indicating if the function attempted to create a new article - * revision: The revision object for the inserted revision, or null + * new: Boolean indicating if the function attempted to create a new article. + * revision: The revision object for the inserted revision, or null. * * @since 1.21 */ @@ -2020,7 +2033,8 @@ class WikiPage implements Page, IDBAccessObject { $options = $this->getContentHandler()->makeParserOptions( $context ); if ( $this->getTitle()->isConversionTable() ) { - // @todo ConversionTable should become a separate content model, so we don't need special cases like this one. + // @todo ConversionTable should become a separate content model, so + // we don't need special cases like this one. $options->disableContentConversion(); } @@ -2087,7 +2101,9 @@ class WikiPage implements Page, IDBAccessObject { $edit->format = $serialization_format; $edit->popts = $this->makeParserOptions( 'canonical' ); - $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) : null; + $edit->output = $edit->pstContent + ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) + : null; $edit->newContent = $content; $edit->oldContent = $this->getContent( Revision::RAW ); @@ -2298,7 +2314,9 @@ class WikiPage implements Page, IDBAccessObject { * @param User $user The user updating the restrictions * @return Status */ - public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) { + public function doUpdateRestrictions( array $limit, array $expiry, + &$cascade, $reason, User $user + ) { global $wgCascadingRestrictionLevels, $wgContLang; if ( wfReadOnly() ) { @@ -2384,7 +2402,9 @@ class WikiPage implements Page, IDBAccessObject { } // Only certain restrictions can cascade... - $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' ); + $editrestriction = isset( $limit['edit'] ) + ? array( $limit['edit'] ) + : $this->mTitle->getRestrictions( 'edit' ); foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) { $editrestriction[$key] = 'editprotected'; // backwards compatibility } @@ -2407,7 +2427,15 @@ class WikiPage implements Page, IDBAccessObject { // insert null revision to identify the page protection change as edit summary $latest = $this->getLatest(); - $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason, $user ); + $nullRevision = $this->insertProtectNullRevision( + $revCommentMsg, + $limit, + $expiry, + $cascade, + $reason, + $user + ); + if ( $nullRevision === null ) { return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() ); } @@ -2509,7 +2537,9 @@ class WikiPage implements Page, IDBAccessObject { * @param User|null $user * @return Revision|null Null on error */ - public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user = null ) { + public function insertProtectNullRevision( $revCommentMsg, array $limit, + array $expiry, $cascade, $reason, $user = null + ) { global $wgContLang; $dbw = wfGetDB( DB_MASTER ); @@ -2526,7 +2556,8 @@ class WikiPage implements Page, IDBAccessObject { $protectDescription = $this->protectDescription( $limit, $expiry ); if ( $protectDescription ) { $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text(); - $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )->inContentLanguage()->text(); + $editComment .= wfMessage( 'parentheses' )->params( $protectDescription ) + ->inContentLanguage()->text(); } if ( $cascade ) { $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text(); @@ -2825,8 +2856,9 @@ class WikiPage implements Page, IDBAccessObject { * Do some database updates after deletion * * @param int $id page_id value of the page being deleted - * @param Content $content Optional page content to be used when determining the required updates. - * This may be needed because $this->getContent() may already return null when the page proper was deleted. + * @param Content $content Optional page content to be used when determining + * the required updates. This may be needed because $this->getContent() + * may already return null when the page proper was deleted. */ public function doDeleteUpdates( $id, Content $content = null ) { // update site status @@ -2963,7 +2995,9 @@ class WikiPage implements Page, IDBAccessObject { if ( $s === false ) { // No one else ever edited this page return array( array( 'cantrollback' ) ); - } elseif ( $s->rev_deleted & Revision::DELETED_TEXT || $s->rev_deleted & Revision::DELETED_USER ) { + } elseif ( $s->rev_deleted & Revision::DELETED_TEXT + || $s->rev_deleted & Revision::DELETED_USER + ) { // Only admins can see this text return array( array( 'notvisiblerev' ) ); } @@ -3031,7 +3065,13 @@ class WikiPage implements Page, IDBAccessObject { } // Actually store the edit - $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser ); + $status = $this->doEditContent( + $target->getContent(), + $summary, + $flags, + $target->getId(), + $guser + ); if ( !$status->isOK() ) { return $status->getErrorsArray(); @@ -3138,7 +3178,8 @@ class WikiPage implements Page, IDBAccessObject { * Purge caches on page update etc * * @param Title $title - * @todo Verify that $title is always a Title object (and never false or null), add Title hint to parameter $title + * @todo Verify that $title is always a Title object (and never false or + * null), add Title hint to parameter $title. */ public static function onArticleEdit( $title ) { // Invalidate caches of articles which include this page @@ -3220,7 +3261,8 @@ class WikiPage implements Page, IDBAccessObject { * @deprecated since 1.21, use ContentHandler::getAutosummary() instead */ public static function getAutosummary( $oldtext, $newtext, $flags ) { - // NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't. + // NOTE: stub for backwards-compatibility. assumes the given text is + // wikitext. will break horribly if it isn't. ContentHandler::deprecated( __METHOD__, '1.21' ); @@ -3370,7 +3412,8 @@ class WikiPage implements Page, IDBAccessObject { if ( count( $links_diff ) > 0 ) { // Whee, link updates time. - // Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output. + // Note: we are only interested in links here. We don't need to get + // other DataUpdate items from the parser output. $u = new LinksUpdate( $this->mTitle, $parserOutput, false ); $u->doUpdate(); } @@ -3457,10 +3500,12 @@ class WikiPage implements Page, IDBAccessObject { } /** - * Returns a list of updates to be performed when this page is deleted. The updates should remove any information - * about this page from secondary data stores such as links tables. + * Returns a list of updates to be performed when this page is deleted. The + * updates should remove any information about this page from secondary data + * stores such as links tables. * - * @param Content|null $content Optional Content object for determining the necessary updates + * @param Content|null $content Optional Content object for determining the + * necessary updates. * @return array An array of DataUpdates objects */ public function getDeletionUpdates( Content $content = null ) { @@ -3483,57 +3528,42 @@ class WikiPage implements Page, IDBAccessObject { } class PoolWorkArticleView extends PoolCounterWork { - - /** - * @var Page - */ + /** @var Page */ private $page; - /** - * @var string - */ + /** @var string */ private $cacheKey; - /** - * @var int - */ + /** @var int */ private $revid; - /** - * @var ParserOptions - */ + /** @var ParserOptions */ private $parserOptions; - /** - * @var Content|null - */ + /** @var Content|null */ private $content = null; - /** - * @var ParserOutput|bool - */ + /** @var ParserOutput|bool */ private $parserOutput = false; - /** - * @var bool - */ + /** @var bool */ private $isDirty = false; - /** - * @var Status|bool - */ + /** @var Status|bool */ private $error = false; /** - * Constructor - * * @param Page $page - * @param int $revid ID of the revision being parsed - * @param bool $useParserCache Whether to use the parser cache - * @param ParserOptions $parserOptions ParserOptions to use for the parse operation - * @param Content|string $content Content to parse or null to load it; may also be given as a wikitext string, for BC - */ - public function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) { + * @param int $revid ID of the revision being parsed. + * @param bool $useParserCache Whether to use the parser cache. + * @param ParserOptions $parserOptions ParserOptions to use for the parse + * operation. + * @param Content|string $content Content to parse or null to load it; may + * also be given as a wikitext string, for BC. + */ + public function __construct( Page $page, ParserOptions $parserOptions, + $revid, $useParserCache, $content = null + ) { if ( is_string( $content ) ) { // BC: old style call $modelId = $page->getRevision()->getContentModel(); $format = $page->getRevision()->getContentFormat(); @@ -3611,7 +3641,11 @@ class PoolWorkArticleView extends PoolCounterWork { $cacheTime = wfTimestampNow(); $time = - microtime( true ); - $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions ); + $this->parserOutput = $content->getParserOutput( + $this->page->getTitle(), + $this->revid, + $this->parserOptions + ); $time += microtime( true ); // Timing hack diff --git a/includes/Xml.php b/includes/Xml.php index 6510eaecdb..6fb5380550 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -36,7 +36,9 @@ class Xml { * @param bool $allowShortTag Whether '' in $contents will result in a contentless closed tag * @return string */ - public static function element( $element, $attribs = null, $contents = '', $allowShortTag = true ) { + public static function element( $element, $attribs = null, $contents = '', + $allowShortTag = true + ) { $out = '<' . $element; if ( !is_null( $attribs ) ) { $out .= self::expandAttributes( $attribs ); @@ -142,7 +144,9 @@ class Xml { * @return string * @deprecated since 1.19 */ - public static function namespaceSelector( $selected = '', $all = null, $element_name = 'namespace', $label = null ) { + public static function namespaceSelector( $selected = '', $all = null, + $element_name = 'namespace', $label = null + ) { wfDeprecated( __METHOD__, '1.19' ); return Html::namespaceSelector( array( 'selected' => $selected, @@ -158,8 +162,9 @@ class Xml { /** * Create a date selector * - * @param string $selected The month which should be selected, default '' - * @param string $allmonths Value of a special item denoting all month. Null to not include (default) + * @param string $selected The month which should be selected, default ''. + * @param string $allmonths Value of a special item denoting all month. + * Null to not include (default). * @param string $id Element identifier * @return string Html string containing the month selector */ @@ -170,12 +175,20 @@ class Xml { $selected = ''; } if ( !is_null( $allmonths ) ) { - $options[] = self::option( wfMessage( 'monthsall' )->text(), $allmonths, $selected === $allmonths ); + $options[] = self::option( + wfMessage( 'monthsall' )->text(), + $allmonths, + $selected === $allmonths + ); } for ( $i = 1; $i < 13; $i++ ) { $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i ); } - return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) ) + return self::openElement( 'select', array( + 'id' => $id, + 'name' => 'month', + 'class' => 'mw-month-selector' + ) ) . implode( "\n", $options ) . self::closeElement( 'select' ); } @@ -222,7 +235,9 @@ class Xml { * @param Message|null $msg Label message key (since 1.20) * @return array containing 2 items: label HTML and select list HTML */ - public static function languageSelector( $selected, $customisedOnly = true, $inLanguage = null, $overrideAttrs = array(), Message $msg = null ) { + public static function languageSelector( $selected, $customisedOnly = true, + $inLanguage = null, $overrideAttrs = array(), Message $msg = null + ) { global $wgLanguageCode; $include = $customisedOnly ? 'mwfile' : 'mw'; @@ -313,8 +328,11 @@ class Xml { * @param array $attribs Other attributes * @return string HTML */ - public static function password( $name, $size = false, $value = false, $attribs = array() ) { - return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) ); + public static function password( $name, $size = false, $value = false, + $attribs = array() + ) { + return self::input( $name, $size, $value, + array_merge( $attribs, array( 'type' => 'password' ) ) ); } /** @@ -395,7 +413,9 @@ class Xml { * @param array $attribs Other attributes * @return string HTML */ - public static function inputLabel( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { + public static function inputLabel( $label, $name, $id, $size = false, + $value = false, $attribs = array() + ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); return $label . ' ' . $input; } @@ -412,7 +432,9 @@ class Xml { * * @return array */ - public static function inputLabelSep( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { + public static function inputLabelSep( $label, $name, $id, $size = false, + $value = false, $attribs = array() + ) { return array( Xml::label( $label, $id, $attribs ), self::input( $name, $size, $value, array( 'id' => $id ) + $attribs ) @@ -448,7 +470,9 @@ class Xml { * * @return string HTML */ - public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) { + public static function radioLabel( $label, $name, $value, $id, + $checked = false, $attribs = array() + ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . ' ' . self::label( $label, $id, $attribs ); @@ -487,14 +511,17 @@ class Xml { * Build a drop-down box from a textual list. * * @param string $name Name and id for the drop-down - * @param string $list Correctly formatted text (newline delimited) to be used to generate the options + * @param string $list Correctly formatted text (newline delimited) to be + * used to generate the options. * @param string $other Text for the "Other reasons" option * @param string $selected Option which should be pre-selected * @param string $class CSS classes for the drop-down * @param int $tabindex Value of the tabindex attribute * @return string */ - public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { + public static function listDropDown( $name = '', $list = '', $other = '', + $selected = '', $class = '', $tabindex = null + ) { $optgroup = false; $options = self::option( $other, 'other', $selected === 'other' ); @@ -554,8 +581,10 @@ class Xml { /** * Shortcut for creating fieldsets. * - * @param string|bool $legend Legend of the fieldset. If evaluates to false, legend is not added. - * @param string $content Pre-escaped content for the fieldset. If false, only open fieldset is returned. + * @param string|bool $legend Legend of the fieldset. If evaluates to false, + * legend is not added. + * @param string $content Pre-escaped content for the fieldset. If false, + * only open fieldset is returned. * @param array $attribs Any attributes to fieldset-element. * * @return string @@ -740,8 +769,11 @@ class Xml { /** * Generate a form (without the opening form element). * Output optionally includes a submit button. - * @param array $fields Associative array, key is the name of a message that contains a description for the field, value is an HTML string containing the appropriate input. - * @param string $submitLabel The name of a message containing a label for the submit button. + * @param array $fields Associative array, key is the name of a message that + * contains a description for the field, value is an HTML string + * containing the appropriate input. + * @param string $submitLabel The name of a message containing a label for + * the submit button. * @param array $submitAttribs The attributes to add to the submit button * @return string HTML form. */ @@ -758,14 +790,17 @@ class Xml { // the input somehow. $form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), wfMessage( $labelmsg )->parse() ); - $form .= Xml::openElement( 'td', array( 'class' => 'mw-input' ) ) . $input . Xml::closeElement( 'td' ); + $form .= Xml::openElement( 'td', array( 'class' => 'mw-input' ) ) + . $input . Xml::closeElement( 'td' ); $form .= Xml::closeElement( 'tr' ); } if ( $submitLabel ) { $form .= Xml::openElement( 'tr' ); $form .= Xml::tags( 'td', array(), '' ); - $form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs ) . Xml::closeElement( 'td' ); + $form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) + . Xml::submitButton( wfMessage( $submitLabel )->text(), $submitAttribs ) + . Xml::closeElement( 'td' ); $form .= Xml::closeElement( 'tr' ); } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 953df584af..1fcc6793ac 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -218,7 +218,8 @@ class ApiWatch extends ApiBase { return $psModule->getParamDescription() + array( 'title' => 'The page to (un)watch. use titles instead', 'unwatch' => 'If set the page will be unwatched rather than watched', - 'entirewatchlist' => 'Work on all watched pages without returning a list; can only be used together with \'unwatch\' option.', + 'entirewatchlist' => 'Work on all watched pages without returning a list; ' + . 'can only be used together with \'unwatch\' option.', 'uselang' => 'Language to show the message in', 'token' => 'A token previously acquired via prop=info', ); diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 7fb85b9fb1..73ab04d49a 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2126,7 +2126,11 @@ class LocalFileDeleteBatch { $dbw->insertSelect( 'filearchive', 'image', array( 'fa_storage_group' => $encGroup, - 'fa_storage_key' => $dbw->conditional( array( 'img_sha1' => '' ), $dbw->addQuotes( '' ), $concat ), + 'fa_storage_key' => $dbw->conditional( + array( 'img_sha1' => '' ), + $dbw->addQuotes( '' ), + $concat + ), 'fa_deleted_user' => $encUserId, 'fa_deleted_timestamp' => $encTimestamp, 'fa_deleted_reason' => $encReason, @@ -2158,7 +2162,11 @@ class LocalFileDeleteBatch { $dbw->insertSelect( 'filearchive', 'oldimage', array( 'fa_storage_group' => $encGroup, - 'fa_storage_key' => $dbw->conditional( array( 'oi_sha1' => '' ), $dbw->addQuotes( '' ), $concat ), + 'fa_storage_key' => $dbw->conditional( + array( 'oi_sha1' => '' ), + $dbw->addQuotes( '' ), + $concat + ), 'fa_deleted_user' => $encUserId, 'fa_deleted_timestamp' => $encTimestamp, 'fa_deleted_reason' => $encReason, diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index e7aab8aa9b..8c81080f37 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -406,7 +406,8 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'recentchanges', 'rc_source', "TEXT NOT NULL DEFAULT ''" ), array( 'addPgField', 'page', 'page_links_updated', "TIMESTAMPTZ NULL" ), array( 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ), - array( 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea', "replace(lc_value,'\','\\\\')::bytea" ), + array( 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea', + "replace(lc_value,'\','\\\\')::bytea" ), // 1.24 array( 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ), -- 2.20.1