Merge "Several tweaks to the install.php script"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 11 May 2014 09:04:48 +0000 (09:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 11 May 2014 09:04:48 +0000 (09:04 +0000)
57 files changed:
.gitattributes [new file with mode: 0644]
RELEASE-NOTES-1.23
RELEASE-NOTES-1.24
docs/hooks.txt
includes/Article.php
includes/AutoLoader.php
includes/DefaultSettings.php
includes/MagicWord.php
includes/Skin.php
includes/UserMailer.php
includes/api/ApiFeedContributions.php
includes/api/ApiFeedWatchlist.php
includes/content/AbstractContent.php
includes/content/TextContent.php
includes/content/WikitextContent.php
includes/htmlform/HTMLHiddenField.php
includes/installer/Installer.php
includes/installer/WebInstallerPage.php
includes/parser/CacheTime.php
includes/parser/CoreParserFunctions.php
includes/parser/DateFormatter.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php
includes/parser/ParserCache.php
includes/parser/ParserOptions.php
includes/parser/ParserOutput.php
includes/parser/Parser_DiffTest.php
includes/parser/Preprocessor.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
includes/profiler/Profiler.php
includes/profiler/ProfilerSimpleDB.php
includes/profiler/ProfilerStub.php
includes/specials/SpecialBlock.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialExport.php
includes/specials/SpecialImport.php
includes/specials/SpecialJavaScriptTest.php
includes/specials/SpecialListfiles.php
includes/specials/SpecialListgrouprights.php
includes/specials/SpecialLockdb.php
includes/specials/SpecialLog.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialNewimages.php
includes/specials/SpecialNewpages.php
includes/specials/SpecialProtectedpages.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialRunJobs.php
includes/specials/SpecialSearch.php
maintenance/generateJsonI18n.php
maintenance/pageExists.php [new file with mode: 0644]
resources/src/mediawiki.api/mediawiki.api.watch.js
skins/common/commonPrint.css
tests/phpunit/includes/content/ContentHandlerTest.php
tests/phpunit/includes/content/CssContentTest.php
tests/phpunit/includes/content/TextContentTest.php

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..50ca329
--- /dev/null
@@ -0,0 +1 @@
+*.sh eol=lf
index 5326e23..575fdc3 100644 (file)
@@ -516,7 +516,7 @@ Don't forget to always back up your database before upgrading!
 
 See the file UPGRADE for more detailed upgrade instructions.
 
-For notes on 1.21.x and older releases, see HISTORY.
+For notes on 1.22.x and older releases, see HISTORY.
 
 == Online documentation ==
 
index ff73139..1bf308c 100644 (file)
@@ -15,12 +15,17 @@ production.
 === New features in 1.24 ===
 * Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
   WhatLinksHere entries.
+* Added a new hook, "ContentGetParserOutput", to customize parser output for
+  a given content object.
+* Deprecated the hook "ShowRawCssJs", use "ContentGetParserOutput" instead.
 * HTMLForm's HTMLTextField now supports the 'url' type.
 * HTMLForm fields may now be dynamically hidden based on the values of other
   fields in the form.
 * HTMLForm now supports multiple copies of an input field or set of input
   fields, e.g. the form may request "one or more usernames" without having to
   have the user enter delimited list of names into a text field.
+* Added a new hook, "SidebarBeforeOutput", to allow to edit the structure of
+  the sidebar just before its display.
 
 === Bug fixes in 1.24 ===
 * (bug 62258) A bug was fixed in File::getUnscaledThumb when a height
@@ -73,6 +78,10 @@ changes to languages because of Bugzilla reports.
 * RevDel_RevisionItem to RevDelRevisionItem
 * RevDel_RevisionList to RevDelRevisionList
 
+==== Removed classes ====
+* IPBlockForm - Use SpecialBlock directly
+* WatchlistEditor - Use SpecialEditWatchlist directly
+
 == Compatibility ==
 
 MediaWiki 1.24 requires PHP 5.3.2 or later.
@@ -111,7 +120,7 @@ Don't forget to always back up your database before upgrading!
 
 See the file UPGRADE for more detailed upgrade instructions.
 
-For notes on 1.21.x and older releases, see HISTORY.
+For notes on 1.22.x and older releases, see HISTORY.
 
 == Online documentation ==
 
index 688e0cd..d455fd2 100644 (file)
@@ -887,6 +887,19 @@ $title: the Title in question.
 Handler functions that modify $ok should generally return false to prevent further
 hooks from further modifying $ok.
 
+'ContentGetParserOutput': Customize parser output for a given content object,
+called by AbstractContent::getParserOutput. May be used to override the normal
+model-specific rendering of page content.
+$content: The Content to render
+$title: Title of the page, as context
+$revId: The revision ID, as context
+$options: ParserOptions for rendering. To avoid confusing the parser cache,
+the output can only depend on parameters provided to this hook function, not on global state.
+$generateHtml: boolean, indicating whether full HTML should be generated. If false,
+generation of HTML may be skipped, but other information should still be present in the
+ParserOutput object.
+&$output: ParserOutput, to manipulate or replace
+
 'ConvertContent': Called by AbstractContent::convert when a conversion to another
 content model is requested.
 $content: The Content object to be converted.
@@ -2171,7 +2184,7 @@ $title : Current Title object being displayed in search results.
 $article: The article object corresponding to the page
 
 'ShowRawCssJs': Customise the output of raw CSS and JavaScript in page views.
-DEPRECATED, use the ContentHandler facility to handle CSS and JavaScript!
+DEPRECATED, use the ContentGetParserOutput hook instead!
 $text: Text being shown
 $title: Title of the custom script/stylesheet page
 $output: Current OutputPage object
@@ -2226,6 +2239,12 @@ $skin: Skin object
 &$bar: Sidebar contents
 Modify $bar to add or modify sidebar portlets.
 
+'SidebarBeforeOutput': Allows to edit sidebar just before its output by skins.
+$skin Skin object
+&$bar: Sidebar content
+Modify $bar to add or modify sidebar portlets.
+Warning: This hook is run on each display. You should consider to use 'SkinBuildSidebar' that is aggressively cached.
+
 'SkinCopyrightFooter': Allow for site and per-namespace customization of
 copyright notice.
 $title: displayed page title
index 0a4b5ee..3bb1563 100644 (file)
@@ -832,8 +832,9 @@ class Article implements Page {
         * Show a page view for a page formatted as CSS or JavaScript. To be called by
         * Article::view() only.
         *
-        * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
-        * page views.
+        * This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views).
+        * It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with
+        * more flexibility.
         *
         * @param bool $showCacheHint Whether to show a message telling the user
         *   to clear the browser cache (default: true).
index 8e5b872..09f1667 100644 (file)
@@ -952,7 +952,6 @@ $wgAutoloadLocalClasses = array(
        'HTMLBlockedUsersItemSelect' => 'includes/specials/SpecialBlockList.php',
        'ImageListPager' => 'includes/specials/SpecialListfiles.php',
        'ImportReporter' => 'includes/specials/SpecialImport.php',
-       'IPBlockForm' => 'includes/specials/SpecialBlock.php',
        'LinkSearchPage' => 'includes/specials/SpecialLinkSearch.php',
        'ListredirectsPage' => 'includes/specials/SpecialListredirects.php',
        'ListDuplicatedFilesPage' => 'includes/specials/SpecialListDuplicatedFiles.php',
@@ -1063,7 +1062,6 @@ $wgAutoloadLocalClasses = array(
        'WantedFilesPage' => 'includes/specials/SpecialWantedfiles.php',
        'WantedPagesPage' => 'includes/specials/SpecialWantedpages.php',
        'WantedTemplatesPage' => 'includes/specials/SpecialWantedtemplates.php',
-       'WatchlistEditor' => 'includes/specials/SpecialEditWatchlist.php',
        'WithoutInterwikiPage' => 'includes/specials/SpecialWithoutinterwiki.php',
 
        # includes/templates
index 5d35c42..cf94bae 100644 (file)
@@ -2893,11 +2893,6 @@ $wgShowIPinHeader = true;
  */
 $wgSiteNotice = '';
 
-/**
- * A subtitle to add to the tagline, for skins that have it/
- */
-$wgExtraSubtitle = '';
-
 /**
  * If this is set, a "donate" link will appear in the sidebar. Set it to a URL.
  */
index 56786f1..4781667 100644 (file)
@@ -270,7 +270,7 @@ class MagicWord {
         * Allow external reads of TTL array
         *
         * @param int $id
-        * @return array
+        * @return int
         */
        static function getCacheTTL( $id ) {
                if ( array_key_exists( $id, self::$mCacheTTLs ) ) {
index 8300da7..cfa059e 100644 (file)
@@ -1244,6 +1244,8 @@ abstract class Skin extends ContextSource {
                if ( $wgEnableSidebarCache ) {
                        $cachedsidebar = $wgMemc->get( $key );
                        if ( $cachedsidebar ) {
+                               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
+
                                wfProfileOut( __METHOD__ );
                                return $cachedsidebar;
                        }
@@ -1257,6 +1259,8 @@ abstract class Skin extends ContextSource {
                        $wgMemc->set( $key, $bar, $wgSidebarCacheExpiry );
                }
 
+               wfRunHooks( 'SidebarBeforeOutput', array( $this, &$bar ) );
+
                wfProfileOut( __METHOD__ );
                return $bar;
        }
index 1ec2792..2885e6a 100644 (file)
@@ -58,7 +58,7 @@ class MailAddress {
                if ( $this->address ) {
                        if ( $this->name != '' && !wfIsWindows() ) {
                                global $wgEnotifUseRealName;
-                               $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
+                               $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name;
                                $quoted = UserMailer::quotedPrintable( $name );
                                if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
                                        $quoted = '"' . $quoted . '"';
@@ -761,7 +761,8 @@ class EmailNotification {
                        $keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text();
 
                } else {
-                       $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
+                       $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== ''
+                               ? $this->editor->getRealName() : $this->editor->getName();
                        $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
                        $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
                }
@@ -868,7 +869,8 @@ class EmailNotification {
                        array( '$WATCHINGUSERNAME',
                                '$PAGEEDITDATE',
                                '$PAGEEDITTIME' ),
-                       array( $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName(),
+                       array( $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
+                                       ? $watchingUser->getRealName() : $watchingUser->getName(),
                                $wgContLang->userDate( $this->timestamp, $watchingUser ),
                                $wgContLang->userTime( $this->timestamp, $watchingUser ) ),
                        $this->body );
index 6f7121b..afd5a13 100644 (file)
@@ -112,7 +112,7 @@ class ApiFeedContributions extends ApiBase {
                        return new FeedItem(
                                $title->getPrefixedText(),
                                $this->feedItemDesc( $revision ),
-                               $title->getFullURL(),
+                               $title->getFullURL( array( 'diff' => $revision->getId() ) ),
                                $date,
                                $this->feedItemAuthor( $revision ),
                                $comments
index 545b94d..64c3eec 100644 (file)
@@ -34,7 +34,6 @@
 class ApiFeedWatchlist extends ApiBase {
 
        private $watchlistModule = null;
-       private $linkToDiffs = false;
        private $linkToSections = false;
 
        /**
@@ -73,7 +72,7 @@ class ApiFeedWatchlist extends ApiBase {
                                'meta' => 'siteinfo',
                                'siprop' => 'general',
                                'list' => 'watchlist',
-                               'wlprop' => 'title|user|comment|timestamp',
+                               'wlprop' => 'title|user|comment|timestamp|ids',
                                'wldir' => 'older', // reverse order - from newest to oldest
                                'wlend' => $endTime, // stop at this time
                                'wllimit' => min( 50, $wgFeedLimit )
@@ -95,12 +94,6 @@ class ApiFeedWatchlist extends ApiBase {
                                $fauxReqArr['wltype'] = $params['wltype'];
                        }
 
-                       // Support linking to diffs instead of article
-                       if ( $params['linktodiffs'] ) {
-                               $this->linkToDiffs = true;
-                               $fauxReqArr['wlprop'] .= '|ids';
-                       }
-
                        // Support linking directly to sections when possible
                        // (possible only if section name is present in comment)
                        if ( $params['linktosections'] ) {
@@ -173,7 +166,7 @@ class ApiFeedWatchlist extends ApiBase {
        private function createFeedItem( $info ) {
                $titleStr = $info['title'];
                $title = Title::newFromText( $titleStr );
-               if ( $this->linkToDiffs && isset( $info['revid'] ) ) {
+               if ( isset( $info['revid'] ) ) {
                        $titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) );
                } else {
                        $titleUrl = $title->getFullURL();
@@ -225,7 +218,6 @@ class ApiFeedWatchlist extends ApiBase {
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_MAX => 72,
                        ),
-                       'linktodiffs' => false,
                        'linktosections' => false,
                );
                if ( $flags ) {
@@ -254,7 +246,6 @@ class ApiFeedWatchlist extends ApiBase {
                return array(
                        'feedformat' => 'The format of the feed',
                        'hours' => 'List pages modified within this many hours from now',
-                       'linktodiffs' => 'Link to change differences instead of article pages',
                        'linktosections' => 'Link directly to changed sections if possible',
                        'allrev' => $wldescr['allrev'],
                        'wlowner' => $wldescr['owner'],
@@ -279,7 +270,7 @@ class ApiFeedWatchlist extends ApiBase {
        public function getExamples() {
                return array(
                        'api.php?action=feedwatchlist',
-                       'api.php?action=feedwatchlist&allrev=&linktodiffs=&hours=6'
+                       'api.php?action=feedwatchlist&allrev=&hours=6'
                );
        }
 
index 77d3542..8ba43f6 100644 (file)
@@ -450,4 +450,69 @@ abstract class AbstractContent implements Content {
 
                return $result;
        }
+
+       /**
+        * Returns a ParserOutput object containing information derived from this content.
+        * Most importantly, unless $generateHtml was false, the return value contains an
+        * HTML representation of the content.
+        *
+        * Subclasses that want to control the parser output may override this, but it is
+        * preferred to override fillParserOutput() instead.
+        *
+        * Subclasses that override getParserOutput() itself should take care to call the
+        * ContentGetParserOutput hook.
+        *
+        * @since 1.24
+        *
+        * @param Title $title Context title for parsing
+        * @param int|null $revId Revision ID (for {{REVISIONID}})
+        * @param ParserOptions|null $options Parser options
+        * @param bool $generateHtml Whether or not to generate HTML
+        *
+        * @return ParserOutput Containing information derived from this content.
+        */
+       public function getParserOutput( Title $title, $revId = null,
+               ParserOptions $options = null, $generateHtml = true
+       ) {
+               if ( $options === null ) {
+                       $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
+               }
+
+               $po = new ParserOutput();
+
+               if ( wfRunHooks( 'ContentGetParserOutput',
+                       array( $this, $title, $revId, $options, $generateHtml, &$po ) ) ) {
+
+                       $this->fillParserOutput( $title, $revId, $options, $generateHtml, $po );
+               }
+
+               return $po;
+       }
+
+       /**
+        * Fills the provided ParserOutput with information derived from the content.
+        * Unless $generateHtml was false, this includes an HTML representation of the content.
+        *
+        * This is called by getParserOutput() after consulting the ContentGetParserOutput hook.
+        * Subclasses are expected to override this method (or getParserOutput(), if need be).
+        * Subclasses of TextContent should generally override getHtml() instead.
+        *
+        * This placeholder implementation always throws an exception.
+        *
+        * @since 1.24
+        *
+        * @param Title $title Context title for parsing
+        * @param int|null $revId Revision ID (for {{REVISIONID}})
+        * @param ParserOptions|null $options Parser options
+        * @param bool $generateHtml Whether or not to generate HTML
+        * @param ParserOutput &$output The output object to fill (reference).
+        *
+        * @throws MWException
+        */
+       protected function fillParserOutput( Title $title, $revId,
+               ParserOptions $options, $generateHtml, ParserOutput &$output
+       ) {
+               // Don't make abstract, so subclasses that override getParserOutput() directly don't fail.
+               throw new MWException( 'Subclasses of AbstractContent must override fillParserOutput!' );
+       }
 }
index 4c95d3c..b772f17 100644 (file)
@@ -201,30 +201,30 @@ class TextContent extends AbstractContent {
        }
 
        /**
-        * Returns a generic ParserOutput object, wrapping the HTML returned by
-        * getHtml().
+        * Fills the provided ParserOutput object with information derived from the content.
+        * Unless $generateHtml was false, this includes an HTML representation of the content
+        * provided by getHtml().
+        *
+        * For content models listed in $wgTextModelsToParse, this method will call the MediaWiki
+        * wikitext parser on the text to extract any (wikitext) links, magic words, etc.
+        *
+        * Subclasses may override this to provide custom content processing.
+        * For custom HTML generation alone, it is sufficient to override getHtml().
         *
         * @param Title $title Context title for parsing
         * @param int $revId Revision ID (for {{REVISIONID}})
         * @param ParserOptions $options Parser options
         * @param bool $generateHtml Whether or not to generate HTML
-        *
-        * @return ParserOutput Representing the HTML form of the text.
+        * @param ParserOutput $output The output object to fill (reference).
         */
-       public function getParserOutput( Title $title, $revId = null,
-               ParserOptions $options = null, $generateHtml = true ) {
+       protected function fillParserOutput( Title $title, $revId,
+               ParserOptions $options, $generateHtml, ParserOutput &$output
+       ) {
                global $wgParser, $wgTextModelsToParse;
 
-               if ( !$options ) {
-                       //NOTE: use canonical options per default to produce cacheable output
-                       $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
-               }
-
                if ( in_array( $this->getModel(), $wgTextModelsToParse ) ) {
-                       // parse just to get links etc into the database
-                       $po = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
-               } else {
-                       $po = new ParserOutput();
+                       // parse just to get links etc into the database, HTML is replaced below.
+                       $output = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
                }
 
                if ( $generateHtml ) {
@@ -233,18 +233,16 @@ class TextContent extends AbstractContent {
                        $html = '';
                }
 
-               $po->setText( $html );
-
-               return $po;
+               $output->setText( $html );
        }
 
        /**
         * Generates an HTML version of the content, for display. Used by
-        * getParserOutput() to construct a ParserOutput object.
+        * fillParserOutput() to provide HTML for the ParserOutput object.
         *
         * Subclasses may override this to provide a custom HTML rendering.
         * If further information is to be derived from the content (such as
-        * categories), the getParserOutput() method can be overridden instead.
+        * categories), the fillParserOutput() method can be overridden instead.
         *
         * For backwards-compatibility, this default implementation just calls
         * getHighlightHtml().
index dba0205..ccea916 100644 (file)
@@ -311,41 +311,33 @@ class WikitextContent extends TextContent {
         * Returns a ParserOutput object resulting from parsing the content's text
         * using $wgParser.
         *
-        * @since 1.21
-        *
         * @param Title $title
         * @param int $revId Revision to pass to the parser (default: null)
         * @param ParserOptions $options (default: null)
         * @param bool $generateHtml (default: true)
-        *
-        * @return ParserOutput Representing the HTML form of the text
+        * @param &$output ParserOutput representing the HTML form of the text,
+        *           may be manipulated or replaced.
         */
-       public function getParserOutput( Title $title, $revId = null,
-               ParserOptions $options = null, $generateHtml = true ) {
+       protected function fillParserOutput( Title $title, $revId,
+                       ParserOptions $options, $generateHtml, ParserOutput &$output
+       ) {
                global $wgParser;
 
-               if ( !$options ) {
-                       //NOTE: use canonical options per default to produce cacheable output
-                       $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
-               }
-
                list( $redir, $text ) = $this->getRedirectTargetAndText();
-               $po = $wgParser->parse( $text, $title, $options, true, true, $revId );
+               $output = $wgParser->parse( $text, $title, $options, true, true, $revId );
 
                // Add redirect indicator at the top
                if ( $redir ) {
                        // Make sure to include the redirect link in pagelinks
-                       $po->addLink( $redir );
+                       $output->addLink( $redir );
                        if ( $generateHtml ) {
                                $chain = $this->getRedirectChain();
-                               $po->setText(
+                               $output->setText(
                                        Article::getRedirectHeaderHtml( $title->getPageLanguage(), $chain, false ) .
-                                       $po->getText()
+                                       $output->getText()
                                );
                        }
                }
-
-               return $po;
        }
 
        /**
index 003ccfe..6ea95ed 100644 (file)
@@ -5,7 +5,7 @@ class HTMLHiddenField extends HTMLFormField {
                parent::__construct( $params );
 
                # Per HTML5 spec, hidden fields cannot be 'required'
-               # http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#hidden-state
+               # http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
                unset( $this->mParams['required'] );
        }
 
index 372091a..85717c5 100644 (file)
@@ -200,7 +200,7 @@ abstract class Installer {
                '_NamespaceType' => 'site-name',
                '_AdminName' => '', // will be set later, when the user selects language
                '_AdminPassword' => '',
-               '_AdminPassword2' => '',
+               '_AdminPasswordConfirm' => '',
                '_AdminEmail' => '',
                '_Subscribe' => false,
                '_SkipOptional' => 'continue',
index 3b3473b..4de7f06 100644 (file)
@@ -790,7 +790,7 @@ class WebInstaller_Name extends WebInstallerPage {
                                'label' => 'config-admin-password',
                        ) ) .
                        $this->parent->getPasswordBox( array(
-                               'var' => '_AdminPassword2',
+                               'var' => '_AdminPasswordConfirm',
                                'label' => 'config-admin-password-confirm'
                        ) ) .
                        $this->parent->getTextBox( array(
@@ -829,7 +829,7 @@ class WebInstaller_Name extends WebInstallerPage {
        public function submit() {
                $retVal = true;
                $this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
-                       '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
+                       '_AdminName', '_AdminPassword', '_AdminPasswordConfirm', '_AdminEmail',
                        '_Subscribe', '_SkipOptional', 'wgMetaNamespace' ) );
 
                // Validate site name
@@ -911,7 +911,7 @@ class WebInstaller_Name extends WebInstallerPage {
                        # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
                        # This message is more specific and helpful.
                        $msg = 'config-admin-password-blank';
-               } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
+               } elseif ( $pwd !== $this->getVar( '_AdminPasswordConfirm' ) ) {
                        $msg = 'config-admin-password-mismatch';
                } elseif ( $valid !== true ) {
                        $msg = $valid;
@@ -919,7 +919,7 @@ class WebInstaller_Name extends WebInstallerPage {
                if ( $msg !== false ) {
                        call_user_func_array( array( $this->parent, 'showError' ), (array)$msg );
                        $this->setVar( '_AdminPassword', '' );
-                       $this->setVar( '_AdminPassword2', '' );
+                       $this->setVar( '_AdminPasswordConfirm', '' );
                        $retVal = false;
                }
 
index 464bacd..91f404a 100644 (file)
@@ -32,11 +32,23 @@ class CacheTime {
         */
        public $mUsedOptions;
 
-       var     $mVersion = Parser::VERSION,  # Compatibility check
-               $mCacheTime = '',             # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
-               $mCacheExpiry = null,         # Seconds after which the object should expire, use 0 for uncachable. Used in ParserCache.
-               $mContainsOldMagic,           # Boolean variable indicating if the input contained variables like {{CURRENTDAY}}
-               $mCacheRevisionId = null;     # Revision ID that was parsed
+       /** @var string Compatibility check */
+       protected $mVersion = Parser::VERSION;
+
+       /** @var string Time when this object was generated, or -1 for uncacheable. Used in ParserCache. */
+       protected $mCacheTime = '';
+
+       /**
+        * @var int Seconds after which the object should expire, use 0 for uncachable.
+        *   Used in ParserCache.
+        */
+       protected $mCacheExpiry = null;
+
+       /** @var bool Boolean variable indicating if the input contained variables like {{CURRENTDAY}} */
+       protected $mContainsOldMagic;
+
+       /** @var int Revision ID that was parsed */
+       protected $mCacheRevisionId = null;
 
        /**
         * @return string TS_MW timestamp
@@ -161,12 +173,14 @@ class CacheTime {
         */
        public function expired( $touched ) {
                global $wgCacheEpoch;
-               return !$this->isCacheable() || // parser says it's uncacheable
-                       $this->getCacheTime() < $touched ||
-                       $this->getCacheTime() <= $wgCacheEpoch ||
-                       $this->getCacheTime() < wfTimestamp( TS_MW, time() - $this->getCacheExpiry() ) || // expiry period has passed
-                       !isset( $this->mVersion ) ||
-                       version_compare( $this->mVersion, Parser::VERSION, "lt" );
+
+               return !$this->isCacheable() // parser says it's uncacheable
+                       || $this->getCacheTime() < $touched
+                       || $this->getCacheTime() <= $wgCacheEpoch
+                       || $this->getCacheTime() <
+                               wfTimestamp( TS_MW, time() - $this->getCacheExpiry() ) // expiry period has passed
+                       || !isset( $this->mVersion )
+                       || version_compare( $this->mVersion, Parser::VERSION, "lt" );
        }
 
        /**
index 65c3e1d..8d52a5b 100644 (file)
@@ -71,7 +71,11 @@ class CoreParserFunctions {
                        $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
                }
                if ( $wgAllowSlowParserFunctions ) {
-                       $parser->setFunctionHook( 'pagesinnamespace', array( __CLASS__, 'pagesinnamespace' ), SFH_NO_HASH );
+                       $parser->setFunctionHook(
+                               'pagesinnamespace',
+                               array( __CLASS__, 'pagesinnamespace' ),
+                               SFH_NO_HASH
+                       );
                }
        }
 
@@ -83,7 +87,9 @@ class CoreParserFunctions {
        static function intFunction( $parser, $part1 = '' /*, ... */ ) {
                if ( strval( $part1 ) !== '' ) {
                        $args = array_slice( func_get_args(), 2 );
-                       $message = wfMessage( $part1, $args )->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
+                       $message = wfMessage( $part1, $args )
+                               ->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
+
                        return array( $message, 'noparse' => false );
                } else {
                        return array( 'found' => false );
@@ -393,12 +399,21 @@ class CoreParserFunctions {
                // only requested titles that normalize to the actual title are allowed through
                // if $wgRestrictDisplayTitle is true (it is by default)
                // mimic the escaping process that occurs in OutputPage::setPageTitle
-               $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $text, $htmlTagsCallback, array(), array(), $bad ) );
+               $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
+                       $text,
+                       $htmlTagsCallback,
+                       array(),
+                       array(),
+                       $bad
+               ) );
                $title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
 
                if ( !$wgRestrictDisplayTitle ) {
                        $parser->mOutput->setDisplayTitle( $text );
-               } elseif ( $title instanceof Title && !$title->hasFragment() && $title->equals( $parser->mTitle ) ) {
+               } elseif ( $title instanceof Title
+                       && !$title->hasFragment()
+                       && $title->equals( $parser->mTitle )
+               ) {
                        $parser->mOutput->setDisplayTitle( $text );
                }
 
@@ -855,8 +870,9 @@ class CoreParserFunctions {
                }
        }
 
-       // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}} or {{filepath|300|nowiki}}
-       // or {{filepath|300px}}, {{filepath|200x300px}}, {{filepath|nowiki|200x300px}}, {{filepath|200x300px|nowiki}}
+       // Usage {{filepath|300}}, {{filepath|nowiki}}, {{filepath|nowiki|300}}
+       // or {{filepath|300|nowiki}} or {{filepath|300px}}, {{filepath|200x300px}},
+       // {{filepath|nowiki|200x300px}}, {{filepath|200x300px|nowiki}}.
        public static function filepath( $parser, $name = '', $argA = '', $argB = '' ) {
                $file = wfFindFile( $name );
 
index 3ddc9d4..54c6dec 100644 (file)
  * @ingroup Parser
  */
 class DateFormatter {
-       var $mSource, $mTarget;
-       var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
+       protected $mSource;
 
-       var $regexes, $pDays, $pMonths, $pYears;
-       var $rules, $xMonths, $preferences;
+       protected $mTarget;
+
+       /** @var string */
+       protected $monthNames = '';
+
+       /** @todo Are these unused? */
+       private $rxDM;
+       private $rxMD;
+       private $rxDMY;
+       private $rxYDM;
+       private $rxMDY;
+       private $rxYMD;
+
+       /** @var array */
+       protected $regexes;
+
+       /** @todo Are these unused? */
+       private $pDays;
+       private $pMonths;
+       private $pYears;
+
+       /** @var array */
+       protected $rules;
+
+       /** @var array */
+       protected $xMonths;
+
+       /** @var array */
+       protected $preferences;
+
+       /** @var bool */
+       protected $mLinked;
 
        protected $lang;
 
@@ -205,7 +234,8 @@ class DateFormatter {
 
                $bits = array();
                $key = $this->keys[$this->mSource];
-               for ( $p = 0; $p < strlen( $key ); $p++ ) {
+               $keyLength = strlen( $key );
+               for ( $p = 0; $p < $keyLength; $p++ ) {
                        if ( $key[$p] != ' ' ) {
                                $bits[$key[$p]] = $matches[$p + 1];
                        }
@@ -254,7 +284,8 @@ class DateFormatter {
                        $bits['d'] = sprintf( '%02d', $bits['j'] );
                }
 
-               for ( $p = 0; $p < strlen( $format ); $p++ ) {
+               $formatLength = strlen( $format );
+               for ( $p = 0; $p < $formatLength; $p++ ) {
                        $char = $format[$p];
                        switch ( $char ) {
                                case 'd': # ISO day of month
index 2f95af2..dc0f933 100644 (file)
  * @ingroup Parser
  */
 class LinkHolderArray {
-       var $internals = array(), $interwikis = array();
-       var $size = 0;
-       var $parent;
+       /** @var array */
+       public $internals = array();
+
+       /** @var array */
+       public $interwikis = array();
+
+       /** @var int */
+       protected $size = 0;
+
+       /** @var Parser */
+       protected $parent;
+
+       /** @var int */
        protected $tempIdOffset;
 
        function __construct( $parent ) {
@@ -334,7 +344,8 @@ class LinkHolderArray {
 
                        $res = $dbr->select(
                                'page',
-                               array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+                               array( 'page_id', 'page_namespace', 'page_title',
+                                       'page_is_redirect', 'page_len', 'page_latest' ),
                                $dbr->makeList( $where, LIST_OR ),
                                __METHOD__
                        );
@@ -537,7 +548,8 @@ class LinkHolderArray {
                        // construct query
                        $dbr = wfGetDB( DB_SLAVE );
                        $varRes = $dbr->select( 'page',
-                               array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
+                               array( 'page_id', 'page_namespace', 'page_title',
+                                       'page_is_redirect', 'page_len', 'page_latest' ),
                                $linkBatch->constructSet( 'page', $dbr ),
                                __METHOD__
                        );
index 227937a..5a6dd9e 100644 (file)
@@ -119,103 +119,203 @@ class Parser {
        const TOC_START = '<mw:toc>';
        const TOC_END = '</mw:toc>';
 
-       # Persistent:
-       var $mTagHooks = array();
-       var $mTransparentTagHooks = array();
-       var $mFunctionHooks = array();
-       var $mFunctionSynonyms = array( 0 => array(), 1 => array() );
-       var $mFunctionTagHooks = array();
-       var $mStripList = array();
-       var $mDefaultStripList = array();
-       var $mVarCache = array();
-       var $mImageParams = array();
-       var $mImageParamsMagicArray = array();
-       var $mMarkerIndex = 0;
-       var $mFirstCall = true;
+       # Persistent
 
-       # Initialised by initialiseVariables()
+       /** @var array */
+       public $mTagHooks = array();
 
-       /**
-        * @var MagicWordArray
-        */
-       var $mVariables;
+       /** @var array */
+       public $mTransparentTagHooks = array();
+
+       /** @var array */
+       public $mFunctionHooks = array();
+
+       /** @var array */
+       protected $mFunctionSynonyms = array( 0 => array(), 1 => array() );
+
+       /** @var array */
+       protected $mFunctionTagHooks = array();
+
+       /** @var array */
+       protected $mStripList = array();
 
        /**
-        * @var MagicWordArray
+        * @var array
+        * @todo Unused?
         */
-       var $mSubstWords;
-       var $mConf, $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols; # Initialised in constructor
+       private $mDefaultStripList = array();
+
+       /** @var array */
+       protected $mVarCache = array();
+
+       /** @var array */
+       protected $mImageParams = array();
+
+       /** @var array */
+       protected $mImageParamsMagicArray = array();
+
+       /** @var int */
+       public $mMarkerIndex = 0;
+
+       /** @var bool */
+       protected $mFirstCall = true;
+
+       # Initialised by initialiseVariables()
+
+       /** @var MagicWordArray */
+       public $mVariables;
+
+       /** @var MagicWordArray */
+       protected $mSubstWords;
+
+       # Initialised in constructor
+
+       /** @var array */
+       protected $mConf;
+
+       /** @var Parser */
+       public $mPreprocessor;
+
+       /** @var string */
+       protected $mExtLinkBracketedRegex;
+
+       /** @var string */
+       protected $mUrlProtocols;
 
        # Cleared with clearState():
-       /**
-        * @var ParserOutput
-        */
-       var $mOutput;
-       var $mAutonumber, $mDTopen;
+
+       /** @var ParserOutput */
+       public $mOutput;
+
+       /** @var int */
+       protected $mAutonumber;
+
+       /** @var bool */
+       protected $mDTopen;
+
+       /** @var StripState */
+       public $mStripState;
 
        /**
-        * @var StripState
+        * @var array
+        * @todo Unused?
         */
-       var $mStripState;
+       private $mIncludeCount;
 
-       var $mIncludeCount, $mArgStack, $mLastSection, $mInPre;
        /**
-        * @var LinkHolderArray
+        * @var bool
+        * @todo Unused?
         */
-       var $mLinkHolders;
+       private $mArgStack;
 
-       var $mLinkID;
-       var $mIncludeSizes, $mPPNodeCount, $mGeneratedPPNodeCount, $mHighestExpansionDepth;
-       var $mDefaultSort;
-       var $mTplExpandCache; # empty-frame expansion cache
-       var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
-       var $mExpensiveFunctionCount; # number of expensive parser function calls
-       var $mShowToc, $mForceTocPosition;
+       /** @var string */
+       protected $mLastSection;
 
-       /**
-        * @var User
-        */
-       var $mUser; # User object; only used when doing pre-save transform
+       /** @var bool */
+       protected $mInPre;
+
+       /** @var LinkHolderArray */
+       protected $mLinkHolders;
+
+       /** @var int */
+       protected $mLinkID;
+
+       /** @var array */
+       protected $mIncludeSizes;
+
+       /** @var int */
+       public $mPPNodeCount;
+
+       /** @var int */
+       public $mGeneratedPPNodeCount;
+
+       /** @var int */
+       public $mHighestExpansionDepth;
+
+       /** @var bool|string */
+       protected $mDefaultSort;
+
+       /** @var array Empty-frame expansion cache */
+       protected $mTplExpandCache;
+
+       /** @var array */
+       protected $mTplRedirCache;
+
+       /** @var array */
+       protected $mTplDomCache;
+
+       /** @var array */
+       public $mHeadings;
+
+       /** @var array */
+       protected $mDoubleUnderscores;
+
+       /** @var int Number of expensive parser function calls */
+       protected $mExpensiveFunctionCount;
+
+       /** @var bool */
+       protected $mShowToc;
+
+       /** @var bool */
+       protected $mForceTocPosition;
+
+       /** @var User User object; only used when doing pre-save transform */
+       protected $mUser;
 
        # Temporary
        # These are variables reset at least once per parse regardless of $clearState
 
-       /**
-        * @var ParserOptions
-        */
-       var $mOptions;
+       /** @var ParserOptions */
+       public $mOptions;
 
-       /**
-        * @var Title
-        */
-       var $mTitle;        # Title context, used for self-link rendering and similar things
-       var $mOutputType;   # Output type, one of the OT_xxx constants
-       var $ot;            # Shortcut alias, see setOutputType()
-       var $mRevisionObject; # The revision object of the specified revision ID
-       var $mRevisionId;   # ID to display in {{REVISIONID}} tags
-       var $mRevisionTimestamp; # The timestamp of the specified revision ID
-       var $mRevisionUser; # User to display in {{REVISIONUSER}} tag
-       var $mRevisionSize; # Size to display in {{REVISIONSIZE}} variable
-       var $mRevIdForTs;   # The revision ID which was used to fetch the timestamp
-       var $mInputSize = false; # For {{PAGESIZE}} on current page.
+       /** @var Title Title context, used for self-link rendering and similar things */
+       public $mTitle;
+
+       /** @var array Shortcut alias, see setOutputType() */
+       public $ot;
+
+       /** @var string The timestamp of the specified revision ID */
+       public $mRevisionTimestamp;
+
+       /** @var string */
+       public $mUniqPrefix;
 
        /**
-        * @var string
+        * @var boolean Recursive call protection.
+        * This variable should be treated as if it were private.
         */
-       var $mUniqPrefix;
+       public $mInParse = false;
+
+       /** @var int Output type, one of the OT_xxx constants */
+       protected $mOutputType;
+
+       /** @var Revision The revision object of the specified revision ID */
+       protected $mRevisionObject;
+
+       /** @var int ID to display in {{REVISIONID}} tags */
+       protected $mRevisionId;
+
+       /** @var string User to display in {{REVISIONUSER}} tag */
+       protected $mRevisionUser;
+
+       /** @var int Size to display in {{REVISIONSIZE}} variable */
+       protected $mRevisionSize;
+
+       /** @var bool|int For {{PAGESIZE}} on current page. */
+       protected $mInputSize = false;
 
        /**
         * @var array Array with the language name of each language link (i.e. the
         * interwiki prefix) in the key, value arbitrary. Used to avoid sending
         * duplicate language links to the ParserOutput.
         */
-       var $mLangLinkLanguages;
+       protected $mLangLinkLanguages;
 
        /**
-        * @var boolean Recursive call protection.
-        * This variable should be treated as if it were private.
+        * @var int The revision ID which was used to fetch the timestamp
+        * @todo Unused?
         */
-       public $mInParse = false;
+       private $mRevIdForTs;
 
        /**
         * Constructor
@@ -360,7 +460,9 @@ class Parser {
         * @param int $revid Number to pass in {{REVISIONID}}
         * @return ParserOutput A ParserOutput
         */
-       public function parse( $text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null ) {
+       public function parse( $text, Title $title, ParserOptions $options,
+               $linestart = true, $clearState = true, $revid = null
+       ) {
                /**
                 * First pass--just handle <nowiki> sections, pass the rest off
                 * to internalParse() which does all the real work.
@@ -1091,7 +1193,10 @@ class Parser {
                                array_push( $tr_history, false );
                                array_push( $td_history, false );
                                array_push( $last_tag_history, '' );
-                       } elseif ( $first_character === '|' || $first_character === '!' || substr( $line, 0, 2 ) === '|+' ) {
+                       } elseif ( $first_character === '|'
+                               || $first_character === '!'
+                               || substr( $line, 0, 2 ) === '|+'
+                       ) {
                                # This might be cell elements, td, th or captions
                                if ( substr( $line, 0, 2 ) === '|+' ) {
                                        $first_character = '+';
@@ -1236,7 +1341,12 @@ class Parser {
                }
 
                wfRunHooks( 'InternalParseBeforeSanitize', array( &$this, &$text, &$this->mStripState ) );
-               $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) );
+               $text = Sanitizer::removeHTMLtags(
+                       $text,
+                       array( &$this, 'attributeStripCallback' ),
+                       false,
+                       array_keys( $this->mTransparentTagHooks )
+               );
                wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) );
 
                # Tables need to come after variable replacement for things to work
@@ -1642,7 +1752,8 @@ class Parser {
                $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
                if ( $bits === false ) {
                        wfProfileOut( __METHOD__ );
-                       throw new MWException( "PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function" );
+                       throw new MWException( "PCRE needs to be compiled with "
+                               . "--enable-unicode-properties in order for MediaWiki to function" );
                }
                $s = array_shift( $bits );
 
@@ -1812,16 +1923,23 @@ class Parser {
                } else {
                        $imagematch = false;
                }
+
                if ( $this->mOptions->getAllowExternalImages()
-                       || ( $imagesexception && $imagematch ) ) {
+                       || ( $imagesexception && $imagematch )
+               ) {
                        if ( preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
                                # Image found
                                $text = Linker::makeExternalImage( $url );
                        }
                }
                if ( !$text && $this->mOptions->getEnableImageWhitelist()
-                       && preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
-                       $whitelist = explode( "\n", wfMessage( 'external_image_whitelist' )->inContentLanguage()->text() );
+                       && preg_match( self::EXT_IMAGE_REGEX, $url )
+               ) {
+                       $whitelist = explode(
+                               "\n",
+                               wfMessage( 'external_image_whitelist' )->inContentLanguage()->text()
+                       );
+
                        foreach ( $whitelist as $entry ) {
                                # Sanitize the regex fragment, make it case-insensitive, ignore blank entries/comments
                                if ( strpos( $entry, '#' ) === 0 || $entry === '' ) {
@@ -1914,8 +2032,11 @@ class Parser {
                $useSubpages = $this->areSubpagesAllowed();
                wfProfileOut( __METHOD__ . '-setup' );
 
+               // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
                # Loop for each link
                for ( ; $line !== false && $line !== null; $a->next(), $line = $a->current() ) {
+                       // @codingStandardsIgnoreStart
+
                        # Check for excessive memory usage
                        if ( $holders->isBig() ) {
                                # Too big
@@ -1966,7 +2087,8 @@ class Parser {
                                        $m[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $m[1] ) );
                                }
                                $trail = $m[3];
-                       } elseif ( preg_match( $e1_img, $line, $m ) ) { # Invalid, but might be an image with a link in its caption
+                       } elseif ( preg_match( $e1_img, $line, $m ) ) {
+                               # Invalid, but might be an image with a link in its caption
                                $might_be_img = true;
                                $text = $m[2];
                                if ( strpos( $m[1], '%' ) !== false ) {
@@ -2076,7 +2198,9 @@ class Parser {
                        if ( $noforce ) {
                                # Interwikis
                                wfProfileIn( __METHOD__ . "-interwiki" );
-                               if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) {
+                               if ( $iw && $this->mOptions->getInterwikiMagic()
+                                       && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' )
+                               ) {
                                        // XXX: the above check prevents links to sites with identifiers that are not language codes
 
                                        # Bug 24502: filter duplicates
@@ -2488,10 +2612,19 @@ class Parser {
                                wfProfileIn( __METHOD__ . "-paragraph" );
                                # No prefix (not in list)--go to paragraph mode
                                # XXX: use a stack for nestable elements like span, table and div
-                               $openmatch = preg_match( '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
+                               $openmatch = preg_match(
+                                       '/(?:<table|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|'
+                                               . '<p|<ul|<ol|<dl|<li|<\\/tr|<\\/td|<\\/th)/iS',
+                                       $t
+                               );
                                $closematch = preg_match(
-                                       '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|' .
-                                       '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|' . $this->mUniqPrefix . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS', $t );
+                                       '/(?:<\\/table|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'
+                                               . '<td|<th|<\\/?blockquote|<\\/?div|<hr|<\\/pre|<\\/p|<\\/mw:|'
+                                               . $this->mUniqPrefix
+                                               . '-pre|<\\/li|<\\/ul|<\\/ol|<\\/dl|<\\/?center)/iS',
+                                       $t
+                               );
+
                                if ( $openmatch or $closematch ) {
                                        $paragraphStack = false;
                                        # TODO bug 5718: paragraph closed
@@ -2506,7 +2639,10 @@ class Parser {
                                        }
                                        $inBlockElem = !$closematch;
                                } elseif ( !$inBlockElem && !$this->mInPre ) {
-                                       if ( ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' || trim( $t ) != '' ) and !$inBlockquote ) {
+                                       if ( ' ' == substr( $t, 0, 1 )
+                                               && ( $this->mLastSection === 'pre' || trim( $t ) != '' )
+                                               && !$inBlockquote
+                                       ) {
                                                # pre
                                                if ( $this->mLastSection !== 'pre' ) {
                                                        $paragraphStack = false;
@@ -2836,13 +2972,21 @@ class Parser {
                                $value = wfEscapeWikiText( $this->mTitle->getRootText() );
                                break;
                        case 'rootpagenamee':
-                               $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getRootText() ) ) );
+                               $value = wfEscapeWikiText( wfUrlEncode( str_replace(
+                                       ' ',
+                                       '_',
+                                       $this->mTitle->getRootText()
+                               ) ) );
                                break;
                        case 'basepagename':
                                $value = wfEscapeWikiText( $this->mTitle->getBaseText() );
                                break;
                        case 'basepagenamee':
-                               $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ) );
+                               $value = wfEscapeWikiText( wfUrlEncode( str_replace(
+                                       ' ',
+                                       '_',
+                                       $this->mTitle->getBaseText()
+                               ) ) );
                                break;
                        case 'talkpagename':
                                if ( $this->mTitle->canTalk() ) {
@@ -2953,7 +3097,9 @@ class Parser {
                                $value = $this->mTitle->getNamespace();
                                break;
                        case 'talkspace':
-                               $value = $this->mTitle->canTalk() ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() ) : '';
+                               $value = $this->mTitle->canTalk()
+                                       ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() )
+                                       : '';
                                break;
                        case 'talkspacee':
                                $value = $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : '';
@@ -2985,13 +3131,19 @@ class Parser {
                                $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'w' ) );
                                break;
                        case 'localdayname':
-                               $value = $pageLang->getWeekdayName( (int)MWTimestamp::getLocalInstance( $ts )->format( 'w' ) + 1 );
+                               $value = $pageLang->getWeekdayName(
+                                       (int)MWTimestamp::getLocalInstance( $ts )->format( 'w' ) + 1
+                               );
                                break;
                        case 'localyear':
                                $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'Y' ), true );
                                break;
                        case 'localtime':
-                               $value = $pageLang->time( MWTimestamp::getLocalInstance( $ts )->format( 'YmdHis' ), false, false );
+                               $value = $pageLang->time(
+                                       MWTimestamp::getLocalInstance( $ts )->format( 'YmdHis' ),
+                                       false,
+                                       false
+                               );
                                break;
                        case 'localhour':
                                $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'H' ), true );
@@ -3060,7 +3212,11 @@ class Parser {
                                break;
                        default:
                                $ret = null;
-                               wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$this->mVarCache, &$index, &$ret, &$frame ) );
+                               wfRunHooks(
+                                       'ParserGetVariableValueSwitch',
+                                       array( &$this, &$this->mVarCache, &$index, &$ret, &$frame )
+                               );
+
                                return $ret;
                }
 
@@ -3162,7 +3318,8 @@ class Parser {
                if ( $frame === false ) {
                        $frame = $this->getPreprocessor()->newFrame();
                } elseif ( !( $frame instanceof PPFrame ) ) {
-                       wfDebug( __METHOD__ . " called using plain parameters instead of a PPFrame instance. Creating custom frame.\n" );
+                       wfDebug( __METHOD__ . " called using plain parameters instead of "
+                               . "a PPFrame instance. Creating custom frame.\n" );
                        $frame = $this->getPreprocessor()->newCustomFrame( $frame );
                }
 
@@ -3252,13 +3409,20 @@ class Parser {
                wfProfileIn( __METHOD__ );
                wfProfileIn( __METHOD__ . '-setup' );
 
-               # Flags
-               $found = false;             # $text has been filled
-               $nowiki = false;            # wiki markup in $text should be escaped
-               $isHTML = false;            # $text is HTML, armour it against wikitext transformation
-               $forceRawInterwiki = false; # Force interwiki transclusion to be done in raw mode not rendered
-               $isChildObj = false;        # $text is a DOM node needing expansion in a child frame
-               $isLocalObj = false;        # $text is a DOM node needing expansion in the current frame
+               // Flags
+
+               // $text has been filled
+               $found = false;
+               // wiki markup in $text should be escaped
+               $nowiki = false;
+               // $text is HTML, armour it against wikitext transformation
+               $isHTML = false;
+               // Force interwiki transclusion to be done in raw mode not rendered
+               $forceRawInterwiki = false;
+               // $text is a DOM node needing expansion in a child frame
+               $isChildObj = false;
+               // $text is a DOM node needing expansion in the current frame
+               $isLocalObj = false;
 
                # Title object, where $text came from
                $title = false;
@@ -3273,7 +3437,8 @@ class Parser {
                $originalTitle = $part1;
 
                # $args is a list of argument nodes, starting from index 0, not including $part1
-               # @todo FIXME: If piece['parts'] is null then the call to getLength() below won't work b/c this $args isn't an object
+               # @todo FIXME: If piece['parts'] is null then the call to getLength()
+               # below won't work b/c this $args isn't an object
                $args = ( null == $piece['parts'] ) ? array() : $piece['parts'];
                wfProfileOut( __METHOD__ . '-setup' );
 
@@ -3413,7 +3578,8 @@ class Parser {
                                        // "uselang" will have no effect since the Language object
                                        // is forced to the one defined in ParserOptions.
                                        $pageArgs = array();
-                                       for ( $i = 0; $i < $args->getLength(); $i++ ) {
+                                       $argsLength = $args->getLength();
+                                       for ( $i = 0; $i < $argsLength; $i++ ) {
                                                $bits = $args->item( $i )->splitArg();
                                                if ( strval( $bits['index'] ) === '' ) {
                                                        $name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
@@ -3546,7 +3712,8 @@ class Parser {
                                preg_replace( '/^:/', '', $originalTitle );
                                $text = "[[:$originalTitle]]";
                        }
-                       $text .= $this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
+                       $text .= $this->insertStripItem( '<!-- WARNING: template omitted, '
+                               . 'post-expand include size too large -->' );
                        $this->limitationWarn( 'post-expand-template-inclusion' );
                }
 
@@ -3720,7 +3887,8 @@ class Parser {
         * @return array ( string or false, Title )
         */
        function fetchTemplateAndTitle( $title ) {
-               $templateCb = $this->mOptions->getTemplateCallback(); # Defaults to Parser::statelessFetchTemplate()
+               // Defaults to Parser::statelessFetchTemplate()
+               $templateCb = $this->mOptions->getTemplateCallback();
                $stuff = call_user_func( $templateCb, $title, $this );
                $text = $stuff['text'];
                $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
@@ -3929,8 +4097,10 @@ class Parser {
                $status = $req->execute(); // Status object
                if ( $status->isOK() ) {
                        $text = $req->getContent();
-               } elseif ( $req->getStatus() != 200 ) { // Though we failed to fetch the content, this status is useless.
-                       return wfMessage( 'scarytranscludefailed-httpstatus', $url, $req->getStatus() /* HTTP status */ )->inContentLanguage()->text();
+               } elseif ( $req->getStatus() != 200 ) {
+                       // Though we failed to fetch the content, this status is useless.
+                       return wfMessage( 'scarytranscludefailed-httpstatus' )
+                               ->params( $url, $req->getStatus() /* HTTP status */ )->inContentLanguage()->text();
                } else {
                        return wfMessage( 'scarytranscludefailed', $url )->inContentLanguage()->text();
                }
@@ -4012,7 +4182,8 @@ class Parser {
                $name = $frame->expand( $params['name'] );
                $attrText = !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] );
                $content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
-               $marker = "{$this->mUniqPrefix}-$name-" . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;
+               $marker = "{$this->mUniqPrefix}-$name-"
+                       . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;
 
                $isFunctionTag = isset( $this->mFunctionTagHooks[strtolower( $name )] ) &&
                        ( $this->ot['html'] || $this->ot['pre'] );
@@ -4144,7 +4315,9 @@ class Parser {
                if ( isset( $this->mDoubleUnderscores['notoc'] ) && !$this->mForceTocPosition ) {
                        $this->mShowToc = false;
                }
-               if ( isset( $this->mDoubleUnderscores['hiddencat'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) {
+               if ( isset( $this->mDoubleUnderscores['hiddencat'] )
+                       && $this->mTitle->getNamespace() == NS_CATEGORY
+               ) {
                        $this->addTrackingCategory( 'hidden-category-category' );
                }
                # (bug 8068) Allow control over whether robots index a page.
@@ -4239,7 +4412,11 @@ class Parser {
                # Get all headlines for numbering them and adding funky stuff like [edit]
                # links - this is for later, but we need the number of headlines right now
                $matches = array();
-               $numMatches = preg_match_all( '/<H(?P<level>[1-6])(?P<attrib>.*?' . '>)\s*(?P<header>[\s\S]*?)\s*<\/H[1-6] *>/i', $text, $matches );
+               $numMatches = preg_match_all(
+                       '/<H(?P<level>[1-6])(?P<attrib>.*?' . '>)\s*(?P<header>[\s\S]*?)\s*<\/H[1-6] *>/i',
+                       $text,
+                       $matches
+               );
 
                # if there are fewer than 4 headlines in the article, do not show TOC
                # unless it's been explicitly enabled.
@@ -4388,7 +4565,10 @@ class Parser {
                        # We strip any parameter from accepted tags (second regex), except dir="rtl|ltr" from <span>,
                        # to allow setting directionality in toc items.
                        $tocline = preg_replace(
-                               array( '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?' . '>#', '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?' . '>#' ),
+                               array(
+                                       '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?' . '>#',
+                                       '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?' . '>#'
+                               ),
                                array( '', '<$1>' ),
                                $safeHeadline
                        );
@@ -4452,7 +4632,11 @@ class Parser {
                        # Don't number the heading if it is the only one (looks silly)
                        if ( count( $matches[3] ) > 1 && $this->mOptions->getNumberHeadings() ) {
                                # the two are different if the line contains a link
-                               $headline = Html::element( 'span', array( 'class' => 'mw-headline-number' ), $numbering ) . ' ' . $headline;
+                               $headline = Html::element(
+                                       'span',
+                                       array( 'class' => 'mw-headline-number' ),
+                                       $numbering
+                               ) . ' ' . $headline;
                        }
 
                        # Create the anchor for linking from the TOC to the section
@@ -4502,14 +4686,22 @@ class Parser {
                                        # that sections inside <includeonly> should be counted.
                                        $editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
                                } else {
-                                       $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
+                                       $editlinkArgs = array(
+                                               $this->mTitle->getPrefixedText(),
+                                               $sectionIndex,
+                                               $headlineHint
+                                       );
                                }
-                               // We use a bit of pesudo-xml for editsection markers. The language converter is run later on
-                               // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff
-                               // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped
-                               // so we don't have to worry about a user trying to input one of these markers directly.
-                               // We use a page and section attribute to stop the language converter from converting these important bits
-                               // of data, but put the headline hint inside a content block because the language converter is supposed to
+                               // We use a bit of pesudo-xml for editsection markers. The
+                               // language converter is run later on. Using a UNIQ style marker
+                               // leads to the converter screwing up the tokens when it
+                               // converts stuff. And trying to insert strip tags fails too. At
+                               // this point all real inputted tags have already been escaped,
+                               // so we don't have to worry about a user trying to input one of
+                               // these markers directly. We use a page and section attribute
+                               // to stop the language converter from converting these
+                               // important bits of data, but put the headline hint inside a
+                               // content block because the language converter is supposed to
                                // be able to convert that piece of data.
                                $editlink = '<mw:editsection page="' . htmlspecialchars( $editlinkArgs[0] );
                                $editlink .= '" section="' . htmlspecialchars( $editlinkArgs[1] ) . '"';
@@ -4604,7 +4796,9 @@ class Parser {
         * @param bool $clearState Whether to clear the parser state first
         * @return string The altered wiki markup
         */
-       public function preSaveTransform( $text, Title $title, User $user, ParserOptions $options, $clearState = true ) {
+       public function preSaveTransform( $text, Title $title, User $user,
+               ParserOptions $options, $clearState = true
+       ) {
                if ( $clearState ) {
                        $magicScopeVariable = $this->lock();
                }
@@ -4676,10 +4870,14 @@ class Parser {
                $tc = '[' . Title::legalChars() . ']';
                $nc = '[ _0-9A-Za-z\x80-\xff-]'; # Namespaces can use non-ascii!
 
-               $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";                   # [[ns:page (context)|]]
-               $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";                           # [[ns:page(context)|]] (double-width brackets, added in r40257)
-               $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/";         # [[ns:page (context), context|]] (using either single or double-width comma)
-               $p2 = "/\[\[\\|($tc+)]]/";                                              # [[|page]] (reverse pipe trick: add context from page title)
+               // [[ns:page (context)|]]
+               $p1 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\))\\|]]/";
+               // [[ns:page(context)|]] (double-width brackets, added in r40257)
+               $p4 = "/\[\[(:?$nc+:|:|)($tc+?)( ?($tc+))\\|]]/";
+               // [[ns:page (context), context|]] (using either single or double-width comma)
+               $p3 = "/\[\[(:?$nc+:|:|)($tc+?)( ?\\($tc+\\)|)((?:, |,)$tc+|)\\|]]/";
+               // [[|page]] (reverse pipe trick: add context from page title)
+               $p2 = "/\[\[\\|($tc+)]]/";
 
                # try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
                $text = preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text );
@@ -4756,7 +4954,8 @@ class Parser {
                $nickText = wfEscapeWikiText( $nickname );
                $msgName = $user->isAnon() ? 'signature-anon' : 'signature';
 
-               return wfMessage( $msgName, $userText, $nickText )->inContentLanguage()->title( $this->getTitle() )->text();
+               return wfMessage( $msgName, $userText, $nickText )->inContentLanguage()
+                       ->title( $this->getTitle() )->text();
        }
 
        /**
@@ -4830,7 +5029,9 @@ class Parser {
         * @param int $outputType
         * @param bool $clearState
         */
-       public function startExternalParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
+       public function startExternalParse( Title $title = null, ParserOptions $options,
+               $outputType, $clearState = true
+       ) {
                $this->startParse( $title, $options, $outputType, $clearState );
        }
 
@@ -4840,7 +5041,9 @@ class Parser {
         * @param int $outputType
         * @param bool $clearState
         */
-       private function startParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
+       private function startParse( Title $title = null, ParserOptions $options,
+               $outputType, $clearState = true
+       ) {
                $this->setTitle( $title );
                $this->mOptions = $options;
                $this->setOutputType( $outputType );
@@ -5580,7 +5783,11 @@ class Parser {
         * @return array
         */
        function getTags() {
-               return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ), array_keys( $this->mFunctionTagHooks ) );
+               return array_merge(
+                       array_keys( $this->mTransparentTagHooks ),
+                       array_keys( $this->mTagHooks ),
+                       array_keys( $this->mFunctionTagHooks )
+               );
        }
 
        /**
@@ -5603,7 +5810,10 @@ class Parser {
                        list( $element, $content, $params, $tag ) = $data;
                        $tagName = strtolower( $element );
                        if ( isset( $this->mTransparentTagHooks[$tagName] ) ) {
-                               $output = call_user_func_array( $this->mTransparentTagHooks[$tagName], array( $content, $params, $this ) );
+                               $output = call_user_func_array(
+                                       $this->mTransparentTagHooks[$tagName],
+                                       array( $content, $params, $this )
+                               );
                        } else {
                                $output = $tag;
                        }
@@ -6180,7 +6390,8 @@ class Parser {
         */
        protected function lock() {
                if ( $this->mInParse ) {
-                       throw new MWException( "Parser state cleared while parsing. Did you call Parser::parse recursively?" );
+                       throw new MWException( "Parser state cleared while parsing. "
+                               . "Did you call Parser::parse recursively?" );
                }
                $this->mInParse = true;
 
index e374361..f5f9441 100644 (file)
@@ -144,7 +144,8 @@ class ParserCache {
                        if ( !$useOutdated && $optionsKey->expired( $article->getTouched() ) ) {
                                wfIncrStats( "pcache_miss_expired" );
                                $cacheTime = $optionsKey->getCacheTime();
-                               wfDebug( "Parser options key expired, touched " . $article->getTouched() . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
+                               wfDebug( "Parser options key expired, touched " . $article->getTouched()
+                                       . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
                                return false;
                        } elseif ( $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
                                wfIncrStats( "pcache_miss_revid" );
@@ -164,7 +165,10 @@ class ParserCache {
                        $usedOptions = ParserOptions::legacyOptions();
                }
 
-               return $this->getParserOutputKey( $article, $popts->optionsHash( $usedOptions, $article->getTitle() ) );
+               return $this->getParserOutputKey(
+                       $article,
+                       $popts->optionsHash( $usedOptions, $article->getTitle() )
+               );
        }
 
        /**
@@ -215,7 +219,8 @@ class ParserCache {
                if ( !$useOutdated && $value->expired( $touched ) ) {
                        wfIncrStats( "pcache_miss_expired" );
                        $cacheTime = $value->getCacheTime();
-                       wfDebug( "ParserOutput key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
+                       wfDebug( "ParserOutput key expired, touched $touched, "
+                               . "epoch $wgCacheEpoch, cached $cacheTime\n" );
                        $value = false;
                } elseif ( $value->isDifferentRevision( $article->getLatest() ) ) {
                        wfIncrStats( "pcache_miss_revid" );
index 7c84b67..efd5f74 100644 (file)
 /**
  * \brief Set options of the Parser
  *
- * All member variables are supposed to be private in theory, although in practise this is not the case.
+ * All member variables are supposed to be private in theory, although in
+ * practise this is not the case.
  *
  * @ingroup Parser
  */
 class ParserOptions {
+       /** @var bool Parsing the page for a "preview" operation? */
+       public $mIsPreview = false;
 
-       /**
-        * Interlanguage links are removed and returned in an array
-        */
-       var $mInterwikiMagic;
+       /** @var bool Interlanguage links are removed and returned in an array */
+       protected $mInterwikiMagic;
 
-       /**
-        * Allow external images inline?
-        */
-       var $mAllowExternalImages;
+       /** @var bool Allow external images inline? */
+       protected $mAllowExternalImages;
 
-       /**
-        * If not, any exception?
-        */
-       var $mAllowExternalImagesFrom;
+       /** @var string|array If not, any exception? */
+       protected $mAllowExternalImagesFrom;
 
-       /**
-        * If not or it doesn't match, should we check an on-wiki whitelist?
-        */
-       var $mEnableImageWhitelist;
+       /** @var bool If not or it doesn't match, should we check an on-wiki whitelist? */
+       protected $mEnableImageWhitelist;
 
-       /**
-        * Date format index
-        */
-       var $mDateFormat = null;
+       /** @var string Date format index */
+       protected $mDateFormat = null;
 
-       /**
-        * Create "edit section" links?
-        */
-       var $mEditSection = true;
+       /** @var bool Create "edit section" links? */
+       protected $mEditSection = true;
 
-       /**
-        * Allow inclusion of special pages?
-        */
-       var $mAllowSpecialInclusion;
+       /** @var bool Allow inclusion of special pages? */
+       protected $mAllowSpecialInclusion;
 
-       /**
-        * Use tidy to cleanup output HTML?
-        */
-       var $mTidy = false;
+       /** @var bool Use tidy to cleanup output HTML? */
+       protected $mTidy = false;
 
        /**
-        * Which lang to call for PLURAL and GRAMMAR
+        * @var bool Which lang to call for PLURAL and GRAMMAR
+        * @todo FIXME: This comment doesn't appear to be correct.
+        *   Should be this? Whether this is an interface message.
         */
-       var $mInterfaceMessage = false;
+       protected $mInterfaceMessage = false;
 
-       /**
-        * Overrides $mInterfaceMessage with arbitrary language
-        */
-       var $mTargetLanguage = null;
+       /** @var string|Language Overrides $mInterfaceMessage with arbitrary language */
+       protected $mTargetLanguage = null;
 
-       /**
-        * Maximum size of template expansions, in bytes
-        */
-       var $mMaxIncludeSize;
+       /** @var int Maximum size of template expansions, in bytes */
+       protected $mMaxIncludeSize;
 
-       /**
-        * Maximum number of nodes touched by PPFrame::expand()
-        */
-       var $mMaxPPNodeCount;
+       /** @var int Maximum number of nodes touched by PPFrame::expand() */
+       protected $mMaxPPNodeCount;
 
-       /**
-        * Maximum number of nodes generated by Preprocessor::preprocessToObj()
-        */
-       var $mMaxGeneratedPPNodeCount;
+       /** @var int Maximum number of nodes generated by Preprocessor::preprocessToObj() */
+       protected $mMaxGeneratedPPNodeCount;
 
-       /**
-        * Maximum recursion depth in PPFrame::expand()
-        */
-       var $mMaxPPExpandDepth;
+       /** @var int Maximum recursion depth in PPFrame::expand() */
+       protected $mMaxPPExpandDepth;
 
-       /**
-        * Maximum recursion depth for templates within templates
-        */
-       var $mMaxTemplateDepth;
+       /** @var int Maximum recursion depth for templates within templates */
+       protected $mMaxTemplateDepth;
 
-       /**
-        * Maximum number of calls per parse to expensive parser functions
-        */
-       var $mExpensiveParserFunctionLimit;
+       /** @var int Maximum number of calls per parse to expensive parser functions */
+       protected $mExpensiveParserFunctionLimit;
 
-       /**
-        * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
-        */
-       var $mRemoveComments = true;
+       /** @var bool Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS */
+       protected $mRemoveComments = true;
 
-       /**
-        * Callback for template fetching. Used as first argument to call_user_func().
-        */
-       var $mTemplateCallback =
-               array( 'Parser', 'statelessFetchTemplate' );
+       /** @var array Callback for template fetching. Used as first argument to call_user_func(). */
+       protected $mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
 
-       /**
-        * Enable limit report in an HTML comment on output
-        */
-       var $mEnableLimitReport = false;
+       /** @var bool Enable limit report in an HTML comment on output */
+       protected $mEnableLimitReport = false;
 
-       /**
-        * Timestamp used for {{CURRENTDAY}} etc.
-        */
-       var $mTimestamp;
+       /** @var string Timestamp used for {{CURRENTDAY}} etc. */
+       protected $mTimestamp;
 
-       /**
-        * Target attribute for external links
-        */
-       var $mExternalLinkTarget;
+       /** @var bool|string Target attribute for external links */
+       protected $mExternalLinkTarget;
 
        /**
-        * Clean up signature texts?
+        * @var bool Clean up signature texts?
         *
         * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
         * 2) Substitute all transclusions
         */
-       var $mCleanSignatures;
+       protected $mCleanSignatures;
 
-       /**
-        * Transform wiki markup when saving the page?
-        */
-       var $mPreSaveTransform = true;
+       /** @var bool Transform wiki markup when saving the page? */
+       protected $mPreSaveTransform = true;
 
-       /**
-        * Whether content conversion should be disabled
-        */
-       var $mDisableContentConversion;
+       /** @var bool Whether content conversion should be disabled */
+       protected $mDisableContentConversion;
 
-       /**
-        * Whether title conversion should be disabled
-        */
-       var $mDisableTitleConversion;
+       /** @var bool Whether title conversion should be disabled */
+       protected $mDisableTitleConversion;
 
-       /**
-        * Automatically number headings?
-        */
-       var $mNumberHeadings;
+       /** @var string Automatically number headings? */
+       protected $mNumberHeadings;
 
-       /**
-        * Thumb size preferred by the user.
-        */
-       var $mThumbSize;
+       /** @var string Thumb size preferred by the user. */
+       protected $mThumbSize;
 
-       /**
-        * Maximum article size of an article to be marked as "stub"
-        */
+       /** @var Language Language object of the User language. */
+       protected $mUserLang;
+
+       /** @var User Stored user object */
+       protected $mUser;
+
+       /** @var bool Parsing the page for a "preview" operation on a single section? */
+       protected $mIsSectionPreview = false;
+
+       /** @var bool Parsing the printable version of the page? */
+       protected $mIsPrintable = false;
+
+       /** @var string Extra key that should be present in the caching key. */
+       protected $mExtraKey = '';
+
+       /** @var callable Function to be called when an option is accessed. */
+       protected $onAccessCallback = null;
+
+       /** @var int Maximum article size of an article to be marked as "stub" */
        private $mStubThreshold;
 
-       /**
-        * Language object of the User language.
-        */
-       var $mUserLang;
+       function getInterwikiMagic() {
+               return $this->mInterwikiMagic;
+       }
 
-       /**
-        * @var User
-        * Stored user object
-        */
-       var $mUser;
+       function getAllowExternalImages() {
+               return $this->mAllowExternalImages;
+       }
 
-       /**
-        * Parsing the page for a "preview" operation?
-        */
-       var $mIsPreview = false;
+       function getAllowExternalImagesFrom() {
+               return $this->mAllowExternalImagesFrom;
+       }
 
-       /**
-        * Parsing the page for a "preview" operation on a single section?
-        */
-       var $mIsSectionPreview = false;
+       function getEnableImageWhitelist() {
+               return $this->mEnableImageWhitelist;
+       }
 
-       /**
-        * Parsing the printable version of the page?
-        */
-       var $mIsPrintable = false;
+       function getEditSection() {
+               return $this->mEditSection;
+       }
 
-       /**
-        * Extra key that should be present in the caching key.
-        */
-       var $mExtraKey = '';
+       function getNumberHeadings() {
+               $this->optionUsed( 'numberheadings' );
 
-       /**
-        * Function to be called when an option is accessed.
-        */
-       protected $onAccessCallback = null;
+               return $this->mNumberHeadings;
+       }
+
+       function getAllowSpecialInclusion() {
+               return $this->mAllowSpecialInclusion;
+       }
+
+       function getTidy() {
+               return $this->mTidy;
+       }
+
+       function getInterfaceMessage() {
+               return $this->mInterfaceMessage;
+       }
+
+       function getTargetLanguage() {
+               return $this->mTargetLanguage;
+       }
+
+       function getMaxIncludeSize() {
+               return $this->mMaxIncludeSize;
+       }
+
+       function getMaxPPNodeCount() {
+               return $this->mMaxPPNodeCount;
+       }
+
+       function getMaxGeneratedPPNodeCount() {
+               return $this->mMaxGeneratedPPNodeCount;
+       }
+
+       function getMaxPPExpandDepth() {
+               return $this->mMaxPPExpandDepth;
+       }
+
+       function getMaxTemplateDepth() {
+               return $this->mMaxTemplateDepth;
+       }
 
-       function getInterwikiMagic()                { return $this->mInterwikiMagic; }
-       function getAllowExternalImages()           { return $this->mAllowExternalImages; }
-       function getAllowExternalImagesFrom()       { return $this->mAllowExternalImagesFrom; }
-       function getEnableImageWhitelist()          { return $this->mEnableImageWhitelist; }
-       function getEditSection()                   { return $this->mEditSection; }
-       function getNumberHeadings()                { $this->optionUsed( 'numberheadings' );
-                                                                                                 return $this->mNumberHeadings; }
-       function getAllowSpecialInclusion()         { return $this->mAllowSpecialInclusion; }
-       function getTidy()                          { return $this->mTidy; }
-       function getInterfaceMessage()              { return $this->mInterfaceMessage; }
-       function getTargetLanguage()                { return $this->mTargetLanguage; }
-       function getMaxIncludeSize()                { return $this->mMaxIncludeSize; }
-       function getMaxPPNodeCount()                { return $this->mMaxPPNodeCount; }
-       function getMaxGeneratedPPNodeCount()       { return $this->mMaxGeneratedPPNodeCount; }
-       function getMaxPPExpandDepth()              { return $this->mMaxPPExpandDepth; }
-       function getMaxTemplateDepth()              { return $this->mMaxTemplateDepth; }
        /* @since 1.20 */
-       function getExpensiveParserFunctionLimit()  { return $this->mExpensiveParserFunctionLimit; }
-       function getRemoveComments()                { return $this->mRemoveComments; }
-       function getTemplateCallback()              { return $this->mTemplateCallback; }
-       function getEnableLimitReport()             { return $this->mEnableLimitReport; }
-       function getCleanSignatures()               { return $this->mCleanSignatures; }
-       function getExternalLinkTarget()            { return $this->mExternalLinkTarget; }
-       function getDisableContentConversion()      { return $this->mDisableContentConversion; }
-       function getDisableTitleConversion()        { return $this->mDisableTitleConversion; }
-       function getThumbSize()                     { $this->optionUsed( 'thumbsize' );
-                                                                                                 return $this->mThumbSize; }
-       function getStubThreshold()                 { $this->optionUsed( 'stubthreshold' );
-                                                                                                 return $this->mStubThreshold; }
-
-       function getIsPreview()                     { return $this->mIsPreview; }
-       function getIsSectionPreview()              { return $this->mIsSectionPreview; }
-       function getIsPrintable()                   { $this->optionUsed( 'printable' );
-                                                                                                 return $this->mIsPrintable; }
-       function getUser()                          { return $this->mUser; }
-       function getPreSaveTransform()              { return $this->mPreSaveTransform; }
+       function getExpensiveParserFunctionLimit() {
+               return $this->mExpensiveParserFunctionLimit;
+       }
+
+       function getRemoveComments() {
+               return $this->mRemoveComments;
+       }
+
+       function getTemplateCallback() {
+               return $this->mTemplateCallback;
+       }
+
+       function getEnableLimitReport() {
+               return $this->mEnableLimitReport;
+       }
+
+       function getCleanSignatures() {
+               return $this->mCleanSignatures;
+       }
+
+       function getExternalLinkTarget() {
+               return $this->mExternalLinkTarget;
+       }
+
+       function getDisableContentConversion() {
+               return $this->mDisableContentConversion;
+       }
+
+       function getDisableTitleConversion() {
+               return $this->mDisableTitleConversion;
+       }
+
+       function getThumbSize() {
+               $this->optionUsed( 'thumbsize' );
+
+               return $this->mThumbSize;
+       }
+
+       function getStubThreshold() {
+               $this->optionUsed( 'stubthreshold' );
+
+               return $this->mStubThreshold;
+       }
+
+       function getIsPreview() {
+               return $this->mIsPreview;
+       }
+
+       function getIsSectionPreview() {
+               return $this->mIsSectionPreview;
+       }
+
+       function getIsPrintable() {
+               $this->optionUsed( 'printable' );
+
+               return $this->mIsPrintable;
+       }
+
+       function getUser() {
+               return $this->mUser;
+       }
+
+       function getPreSaveTransform() {
+               return $this->mPreSaveTransform;
+       }
 
        function getDateFormat() {
                $this->optionUsed( 'dateformat' );
@@ -293,47 +319,139 @@ class ParserOptions {
                return $this->getUserLangObj()->getCode();
        }
 
-       function setInterwikiMagic( $x )            { return wfSetVar( $this->mInterwikiMagic, $x ); }
-       function setAllowExternalImages( $x )       { return wfSetVar( $this->mAllowExternalImages, $x ); }
-       function setAllowExternalImagesFrom( $x )   { return wfSetVar( $this->mAllowExternalImagesFrom, $x ); }
-       function setEnableImageWhitelist( $x )      { return wfSetVar( $this->mEnableImageWhitelist, $x ); }
-       function setDateFormat( $x )                { return wfSetVar( $this->mDateFormat, $x ); }
-       function setEditSection( $x )               { return wfSetVar( $this->mEditSection, $x ); }
-       function setNumberHeadings( $x )            { return wfSetVar( $this->mNumberHeadings, $x ); }
-       function setAllowSpecialInclusion( $x )     { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
-       function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x ); }
+       function setInterwikiMagic( $x ) {
+               return wfSetVar( $this->mInterwikiMagic, $x );
+       }
+
+       function setAllowExternalImages( $x ) {
+               return wfSetVar( $this->mAllowExternalImages, $x );
+       }
+
+       function setAllowExternalImagesFrom( $x ) {
+               return wfSetVar( $this->mAllowExternalImagesFrom, $x );
+       }
+
+       function setEnableImageWhitelist( $x ) {
+               return wfSetVar( $this->mEnableImageWhitelist, $x );
+       }
+
+       function setDateFormat( $x ) {
+               return wfSetVar( $this->mDateFormat, $x );
+       }
+
+       function setEditSection( $x ) {
+               return wfSetVar( $this->mEditSection, $x );
+       }
+
+       function setNumberHeadings( $x ) {
+               return wfSetVar( $this->mNumberHeadings, $x );
+       }
+
+       function setAllowSpecialInclusion( $x ) {
+               return wfSetVar( $this->mAllowSpecialInclusion, $x );
+       }
+
+       function setTidy( $x ) {
+               return wfSetVar( $this->mTidy, $x );
+       }
 
        /** @deprecated since 1.19 */
-       function setSkin( $x )                      { wfDeprecated( __METHOD__, '1.19' ); }
-       function setInterfaceMessage( $x )          { return wfSetVar( $this->mInterfaceMessage, $x ); }
-       function setTargetLanguage( $x )            { return wfSetVar( $this->mTargetLanguage, $x, true ); }
-       function setMaxIncludeSize( $x )            { return wfSetVar( $this->mMaxIncludeSize, $x ); }
-       function setMaxPPNodeCount( $x )            { return wfSetVar( $this->mMaxPPNodeCount, $x ); }
-       function setMaxGeneratedPPNodeCount( $x )   { return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x ); }
-       function setMaxTemplateDepth( $x )          { return wfSetVar( $this->mMaxTemplateDepth, $x ); }
+       function setSkin( $x ) {
+               wfDeprecated( __METHOD__, '1.19' );
+       }
+
+       function setInterfaceMessage( $x ) {
+               return wfSetVar( $this->mInterfaceMessage, $x );
+       }
+
+       function setTargetLanguage( $x ) {
+               return wfSetVar( $this->mTargetLanguage, $x, true );
+       }
+
+       function setMaxIncludeSize( $x ) {
+               return wfSetVar( $this->mMaxIncludeSize, $x );
+       }
+
+       function setMaxPPNodeCount( $x ) {
+               return wfSetVar( $this->mMaxPPNodeCount, $x );
+       }
+
+       function setMaxGeneratedPPNodeCount( $x ) {
+               return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x );
+       }
+
+       function setMaxTemplateDepth( $x ) {
+               return wfSetVar( $this->mMaxTemplateDepth, $x );
+       }
+
        /* @since 1.20 */
-       function setExpensiveParserFunctionLimit( $x ) { return wfSetVar( $this->mExpensiveParserFunctionLimit, $x ); }
-       function setRemoveComments( $x )            { return wfSetVar( $this->mRemoveComments, $x ); }
-       function setTemplateCallback( $x )          { return wfSetVar( $this->mTemplateCallback, $x ); }
-       function enableLimitReport( $x = true )     { return wfSetVar( $this->mEnableLimitReport, $x ); }
-       function setTimestamp( $x )                 { return wfSetVar( $this->mTimestamp, $x ); }
-       function setCleanSignatures( $x )           { return wfSetVar( $this->mCleanSignatures, $x ); }
-       function setExternalLinkTarget( $x )        { return wfSetVar( $this->mExternalLinkTarget, $x ); }
-       function disableContentConversion( $x = true ) { return wfSetVar( $this->mDisableContentConversion, $x ); }
-       function disableTitleConversion( $x = true ) { return wfSetVar( $this->mDisableTitleConversion, $x ); }
-       function setUserLang( $x )                  {
+       function setExpensiveParserFunctionLimit( $x ) {
+               return wfSetVar( $this->mExpensiveParserFunctionLimit, $x );
+       }
+
+       function setRemoveComments( $x ) {
+               return wfSetVar( $this->mRemoveComments, $x );
+       }
+
+       function setTemplateCallback( $x ) {
+               return wfSetVar( $this->mTemplateCallback, $x );
+       }
+
+       function enableLimitReport( $x = true ) {
+               return wfSetVar( $this->mEnableLimitReport, $x );
+       }
+
+       function setTimestamp( $x ) {
+               return wfSetVar( $this->mTimestamp, $x );
+       }
+
+       function setCleanSignatures( $x ) {
+               return wfSetVar( $this->mCleanSignatures, $x );
+       }
+
+       function setExternalLinkTarget( $x ) {
+               return wfSetVar( $this->mExternalLinkTarget, $x );
+       }
+
+       function disableContentConversion( $x = true ) {
+               return wfSetVar( $this->mDisableContentConversion, $x );
+       }
+
+       function disableTitleConversion( $x = true ) {
+               return wfSetVar( $this->mDisableTitleConversion, $x );
+       }
+
+       function setUserLang( $x ) {
                if ( is_string( $x ) ) {
                        $x = Language::factory( $x );
                }
+
                return wfSetVar( $this->mUserLang, $x );
        }
-       function setThumbSize( $x )                 { return wfSetVar( $this->mThumbSize, $x ); }
-       function setStubThreshold( $x )             { return wfSetVar( $this->mStubThreshold, $x ); }
-       function setPreSaveTransform( $x )          { return wfSetVar( $this->mPreSaveTransform, $x ); }
 
-       function setIsPreview( $x )                 { return wfSetVar( $this->mIsPreview, $x ); }
-       function setIsSectionPreview( $x )          { return wfSetVar( $this->mIsSectionPreview, $x ); }
-       function setIsPrintable( $x )               { return wfSetVar( $this->mIsPrintable, $x ); }
+       function setThumbSize( $x ) {
+               return wfSetVar( $this->mThumbSize, $x );
+       }
+
+       function setStubThreshold( $x ) {
+               return wfSetVar( $this->mStubThreshold, $x );
+       }
+
+       function setPreSaveTransform( $x ) {
+               return wfSetVar( $this->mPreSaveTransform, $x );
+       }
+
+       function setIsPreview( $x ) {
+               return wfSetVar( $this->mIsPreview, $x );
+       }
+
+       function setIsSectionPreview( $x ) {
+               return wfSetVar( $this->mIsSectionPreview, $x );
+       }
+
+       function setIsPrintable( $x ) {
+               return wfSetVar( $this->mIsPrintable, $x );
+       }
 
        /**
         * Extra key that should be present in the parser cache key.
@@ -464,7 +582,14 @@ class ParserOptions {
         * @return array
         */
        public static function legacyOptions() {
-               return array( 'stubthreshold', 'numberheadings', 'userlang', 'thumbsize', 'editsection', 'printable' );
+               return array(
+                       'stubthreshold',
+                       'numberheadings',
+                       'userlang',
+                       'thumbsize',
+                       'editsection',
+                       'printable'
+               );
        }
 
        /**
index b7cc490..74ce325 100644 (file)
  * @ingroup Parser
  */
 class ParserOutput extends CacheTime {
-       var $mText,                       # The output text
-               $mLanguageLinks,              # List of the full text of language links, in the order they appear
-               $mCategories,                 # Map of category names to sort keys
-               $mTitleText,                  # title text of the chosen language variant
-               $mLinks = array(),            # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
-               $mTemplates = array(),        # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
-               $mTemplateIds = array(),      # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
-               $mImages = array(),           # DB keys of the images used, in the array key only
-               $mFileSearchOptions = array(), # DB keys of the images used mapped to sha1 and MW timestamp
-               $mExternalLinks = array(),    # External link URLs, in the key only
-               $mInterwikiLinks = array(),   # 2-D map of prefix/DBK (in keys only) for the inline interwiki links in the document.
-               $mNewSection = false,         # Show a new section link?
-               $mHideNewSection = false,     # Hide the new section link?
-               $mNoGallery = false,          # No gallery on category page? (__NOGALLERY__)
-               $mHeadItems = array(),        # Items to put in the <head> section
-               $mModules = array(),          # Modules to be loaded by the resource loader
-               $mModuleScripts = array(),    # Modules of which only the JS will be loaded by the resource loader
-               $mModuleStyles = array(),     # Modules of which only the CSSS will be loaded by the resource loader
-               $mModuleMessages = array(),   # Modules of which only the messages will be loaded by the resource loader
-               $mJsConfigVars = array(),     # JavaScript config variable for mw.config combined with this page
-               $mOutputHooks = array(),      # Hook tags as per $wgParserOutputHooks
-               $mWarnings = array(),         # Warning text to be returned to the user. Wikitext formatted, in the key only
-               $mSections = array(),         # Table of contents
-               $mEditSectionTokens = false,  # prefix/suffix markers if edit sections were output as tokens
-               $mProperties = array(),       # Name/value pairs to be cached in the DB
-               $mTOCHTML = '',               # HTML of the TOC
-               $mTimestamp,                  # Timestamp of the revision
-               $mTOCEnabled = true;          # Whether TOC should be shown, can't override __NOTOC__
-               private $mIndexPolicy = '';       # 'index' or 'noindex'?  Any other value will result in no change.
-               private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
-               private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
-               private $mExtensionData = array(); # extra data used by extensions
-               private $mLimitReportData = array(); # Parser limit report data
-               private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
-
-       const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
+       /** @var string The output text */
+       public $mText;
+
+       /** @var array List of the full text of language links; in the order they appear */
+       public $mLanguageLinks;
+
+       /** @var array Map of category names to sort keys */
+       public $mCategories;
+
+       /** @var array DB keys of the images used; in the array key only */
+       public $mImages = array();
+
+       /** @var array Modules to be loaded by the resource loader */
+       public $mModules = array();
+
+       /** @var array Name/value pairs to be cached in the DB */
+       public $mProperties = array();
+
+       /** @var string Title text of the chosen language variant */
+       protected $mTitleText;
+
+       /** @var array 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. */
+       protected $mLinks = array();
+
+       /** @var array 2-D map of NS/DBK to ID for the template references. ID=zero for broken. */
+       protected $mTemplates = array();
+
+       /** @var array 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. */
+       protected $mTemplateIds = array();
+
+       /** @var array DB keys of the images used mapped to sha1 and MW timestamp */
+       protected $mFileSearchOptions = array();
+
+       /** @var array External link URLs; in the key only */
+       protected $mExternalLinks = array();
+
+       /**
+        * @var array 2-D map of prefix/DBK (in keys only) for the inline interwiki
+        *   links in the document.
+        */
+       protected $mInterwikiLinks = array();
+
+       /** @var bool Show a new section link? */
+       protected $mNewSection = false;
+
+       /** @var bool Hide the new section link? */
+       protected $mHideNewSection = false;
+
+       /** @var bool No gallery on category page? (__NOGALLERY__) */
+       public $mNoGallery = false;
+
+       /** @var array Items to put in the <head> section */
+       protected $mHeadItems = array();
+
+       /** @var array Modules of which only the JS will be loaded by the resource loader */
+       protected $mModuleScripts = array();
+
+       /** @var array Modules of which only the CSSS will be loaded by the resource loader */
+       protected $mModuleStyles = array();
+
+       /** @var array Modules of which only the messages will be loaded by the resource loader */
+       protected $mModuleMessages = array();
+
+       /** @var array JavaScript config variable for mw.config combined with this page */
+       protected $mJsConfigVars = array();
+
+       /** @var array Hook tags as per $wgParserOutputHooks */
+       protected $mOutputHooks = array();
+
+       /** @var array Warning text to be returned to the user. Wikitext formatted; in the key only */
+       protected $mWarnings = array();
+
+       /** @var array Table of contents */
+       protected $mSections = array();
+
+       /** @var bool Prefix/suffix markers if edit sections were output as tokens */
+       protected $mEditSectionTokens = false;
+
+       /** @var string HTML of the TOC */
+       protected $mTOCHTML = '';
+
+       /** @var string Timestamp of the revision */
+       protected $mTimestamp;
+
+       /** @var bool Whether TOC should be shown, can't override __NOTOC__ */
+       protected $mTOCEnabled = true;
+
+       /** @var string 'index' or 'noindex'?  Any other value will result in no change. */
+       private $mIndexPolicy = '';
+
+       /** @var array List of ParserOptions (stored in the keys) */
+       private $mAccessedOptions = array();
+
+       /** @var array List of DataUpdate, used to save info from the page somewhere else. */
+       private $mSecondaryDataUpdates = array();
+
+       /** @var array Extra data used by extensions */
+       private $mExtensionData = array();
+
+       /** @var array Parser limit report data */
+       private $mLimitReportData = array();
+
+       /** @var array Timestamps for getTimeSinceStart() */
+       private $mParseStartTime = array();
+
+       const EDITSECTION_REGEX =
+               '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
 
        function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false, $titletext = ''
@@ -116,50 +187,166 @@ class ParserOutput extends CacheTime {
                return call_user_func_array( array( $skin, 'doEditSectionLink' ), $args );
        }
 
-       function &getLanguageLinks()         { return $this->mLanguageLinks; }
-       function getInterwikiLinks()         { return $this->mInterwikiLinks; }
-       function getCategoryLinks()          { return array_keys( $this->mCategories ); }
-       function &getCategories()            { return $this->mCategories; }
-       function getTitleText()              { return $this->mTitleText; }
-       function getSections()               { return $this->mSections; }
-       function getEditSectionTokens()      { return $this->mEditSectionTokens; }
-       function &getLinks()                 { return $this->mLinks; }
-       function &getTemplates()             { return $this->mTemplates; }
-       function &getTemplateIds()           { return $this->mTemplateIds; }
-       function &getImages()                { return $this->mImages; }
-       function &getFileSearchOptions()     { return $this->mFileSearchOptions; }
-       function &getExternalLinks()         { return $this->mExternalLinks; }
-       function getNoGallery()              { return $this->mNoGallery; }
-       function getHeadItems()              { return $this->mHeadItems; }
-       function getModules()                { return $this->mModules; }
-       function getModuleScripts()          { return $this->mModuleScripts; }
-       function getModuleStyles()           { return $this->mModuleStyles; }
-       function getModuleMessages()         { return $this->mModuleMessages; }
+       function &getLanguageLinks() {
+               return $this->mLanguageLinks;
+       }
+
+       function getInterwikiLinks() {
+               return $this->mInterwikiLinks;
+       }
+
+       function getCategoryLinks() {
+               return array_keys( $this->mCategories );
+       }
+
+       function &getCategories() {
+               return $this->mCategories;
+       }
+
+       function getTitleText() {
+               return $this->mTitleText;
+       }
+
+       function getSections() {
+               return $this->mSections;
+       }
+
+       function getEditSectionTokens() {
+               return $this->mEditSectionTokens;
+       }
+
+       function &getLinks() {
+               return $this->mLinks;
+       }
+
+       function &getTemplates() {
+               return $this->mTemplates;
+       }
+
+       function &getTemplateIds() {
+               return $this->mTemplateIds;
+       }
+
+       function &getImages() {
+               return $this->mImages;
+       }
+
+       function &getFileSearchOptions() {
+               return $this->mFileSearchOptions;
+       }
+
+       function &getExternalLinks() {
+               return $this->mExternalLinks;
+       }
+
+       function getNoGallery() {
+               return $this->mNoGallery;
+       }
+
+       function getHeadItems() {
+               return $this->mHeadItems;
+       }
+
+       function getModules() {
+               return $this->mModules;
+       }
+
+       function getModuleScripts() {
+               return $this->mModuleScripts;
+       }
+
+       function getModuleStyles() {
+               return $this->mModuleStyles;
+       }
+
+       function getModuleMessages() {
+               return $this->mModuleMessages;
+       }
+
        /** @since 1.23 */
-       function getJsConfigVars()           { return $this->mJsConfigVars; }
-       function getOutputHooks()            { return (array)$this->mOutputHooks; }
-       function getWarnings()               { return array_keys( $this->mWarnings ); }
-       function getIndexPolicy()            { return $this->mIndexPolicy; }
-       function getTOCHTML()                { return $this->mTOCHTML; }
-       function getTimestamp()              { return $this->mTimestamp; }
-       function getLimitReportData()        { return $this->mLimitReportData; }
-       function getTOCEnabled()             { return $this->mTOCEnabled; }
-
-       function setText( $text )            { return wfSetVar( $this->mText, $text ); }
-       function setLanguageLinks( $ll )     { return wfSetVar( $this->mLanguageLinks, $ll ); }
-       function setCategoryLinks( $cl )     { return wfSetVar( $this->mCategories, $cl ); }
-
-       function setTitleText( $t )          { return wfSetVar( $this->mTitleText, $t ); }
-       function setSections( $toc )         { return wfSetVar( $this->mSections, $toc ); }
-       function setEditSectionTokens( $t )  { return wfSetVar( $this->mEditSectionTokens, $t ); }
-       function setIndexPolicy( $policy )   { return wfSetVar( $this->mIndexPolicy, $policy ); }
-       function setTOCHTML( $tochtml )      { return wfSetVar( $this->mTOCHTML, $tochtml ); }
-       function setTimestamp( $timestamp )  { return wfSetVar( $this->mTimestamp, $timestamp ); }
-       function setTOCEnabled( $flag )      { return wfSetVar( $this->mTOCEnabled, $flag ); }
-
-       function addCategory( $c, $sort )    { $this->mCategories[$c] = $sort; }
-       function addLanguageLink( $t )       { $this->mLanguageLinks[] = $t; }
-       function addWarning( $s )            { $this->mWarnings[$s] = 1; }
+       function getJsConfigVars() {
+               return $this->mJsConfigVars;
+       }
+
+       function getOutputHooks() {
+               return (array)$this->mOutputHooks;
+       }
+
+       function getWarnings() {
+               return array_keys( $this->mWarnings );
+       }
+
+       function getIndexPolicy() {
+               return $this->mIndexPolicy;
+       }
+
+       function getTOCHTML() {
+               return $this->mTOCHTML;
+       }
+
+       function getTimestamp() {
+               return $this->mTimestamp;
+       }
+
+       function getLimitReportData() {
+               return $this->mLimitReportData;
+       }
+
+       function getTOCEnabled() {
+               return $this->mTOCEnabled;
+       }
+
+       function setText( $text ) {
+               return wfSetVar( $this->mText, $text );
+       }
+
+       function setLanguageLinks( $ll ) {
+               return wfSetVar( $this->mLanguageLinks, $ll );
+       }
+
+       function setCategoryLinks( $cl ) {
+               return wfSetVar( $this->mCategories, $cl );
+       }
+
+       function setTitleText( $t ) {
+               return wfSetVar( $this->mTitleText, $t );
+       }
+
+       function setSections( $toc ) {
+               return wfSetVar( $this->mSections, $toc );
+       }
+
+       function setEditSectionTokens( $t ) {
+               return wfSetVar( $this->mEditSectionTokens, $t );
+       }
+
+       function setIndexPolicy( $policy ) {
+               return wfSetVar( $this->mIndexPolicy, $policy );
+       }
+
+       function setTOCHTML( $tochtml ) {
+               return wfSetVar( $this->mTOCHTML, $tochtml );
+       }
+
+       function setTimestamp( $timestamp ) {
+               return wfSetVar( $this->mTimestamp, $timestamp );
+       }
+
+       function setTOCEnabled( $flag ) {
+               return wfSetVar( $this->mTOCEnabled, $flag );
+       }
+
+       function addCategory( $c, $sort ) {
+               $this->mCategories[$c] = $sort;
+       }
+
+       function addLanguageLink( $t ) {
+               $this->mLanguageLinks[] = $t;
+       }
+
+       function addWarning( $s ) {
+               $this->mWarnings[$s] = 1;
+       }
 
        function addOutputHook( $hook, $data = false ) {
                $this->mOutputHooks[] = array( $hook, $data );
@@ -512,8 +699,8 @@ class ParserOutput extends CacheTime {
         * extracted from the page's content, including a LinksUpdate object for all links stored in
         * this ParserOutput object.
         *
-        * @note: Avoid using this method directly, use ContentHandler::getSecondaryDataUpdates() instead! The content
-        *        handler may provide additional update objects.
+        * @note Avoid using this method directly, use ContentHandler::getSecondaryDataUpdates()
+        *   instead! The content handler may provide additional update objects.
         *
         * @since 1.20
         *
index 920b6f6..4d821ca 100644 (file)
 /**
  * @ingroup Parser
  */
-class Parser_DiffTest
-{
-       var $parsers, $conf;
-       var $shortOutput = false;
+class Parser_DiffTest {
+       /** @var array */
+       protected $parsers;
 
-       var $dtUniqPrefix;
+       /** @var array */
+       protected $conf;
+
+       /** @var bool */
+       protected $shortOutput = false;
+
+       /** @var string */
+       protected $dtUniqPrefix;
 
        function __construct( $conf ) {
                if ( !isset( $conf['parsers'] ) ) {
index 4cd5694..768dc9a 100644 (file)
@@ -40,7 +40,8 @@ interface Preprocessor {
        function newFrame();
 
        /**
-        * Create a new custom frame for programmatic use of parameter replacement as used in some extensions
+        * Create a new custom frame for programmatic use of parameter replacement
+        * as used in some extensions.
         *
         * @param array $args
         *
@@ -49,7 +50,8 @@ interface Preprocessor {
        function newCustomFrame( $args );
 
        /**
-        * Create a new custom node for programmatic use of parameter replacement as used in some extensions
+        * Create a new custom node for programmatic use of parameter replacement
+        * as used in some extensions.
         *
         * @param array $values
         */
index df3cbeb..ca7fd60 100644 (file)
  * @ingroup Parser
  */
 class Preprocessor_DOM implements Preprocessor {
+       /** @var Parser */
+       public $parser;
 
-       /**
-        * @var Parser
-        */
-       var $parser;
-
-       var $memoryLimit;
+       protected $memoryLimit;
 
        const CACHE_VERSION = 1;
 
@@ -73,9 +70,11 @@ class Preprocessor_DOM implements Preprocessor {
 
                foreach ( $values as $k => $val ) {
                        if ( is_int( $k ) ) {
-                               $xml .= "<part><name index=\"$k\"/><value>" . htmlspecialchars( $val ) . "</value></part>";
+                               $xml .= "<part><name index=\"$k\"/><value>"
+                                       . htmlspecialchars( $val ) . "</value></part>";
                        } else {
-                               $xml .= "<part><name>" . htmlspecialchars( $k ) . "</name>=<value>" . htmlspecialchars( $val ) . "</value></part>";
+                               $xml .= "<part><name>" . htmlspecialchars( $k )
+                                       . "</name>=<value>" . htmlspecialchars( $val ) . "</value></part>";
                        }
                }
 
@@ -111,8 +110,9 @@ class Preprocessor_DOM implements Preprocessor {
         *
         * @param string $text The text to parse
         * @param int $flags Bitwise combination of:
-        *     Parser::PTD_FOR_INCLUSION    Handle "<noinclude>" and "<includeonly>" as if the text is being
-        *                                  included. Default is to assume a direct page view.
+        *     Parser::PTD_FOR_INCLUSION  Handle "<noinclude>" and "<includeonly>"
+        *                                as if the text is being included. Default
+        *                                is to assume a direct page view.
         *
         * The generated DOM tree must depend only on the input text and the flags.
         * The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of bug 4899.
@@ -180,7 +180,8 @@ class Preprocessor_DOM implements Preprocessor {
                if ( !$result ) {
                        // Try running the XML through UtfNormal to get rid of invalid characters
                        $xml = UtfNormal::cleanUp( $xml );
-                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
+                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2
+                       // don't barf when the XML is >256 levels deep.
                        $result = $dom->loadXML( $xml, 1 << 19 );
                }
                if ( $result ) {
@@ -233,7 +234,9 @@ class Preprocessor_DOM implements Preprocessor {
                        $ignoredTags = array( 'includeonly', '/includeonly' );
                        $ignoredElements = array( 'noinclude' );
                        $xmlishElements[] = 'noinclude';
-                       if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
+                       if ( strpos( $text, '<onlyinclude>' ) !== false
+                               && strpos( $text, '</onlyinclude>' ) !== false
+                       ) {
                                $enableOnlyinclude = true;
                        }
                } else {
@@ -249,19 +252,28 @@ class Preprocessor_DOM implements Preprocessor {
                $stack = new PPDStack;
 
                $searchBase = "[{<\n"; #}
-               $revText = strrev( $text ); // For fast reverse searches
+               // For fast reverse searches
+               $revText = strrev( $text );
                $lengthText = strlen( $text );
 
-               $i = 0;                     # Input pointer, starts out pointing to a pseudo-newline before the start
-               $accum =& $stack->getAccum();   # Current accumulator
+               // Input pointer, starts out pointing to a pseudo-newline before the start
+               $i = 0;
+               // Current accumulator
+               $accum =& $stack->getAccum();
                $accum = '<root>';
-               $findEquals = false;            # True to find equals signs in arguments
-               $findPipe = false;              # True to take notice of pipe characters
+               // True to find equals signs in arguments
+               $findEquals = false;
+               // True to take notice of pipe characters
+               $findPipe = false;
                $headingIndex = 1;
-               $inHeading = false;        # True if $i is inside a possible heading
-               $noMoreGT = false;         # True if there are no more greater-than (>) signs right of $i
-               $findOnlyinclude = $enableOnlyinclude; # True to ignore all input up to the next <onlyinclude>
-               $fakeLineStart = true;     # Do a line-start run without outputting an LF character
+               // True if $i is inside a possible heading
+               $inHeading = false;
+               // True if there are no more greater-than (>) signs right of $i
+               $noMoreGT = false;
+               // True to ignore all input up to the next <onlyinclude>
+               $findOnlyinclude = $enableOnlyinclude;
+               // Do a line-start run without outputting an LF character
+               $fakeLineStart = true;
 
                while ( true ) {
                        //$this->memCheck();
@@ -346,7 +358,9 @@ class Preprocessor_DOM implements Preprocessor {
                        if ( $found == 'angle' ) {
                                $matches = false;
                                // Handle </onlyinclude>
-                               if ( $enableOnlyinclude && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>' ) {
+                               if ( $enableOnlyinclude
+                                       && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>'
+                               ) {
                                        $findOnlyinclude = true;
                                        continue;
                                }
@@ -460,7 +474,9 @@ class Preprocessor_DOM implements Preprocessor {
 
                                // Handle ignored tags
                                if ( in_array( $lowerName, $ignoredTags ) ) {
-                                       $accum .= '<ignore>' . htmlspecialchars( substr( $text, $i, $tagEndPos - $i + 1 ) ) . '</ignore>';
+                                       $accum .= '<ignore>'
+                                               . htmlspecialchars( substr( $text, $i, $tagEndPos - $i + 1 ) )
+                                               . '</ignore>';
                                        $i = $tagEndPos + 1;
                                        continue;
                                }
@@ -520,9 +536,11 @@ class Preprocessor_DOM implements Preprocessor {
 
                                $count = strspn( $text, '=', $i, 6 );
                                if ( $count == 1 && $findEquals ) {
-                                       // DWIM: This looks kind of like a name/value separator
-                                       // Let's let the equals handler have it and break the potential heading
-                                       // This is heuristic, but AFAICT the methods for completely correct disambiguation are very complex.
+                                       // DWIM: This looks kind of like a name/value separator.
+                                       // Let's let the equals handler have it and break the
+                                       // potential heading. This is heuristic, but AFAICT the
+                                       // methods for completely correct disambiguation are very
+                                       // complex.
                                } elseif ( $count > 0 ) {
                                        $piece = array(
                                                'open' => "\n",
@@ -541,8 +559,9 @@ class Preprocessor_DOM implements Preprocessor {
                                // A heading must be open, otherwise \n wouldn't have been in the search list
                                assert( '$piece->open == "\n"' );
                                $part = $piece->getCurrentPart();
-                               // Search back through the input to see if it has a proper close
-                               // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
+                               // Search back through the input to see if it has a proper close.
+                               // Do this using the reversed string since the other solutions
+                               // (end anchor, etc.) are inefficient.
                                $wsLength = strspn( $revText, " \t", $lengthText - $i );
                                $searchStart = $i - $wsLength;
                                if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
@@ -736,16 +755,22 @@ class Preprocessor_DOM implements Preprocessor {
  * @ingroup Parser
  */
 class PPDStack {
-       var $stack, $rootAccum;
+       /** @var array */
+       public $stack;
 
-       /**
-        * @var PPDStack
-        */
-       var $top;
-       var $out;
-       var $elementClass = 'PPDStackElement';
+       /** @var string */
+       public $rootAccum;
+
+       /** @var bool|PPDStack */
+       public $top;
+
+       /** @var */
+       public $out;
 
-       static $false = false;
+       /** @var string */
+       protected $elementClass = 'PPDStackElement';
+
+       protected static $false = false;
 
        function __construct() {
                $this->stack = array();
@@ -825,13 +850,26 @@ class PPDStack {
  * @ingroup Parser
  */
 class PPDStackElement {
-       var     $open,              // Opening character (\n for heading)
-               $close,             // Matching closing character
-               $count,             // Number of opening characters found (number of "=" for heading)
-               $parts,             // Array of PPDPart objects describing pipe-separated parts.
-               $lineStart;         // True if the open char appeared at the start of the input line. Not set for headings.
+       /** @var string Opening character (\n for heading) */
+       public $open;
+
+       /** @var string Matching closing character */
+       public $close;
+
+       /** @var int Number of opening characters found (number of "=" for heading) */
+       public $count;
+
+       /** @var array PPDPart objects describing pipe-separated parts. */
+       public $parts;
 
-       var $partClass = 'PPDPart';
+       /**
+        * @var bool True if the open char appeared at the start of the input line.
+        * Not set for headings.
+        */
+       public $lineStart;
+
+       /** @var string */
+       protected $partClass = 'PPDPart';
 
        function __construct( $data = array() ) {
                $class = $this->partClass;
@@ -899,7 +937,8 @@ class PPDStackElement {
  * @ingroup Parser
  */
 class PPDPart {
-       var $out; // Output accumulator string
+       /** @var string */
+       public $out;
 
        // Optional member variables:
        //   eqpos        Position of equals sign in output accumulator
@@ -916,34 +955,29 @@ class PPDPart {
  * @ingroup Parser
  */
 class PPFrame_DOM implements PPFrame {
+       /** @var array */
+       public $titleCache;
 
        /**
-        * @var Preprocessor
+        * @var array Hashtable listing templates which are disallowed for expansion
+        *   in this frame, having been encountered previously in parent frames.
         */
-       var $preprocessor;
+       public $loopCheckHash;
 
        /**
-        * @var Parser
+        * @var int Recursion depth of this frame, top = 0.
+        * Note that this is NOT the same as expansion depth in expand()
         */
-       var $parser;
+       public $depth;
 
-       /**
-        * @var Title
-        */
-       var $title;
-       var $titleCache;
+       /** @var Preprocessor */
+       protected $preprocessor;
 
-       /**
-        * Hashtable listing templates which are disallowed for expansion in this frame,
-        * having been encountered previously in parent frames.
-        */
-       var $loopCheckHash;
+       /** @var Parser */
+       protected $parser;
 
-       /**
-        * Recursion depth of this frame, top = 0
-        * Note that this is NOT the same as expansion depth in expand()
-        */
-       var $depth;
+       /** @var Title */
+       protected $title;
 
        /**
         * Construct a new preprocessor frame.
@@ -1148,8 +1182,9 @@ class PPFrame_DOM implements PPFrame {
                                        ) {
                                                $out .= '';
                                        } elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
-                                               # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
-                                               # Not in RECOVER_COMMENTS mode (extractSections) though
+                                               # Add a strip marker in PST mode so that pstPass2() can
+                                               # run some old-fashioned regexes on the result.
+                                               # Not in RECOVER_COMMENTS mode (extractSections) though.
                                                $out .= $this->parser->insertStripItem( $contextNode->textContent );
                                        } else {
                                                # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
@@ -1160,7 +1195,9 @@ class PPFrame_DOM implements PPFrame {
                                        # OT_WIKI will only respect <ignore> in substed templates.
                                        # The other output types respect it unless NO_IGNORE is set.
                                        # extractSections() sets NO_IGNORE and so never respects it.
-                                       if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] ) || ( $flags & PPFrame::NO_IGNORE ) ) {
+                                       if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] )
+                                               || ( $flags & PPFrame::NO_IGNORE )
+                                       ) {
                                                $out .= $contextNode->textContent;
                                        } else {
                                                $out .= '';
@@ -1433,13 +1470,20 @@ class PPFrame_DOM implements PPFrame {
  * @ingroup Parser
  */
 class PPTemplateFrame_DOM extends PPFrame_DOM {
-       var $numberedArgs, $namedArgs;
+       /** @var PPFrame_DOM */
+       public $parent;
 
-       /**
-        * @var PPFrame_DOM
-        */
-       var $parent;
-       var $numberedExpansionCache, $namedExpansionCache;
+       /** @var array */
+       protected $numberedArgs;
+
+       /** @var array */
+       protected $namedArgs;
+
+       /** @var array */
+       protected $numberedExpansionCache;
+
+       /** @var string[] */
+       protected $namedExpansionCache;
 
        /**
         * @param Preprocessor $preprocessor
@@ -1448,7 +1492,9 @@ class PPTemplateFrame_DOM extends PPFrame_DOM {
         * @param array $namedArgs
         * @param Title $title
         */
-       function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
+       function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
+               $namedArgs = array(), $title = false
+       ) {
                parent::__construct( $preprocessor );
 
                $this->parent = $parent;
@@ -1524,7 +1570,10 @@ class PPTemplateFrame_DOM extends PPFrame_DOM {
                }
                if ( !isset( $this->numberedExpansionCache[$index] ) ) {
                        # No trimming for unnamed arguments
-                       $this->numberedExpansionCache[$index] = $this->parent->expand( $this->numberedArgs[$index], PPFrame::STRIP_COMMENTS );
+                       $this->numberedExpansionCache[$index] = $this->parent->expand(
+                               $this->numberedArgs[$index],
+                               PPFrame::STRIP_COMMENTS
+                       );
                }
                return $this->numberedExpansionCache[$index];
        }
@@ -1564,7 +1613,7 @@ class PPTemplateFrame_DOM extends PPFrame_DOM {
  * @ingroup Parser
  */
 class PPCustomFrame_DOM extends PPFrame_DOM {
-       var $args;
+       protected $args;
 
        function __construct( $preprocessor, $args ) {
                parent::__construct( $preprocessor );
@@ -1610,12 +1659,11 @@ class PPCustomFrame_DOM extends PPFrame_DOM {
  * @ingroup Parser
  */
 class PPNode_DOM implements PPNode {
+       /** @var DOMElement */
+       public $node;
 
-       /**
-        * @var DOMElement
-        */
-       var $node;
-       var $xpath;
+       /** @var DOMXPath */
+       protected $xpath;
 
        function __construct( $node, $xpath = false ) {
                $this->node = $node;
index aebb98e..137f885 100644 (file)
  * @ingroup Parser
  */
 class Preprocessor_Hash implements Preprocessor {
-       /**
-        * @var Parser
-        */
-       var $parser;
+       /** @var Parser */
+       public $parser;
 
        const CACHE_VERSION = 1;
 
@@ -114,7 +112,9 @@ class Preprocessor_Hash implements Preprocessor {
                // Check cache.
                global $wgMemc, $wgPreprocessorCacheThreshold;
 
-               $cacheable = $wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold;
+               $cacheable = $wgPreprocessorCacheThreshold !== false
+                       && strlen( $text ) > $wgPreprocessorCacheThreshold;
+
                if ( $cacheable ) {
                        wfProfileIn( __METHOD__ . '-cacheable' );
 
@@ -161,7 +161,9 @@ class Preprocessor_Hash implements Preprocessor {
                        $ignoredTags = array( 'includeonly', '/includeonly' );
                        $ignoredElements = array( 'noinclude' );
                        $xmlishElements[] = 'noinclude';
-                       if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
+                       if ( strpos( $text, '<onlyinclude>' ) !== false
+                               && strpos( $text, '</onlyinclude>' ) !== false
+                       ) {
                                $enableOnlyinclude = true;
                        }
                } else {
@@ -177,18 +179,27 @@ class Preprocessor_Hash implements Preprocessor {
                $stack = new PPDStack_Hash;
 
                $searchBase = "[{<\n";
-               $revText = strrev( $text ); // For fast reverse searches
+               // For fast reverse searches
+               $revText = strrev( $text );
                $lengthText = strlen( $text );
 
-               $i = 0;                     # Input pointer, starts out pointing to a pseudo-newline before the start
-               $accum =& $stack->getAccum();   # Current accumulator
-               $findEquals = false;            # True to find equals signs in arguments
-               $findPipe = false;              # True to take notice of pipe characters
+               // Input pointer, starts out pointing to a pseudo-newline before the start
+               $i = 0;
+               // Current accumulator
+               $accum =& $stack->getAccum();
+               // True to find equals signs in arguments
+               $findEquals = false;
+               // True to take notice of pipe characters
+               $findPipe = false;
                $headingIndex = 1;
-               $inHeading = false;        # True if $i is inside a possible heading
-               $noMoreGT = false;         # True if there are no more greater-than (>) signs right of $i
-               $findOnlyinclude = $enableOnlyinclude; # True to ignore all input up to the next <onlyinclude>
-               $fakeLineStart = true;     # Do a line-start run without outputting an LF character
+               // True if $i is inside a possible heading
+               $inHeading = false;
+               // True if there are no more greater-than (>) signs right of $i
+               $noMoreGT = false;
+               // True to ignore all input up to the next <onlyinclude>
+               $findOnlyinclude = $enableOnlyinclude;
+               // Do a line-start run without outputting an LF character
+               $fakeLineStart = true;
 
                while ( true ) {
                        //$this->memCheck();
@@ -273,7 +284,9 @@ class Preprocessor_Hash implements Preprocessor {
                        if ( $found == 'angle' ) {
                                $matches = false;
                                // Handle </onlyinclude>
-                               if ( $enableOnlyinclude && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>' ) {
+                               if ( $enableOnlyinclude
+                                       && substr( $text, $i, strlen( '</onlyinclude>' ) ) == '</onlyinclude>'
+                               ) {
                                        $findOnlyinclude = true;
                                        continue;
                                }
@@ -452,9 +465,10 @@ class Preprocessor_Hash implements Preprocessor {
 
                                $count = strspn( $text, '=', $i, 6 );
                                if ( $count == 1 && $findEquals ) {
-                                       // DWIM: This looks kind of like a name/value separator
-                                       // Let's let the equals handler have it and break the potential heading
-                                       // This is heuristic, but AFAICT the methods for completely correct disambiguation are very complex.
+                                       // DWIM: This looks kind of like a name/value separator.
+                                       // Let's let the equals handler have it and break the potential
+                                       // heading. This is heuristic, but AFAICT the methods for
+                                       // completely correct disambiguation are very complex.
                                } elseif ( $count > 0 ) {
                                        $piece = array(
                                                'open' => "\n",
@@ -472,8 +486,9 @@ class Preprocessor_Hash implements Preprocessor {
                                // A heading must be open, otherwise \n wouldn't have been in the search list
                                assert( '$piece->open == "\n"' );
                                $part = $piece->getCurrentPart();
-                               // Search back through the input to see if it has a proper close
-                               // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient
+                               // Search back through the input to see if it has a proper close.
+                               // Do this using the reversed string since the other solutions
+                               // (end anchor, etc.) are inefficient.
                                $wsLength = strspn( $revText, " \t", $lengthText - $i );
                                $searchStart = $i - $wsLength;
                                if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) {
@@ -805,7 +820,9 @@ class PPDPart_Hash extends PPDPart {
  * @ingroup Parser
  */
 class PPDAccum_Hash {
-       var $firstNode, $lastNode;
+       public $firstNode;
+
+       public $lastNode;
 
        function __construct() {
                $this->firstNode = $this->lastNode = false;
@@ -873,34 +890,30 @@ class PPDAccum_Hash {
  * @ingroup Parser
  */
 class PPFrame_Hash implements PPFrame {
-
        /**
-        * @var Parser
+        * @var int Recursion depth of this frame, top = 0
+        * Note that this is NOT the same as expansion depth in expand()
         */
-       var $parser;
+       public $depth;
 
-       /**
-        * @var Preprocessor
-        */
-       var $preprocessor;
+       /** @var Parser */
+       protected $parser;
 
-       /**
-        * @var Title
-        */
-       var $title;
-       var $titleCache;
+       /** @var Preprocessor */
+       protected $preprocessor;
 
-       /**
-        * Hashtable listing templates which are disallowed for expansion in this frame,
-        * having been encountered previously in parent frames.
-        */
-       var $loopCheckHash;
+       /** @var Title */
+       protected $title;
+
+       /** @var array */
+       protected $titleCache;
 
        /**
-        * Recursion depth of this frame, top = 0
-        * Note that this is NOT the same as expansion depth in expand()
+        * @var array Hashtable listing templates which are disallowed for
+        *   expansion in this frame, having been encountered previously in
+        *   parent frames.
         */
-       var $depth;
+       protected $loopCheckHash;
 
        /**
         * Construct a new preprocessor frame.
@@ -1038,7 +1051,11 @@ class PPFrame_Hash implements PPFrame {
                                        # Double-brace expansion
                                        $bits = $contextNode->splitTemplate();
                                        if ( $flags & PPFrame::NO_TEMPLATES ) {
-                                               $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $bits['title'], $bits['parts'] );
+                                               $newIterator = $this->virtualBracketedImplode(
+                                                       '{{', '|', '}}',
+                                                       $bits['title'],
+                                                       $bits['parts']
+                                               );
                                        } else {
                                                $ret = $this->parser->braceSubstitution( $bits, $this );
                                                if ( isset( $ret['object'] ) ) {
@@ -1051,7 +1068,11 @@ class PPFrame_Hash implements PPFrame {
                                        # Triple-brace expansion
                                        $bits = $contextNode->splitTemplate();
                                        if ( $flags & PPFrame::NO_ARGS ) {
-                                               $newIterator = $this->virtualBracketedImplode( '{{{', '|', '}}}', $bits['title'], $bits['parts'] );
+                                               $newIterator = $this->virtualBracketedImplode(
+                                                       '{{{', '|', '}}}',
+                                                       $bits['title'],
+                                                       $bits['parts']
+                                               );
                                        } else {
                                                $ret = $this->parser->argSubstitution( $bits, $this );
                                                if ( isset( $ret['object'] ) ) {
@@ -1069,8 +1090,9 @@ class PPFrame_Hash implements PPFrame {
                                        ) {
                                                $out .= '';
                                        } elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) {
-                                               # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result
-                                               # Not in RECOVER_COMMENTS mode (extractSections) though
+                                               # Add a strip marker in PST mode so that pstPass2() can
+                                               # run some old-fashioned regexes on the result.
+                                               # Not in RECOVER_COMMENTS mode (extractSections) though.
                                                $out .= $this->parser->insertStripItem( $contextNode->firstChild->value );
                                        } else {
                                                # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove
@@ -1081,7 +1103,9 @@ class PPFrame_Hash implements PPFrame {
                                        # OT_WIKI will only respect <ignore> in substed templates.
                                        # The other output types respect it unless NO_IGNORE is set.
                                        # extractSections() sets NO_IGNORE and so never respects it.
-                                       if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] ) || ( $flags & PPFrame::NO_IGNORE ) ) {
+                                       if ( ( !isset( $this->parent ) && $this->parser->ot['wiki'] )
+                                               || ( $flags & PPFrame::NO_IGNORE )
+                                       ) {
                                                $out .= $contextNode->firstChild->value;
                                        } else {
                                                //$out .= '';
@@ -1351,8 +1375,20 @@ class PPFrame_Hash implements PPFrame {
  * @ingroup Parser
  */
 class PPTemplateFrame_Hash extends PPFrame_Hash {
-       var $numberedArgs, $namedArgs, $parent;
-       var $numberedExpansionCache, $namedExpansionCache;
+       /** @var array */
+       protected $numberedArgs;
+
+       /** @var array */
+       protected $namedArgs;
+
+       /** @var bool|PPFrame */
+       protected $parent;
+
+       /** @var array */
+       protected $numberedExpansionCache;
+
+       /** @var  */
+       protected $namedExpansionCache;
 
        /**
         * @param Preprocessor $preprocessor
@@ -1361,7 +1397,9 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
         * @param array $namedArgs
         * @param Title $title
         */
-       function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
+       function __construct( $preprocessor, $parent = false, $numberedArgs = array(),
+               $namedArgs = array(), $title = false
+       ) {
                parent::__construct( $preprocessor );
 
                $this->parent = $parent;
@@ -1450,7 +1488,10 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
                }
                if ( !isset( $this->numberedExpansionCache[$index] ) ) {
                        # No trimming for unnamed arguments
-                       $this->numberedExpansionCache[$index] = $this->parent->expand( $this->numberedArgs[$index], PPFrame::STRIP_COMMENTS );
+                       $this->numberedExpansionCache[$index] = $this->parent->expand(
+                               $this->numberedArgs[$index],
+                               PPFrame::STRIP_COMMENTS
+                       );
                }
                return $this->numberedExpansionCache[$index];
        }
@@ -1498,7 +1539,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
  * @ingroup Parser
  */
 class PPCustomFrame_Hash extends PPFrame_Hash {
-       var $args;
+       /** @var array */
+       protected $args;
 
        function __construct( $preprocessor, $args ) {
                parent::__construct( $preprocessor );
@@ -1548,7 +1590,13 @@ class PPCustomFrame_Hash extends PPFrame_Hash {
  * @ingroup Parser
  */
 class PPNode_Hash_Tree implements PPNode {
-       var $name, $firstChild, $lastChild, $nextSibling;
+       public $name;
+
+       public $firstChild;
+
+       public $lastChild;
+
+       public $nextSibling;
 
        function __construct( $name ) {
                $this->name = $name;
@@ -1770,7 +1818,9 @@ class PPNode_Hash_Tree implements PPNode {
  * @ingroup Parser
  */
 class PPNode_Hash_Text implements PPNode {
-       var $value, $nextSibling;
+       public $value;
+
+       public $nextSibling;
 
        function __construct( $value ) {
                if ( is_object( $value ) ) {
@@ -1787,22 +1837,50 @@ class PPNode_Hash_Text implements PPNode {
                return $this->nextSibling;
        }
 
-       function getChildren() { return false; }
-       function getFirstChild() { return false; }
-       function getChildrenOfType( $name ) { return false; }
-       function getLength() { return false; }
-       function item( $i ) { return false; }
-       function getName() { return '#text'; }
-       function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+       function getChildren() {
+               return false;
+       }
+
+       function getFirstChild() {
+               return false;
+       }
+
+       function getChildrenOfType( $name ) {
+               return false;
+       }
+
+       function getLength() {
+               return false;
+       }
+
+       function item( $i ) {
+               return false;
+       }
+
+       function getName() {
+               return '#text';
+       }
+
+       function splitArg() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitExt() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitHeading() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
 }
 
 /**
  * @ingroup Parser
  */
 class PPNode_Hash_Array implements PPNode {
-       var $value, $nextSibling;
+       public $value;
+
+       public $nextSibling;
 
        function __construct( $value ) {
                $this->value = $value;
@@ -1820,25 +1898,50 @@ class PPNode_Hash_Array implements PPNode {
                return $this->value[$i];
        }
 
-       function getName() { return '#nodelist'; }
+       function getName() {
+               return '#nodelist';
+       }
 
        function getNextSibling() {
                return $this->nextSibling;
        }
 
-       function getChildren() { return false; }
-       function getFirstChild() { return false; }
-       function getChildrenOfType( $name ) { return false; }
-       function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+       function getChildren() {
+               return false;
+       }
+
+       function getFirstChild() {
+               return false;
+       }
+
+       function getChildrenOfType( $name ) {
+               return false;
+       }
+
+       function splitArg() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitExt() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitHeading() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
 }
 
 /**
  * @ingroup Parser
  */
 class PPNode_Hash_Attr implements PPNode {
-       var $name, $value, $nextSibling;
+       /** @var string */
+       public $name;
+
+       /** @var string */
+       public $value;
+
+       public $nextSibling;
 
        function __construct( $name, $value ) {
                $this->name = $name;
@@ -1857,12 +1960,35 @@ class PPNode_Hash_Attr implements PPNode {
                return $this->nextSibling;
        }
 
-       function getChildren() { return false; }
-       function getFirstChild() { return false; }
-       function getChildrenOfType( $name ) { return false; }
-       function getLength() { return false; }
-       function item( $i ) { return false; }
-       function splitArg() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitExt() { throw new MWException( __METHOD__ . ': not supported' ); }
-       function splitHeading() { throw new MWException( __METHOD__ . ': not supported' ); }
+       function getChildren() {
+               return false;
+       }
+
+       function getFirstChild() {
+               return false;
+       }
+
+       function getChildrenOfType( $name ) {
+               return false;
+       }
+
+       function getLength() {
+               return false;
+       }
+
+       function item( $i ) {
+               return false;
+       }
+
+       function splitArg() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitExt() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
+
+       function splitHeading() {
+               throw new MWException( __METHOD__ . ': not supported' );
+       }
 }
index efbdf05..f6bafd5 100644 (file)
@@ -101,8 +101,10 @@ abstract class Profiler {
        /** @var TransactionProfiler */
        protected $trxProfiler;
 
-       /** @var Profiler */
-       public static $__instance = null; // do not call this outside Profiler and ProfileSection
+       // @codingStandardsIgnoreStart PSR2.Classes.PropertyDeclaration.Underscore
+       /** @var Profiler Do not call this outside Profiler and ProfileSection */
+       public static $__instance = null;
+       // @codingStandardsIgnoreEnd
 
        /**
         * @param array $params
index 6911d4b..38a6436 100644 (file)
@@ -105,6 +105,7 @@ class ProfilerSimpleDB extends ProfilerStandard {
                        if ( $useTrx ) {
                                $dbw->commit();
                        }
-               } catch ( DBError $e ) {}
+               } catch ( DBError $e ) {
+               }
        }
 }
index 6de97ba..1d3b65d 100644 (file)
@@ -30,16 +30,37 @@ class ProfilerStub extends Profiler {
        public function isStub() {
                return true;
        }
+
        public function isPersistent() {
                return false;
        }
-       public function profileIn( $fn ) {}
-       public function profileOut( $fn ) {}
-       public function getOutput() {}
-       public function close() {}
-       public function logData() {}
-       public function getCurrentSection() { return ''; }
-       public function transactionWritingIn( $server, $db, $id = '' ) {}
-       public function transactionWritingOut( $server, $db, $id = '' ) {}
-       public function getRawData() { return array(); }
+
+       public function profileIn( $fn ) {
+       }
+
+       public function profileOut( $fn ) {
+       }
+
+       public function getOutput() {
+       }
+
+       public function close() {
+       }
+
+       public function logData() {
+       }
+
+       public function getCurrentSection() {
+               return '';
+       }
+
+       public function transactionWritingIn( $server, $db, $id = '' ) {
+       }
+
+       public function transactionWritingOut( $server, $db, $id = '' ) {
+       }
+
+       public function getRawData() {
+               return array();
+       }
 }
index 007850b..8c46a93 100644 (file)
@@ -130,7 +130,6 @@ class SpecialBlock extends FormSpecialPage {
                        'Target' => array(
                                'type' => 'text',
                                'label-message' => 'ipaddressorusername',
-                               'tabindex' => '1',
                                'id' => 'mw-bi-target',
                                'size' => '45',
                                'autofocus' => true,
@@ -141,7 +140,6 @@ class SpecialBlock extends FormSpecialPage {
                                'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
                                'label-message' => 'ipbexpiry',
                                'required' => true,
-                               'tabindex' => '2',
                                'options' => $suggestedDurations,
                                'other' => $this->msg( 'ipbother' )->text(),
                                'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
@@ -977,7 +975,3 @@ class SpecialBlock extends FormSpecialPage {
                return 'users';
        }
 }
-
-# BC @since 1.18
-class IPBlockForm extends SpecialBlock {
-}
index f918708..86433ca 100644 (file)
@@ -562,7 +562,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
                $form = new EditWatchlistNormalHTMLForm( $fields, $context );
                $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
-               # Used message keys: 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
+               # Used message keys:
+               # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
                $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
                $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
                $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
@@ -603,7 +604,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        );
                }
 
-               wfRunHooks( 'WatchlistEditorBuildRemoveLine', array( &$tools, $title, $title->isRedirect(), $this->getSkin() ) );
+               wfRunHooks(
+                       'WatchlistEditorBuildRemoveLine',
+                       array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
+               );
 
                return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
        }
@@ -714,10 +718,6 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
        }
 }
 
-# B/C since 1.18
-class WatchlistEditor extends SpecialEditWatchlist {
-}
-
 /**
  * Extend HTMLForm purely so we can have a more sane way of getting the section headers
  */
index 487d979..bc8e728 100644 (file)
@@ -259,8 +259,14 @@ class SpecialExport extends SpecialPage {
                        ) . '<br />';
                }
 
-               // Enable this when we can do something useful exporting/importing image information. :)
-               //$form .= Xml::checkLabel( $this->msg( 'export-images' )->text(), 'images', 'wpExportImages', false ) . '<br />';
+               /* Enable this when we can do something useful exporting/importing image information.
+               $form .= Xml::checkLabel(
+                               $this->msg( 'export-images' )->text(),
+                               'images',
+                               'wpExportImages',
+                               false
+                       ) . '<br />';
+               */
                $form .= Xml::checkLabel(
                        $this->msg( 'export-download' )->text(),
                        'wpDownload',
@@ -510,7 +516,9 @@ class SpecialExport extends SpecialPage {
         * @return array
         */
        private function getPageLinks( $inputPages, $pageSet, $depth ) {
+               // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
                for ( ; $depth > 0; --$depth ) {
+                       // @codingStandardsIgnoreEnd
                        $pageSet = $this->getLinks(
                                $inputPages, $pageSet, 'pagelinks',
                                array( 'namespace' => 'pl_namespace', 'title' => 'pl_title' ),
index 891962b..28e6479 100644 (file)
@@ -99,7 +99,9 @@ class SpecialImport extends SpecialPage {
                $sourceName = $request->getVal( "source" );
 
                $this->logcomment = $request->getText( 'log-comment' );
-               $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull( 'pagelink-depth' );
+               $this->pageLinkDepth = $wgExportMaxLinkDepth == 0
+                       ? 0
+                       : $request->getIntOrNull( 'pagelink-depth' );
                $this->rootpage = $request->getText( 'rootpage' );
 
                $user = $this->getUser();
@@ -242,7 +244,10 @@ class SpecialImport extends SpecialPage {
                                </tr>
                                <tr>
                                        <td class='mw-label'>" .
-                                       Xml::label( $this->msg( 'import-interwiki-rootpage' )->text(), 'mw-interwiki-rootpage-upload' ) .
+                                       Xml::label(
+                                               $this->msg( 'import-interwiki-rootpage' )->text(),
+                                               'mw-interwiki-rootpage-upload'
+                                       ) .
                                        "</td>
                                        <td class='mw-input'>" .
                                        Xml::input( 'rootpage', 50, $this->rootpage,
@@ -434,7 +439,9 @@ class ImportReporter extends ContextSource {
        }
 
        function reportNotice( $msg, array $params ) {
-               $this->getOutput()->addHTML( Html::element( 'li', array(), $this->msg( $msg, $params )->text() ) );
+               $this->getOutput()->addHTML(
+                       Html::element( 'li', array(), $this->msg( $msg, $params )->text() )
+               );
        }
 
        function reportLogItem( /* ... */ ) {
@@ -475,7 +482,8 @@ class ImportReporter extends ContextSource {
                                $detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
                                        $successCount )->inContentLanguage()->text();
                                if ( $this->reason ) {
-                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+                                               . $this->reason;
                                }
                                $log->addEntry( 'upload', $title, $detail, array(), $this->getUser() );
                        } else {
@@ -484,7 +492,8 @@ class ImportReporter extends ContextSource {
                                $detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
                                        $successCount )->params( $interwiki )->inContentLanguage()->text();
                                if ( $this->reason ) {
-                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+                                               . $this->reason;
                                }
                                $log->addEntry( 'interwiki', $title, $detail, array(), $this->getUser() );
                        }
@@ -492,13 +501,23 @@ class ImportReporter extends ContextSource {
                        $comment = $detail; // quick
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $title->getLatestRevID();
-                       $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleID(), $comment, true, $this->getUser() );
+                       $nullRevision = Revision::newNullRevision(
+                               $dbw,
+                               $title->getArticleID(),
+                               $comment,
+                               true,
+                               $this->getUser()
+                       );
+
                        if ( !is_null( $nullRevision ) ) {
                                $nullRevision->insertOn( $dbw );
                                $page = WikiPage::factory( $title );
                                # Update page record
                                $page->updateRevisionOn( $dbw, $nullRevision );
-                               wfRunHooks( 'NewRevisionFromEditComplete', array( $page, $nullRevision, $latest, $this->getUser() ) );
+                               wfRunHooks(
+                                       'NewRevisionFromEditComplete',
+                                       array( $page, $nullRevision, $latest, $this->getUser() )
+                               );
                        }
                } else {
                        $this->getOutput()->addHTML( "<li>" . Linker::linkKnown( $title ) . " " .
index 7982d5c..1c4f79f 100644 (file)
  * @ingroup SpecialPage
  */
 class SpecialJavaScriptTest extends SpecialPage {
-
        /**
-        * @var $frameworks Array: Mapping of framework ids and their initilizer methods
+        * @var array Mapping of framework ids and their initilizer methods
         * in this class. If a framework is requested but not in this array,
         * the 'unknownframework' error is served.
         */
-       static $frameworks = array(
+       private static $frameworks = array(
                'qunit' => 'initQUnitTesting',
        );
 
index f9caff6..6b54fe8 100644 (file)
@@ -68,14 +68,20 @@ class SpecialListFiles extends IncludableSpecialPage {
  * @ingroup SpecialPage Pager
  */
 class ImageListPager extends TablePager {
-       var $mFieldNames = null;
+       protected $mFieldNames = null;
+
        // Subclasses should override buildQueryConds instead of using $mQueryConds variable.
-       var $mQueryConds = array();
-       var $mUserName = null;
-       var $mSearch = '';
-       var $mIncluding = false;
-       var $mShowAll = false;
-       var $mTableName = 'image';
+       protected $mQueryConds = array();
+
+       protected $mUserName = null;
+
+       protected $mSearch = '';
+
+       protected $mIncluding = false;
+
+       protected $mShowAll = false;
+
+       protected $mTableName = 'image';
 
        function __construct( IContextSource $context, $userName = null, $search = '',
                $including = false, $showAll = false
@@ -298,7 +304,8 @@ class ImageListPager extends TablePager {
        function reallyDoQuery( $offset, $limit, $asc ) {
                $prevTableName = $this->mTableName;
                $this->mTableName = 'image';
-               list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+               list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+                       $this->buildQueryInfo( $offset, $limit, $asc );
                $imageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
                $this->mTableName = $prevTableName;
 
@@ -315,7 +322,8 @@ class ImageListPager extends TablePager {
                }
                $this->mIndexField = 'oi_' . substr( $this->mIndexField, 4 );
 
-               list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $asc );
+               list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+                       $this->buildQueryInfo( $offset, $limit, $asc );
                $oldimageRes = $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
 
                $this->mTableName = $prevTableName;
@@ -360,11 +368,17 @@ class ImageListPager extends TablePager {
                                }
                        }
                }
+
+               // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
                for ( ; $i < $limit && $topRes1; $i++ ) {
+                       // @codingStandardsIgnoreEnd
                        $resultArray[] = $topRes1;
                        $topRes1 = $res1->next();
                }
+
+               // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
                for ( ; $i < $limit && $topRes2; $i++ ) {
+                       // @codingStandardsIgnoreEnd
                        $resultArray[] = $topRes2;
                        $topRes2 = $res2->next();
                }
index 31034f9..a77b70c 100644 (file)
@@ -29,9 +29,6 @@
  * @author Petr Kadlec <mormegil@centrum.cz>
  */
 class SpecialListGroupRights extends SpecialPage {
-       /**
-        * Constructor
-        */
        function __construct() {
                parent::__construct( 'Listgrouprights' );
        }
@@ -118,11 +115,12 @@ class SpecialListGroupRights extends SpecialPage {
                        $addgroups = isset( $wgAddGroups[$group] ) ? $wgAddGroups[$group] : array();
                        $removegroups = isset( $wgRemoveGroups[$group] ) ? $wgRemoveGroups[$group] : array();
                        $addgroupsSelf = isset( $wgGroupsAddToSelf[$group] ) ? $wgGroupsAddToSelf[$group] : array();
-                       $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] ) ? $wgGroupsRemoveFromSelf[$group] : array();
+                       $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] )
+                               ? $wgGroupsRemoveFromSelf[$group]
+                               : array();
 
                        $id = $group == '*' ? false : Sanitizer::escapeId( $group );
-                       $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ),
-                               "
+                       $out->addHTML( Html::rawElement( 'tr', array( 'id' => $id ), "
                                <td>$grouppage$grouplink</td>
                                        <td>" .
                                        $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups,
index 95ef951..3382405 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup SpecialPage
  */
 class SpecialLockdb extends FormSpecialPage {
-       var $reason = '';
+       protected $reason = '';
 
        public function __construct() {
                parent::__construct( 'Lockdb', 'siteadmin' );
index dd5ab93..6da6674 100644 (file)
@@ -80,7 +80,9 @@ class SpecialLog extends SpecialPage {
                $type = $opts->getValue( 'type' );
                if ( !LogPage::isLogType( $type ) ) {
                        $opts->setValue( 'type', '' );
-               } elseif ( isset( $wgLogRestrictions[$type] ) && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] ) ) {
+               } elseif ( isset( $wgLogRestrictions[$type] )
+                       && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] )
+               ) {
                        throw new PermissionsError( $wgLogRestrictions[$type] );
                }
 
index f799fc5..097f1b6 100644 (file)
  * @ingroup SpecialPage
  */
 class SpecialMergeHistory extends SpecialPage {
-       var $mAction, $mTarget, $mDest, $mTimestamp, $mTargetID, $mDestID, $mComment;
+       /** @var string */
+       protected $mAction;
 
-       /**
-        * @var Title
-        */
-       var $mTargetObj, $mDestObj;
+       /** @var string */
+       protected $mTarget;
+
+       /** @var string */
+       protected $mDest;
+
+       /** @var string */
+       protected $mTimestamp;
+
+       /** @var int */
+       protected $mTargetID;
+
+       /** @var int */
+       protected $mDestID;
+
+       /** @var string */
+       protected $mComment;
+
+       /** @var bool Was posted? */
+       protected $mMerge;
+
+       /** @var bool Was submitted? */
+       protected $mSubmitted;
+
+       /** @var Title */
+       protected $mTargetObj;
+
+       /** @var Title */
+       protected $mDestObj;
 
        public function __construct() {
                parent::__construct( 'MergeHistory', 'mergehistory' );
@@ -57,7 +83,9 @@ class SpecialMergeHistory extends SpecialPage {
                }
                $this->mComment = $request->getText( 'wpComment' );
 
-               $this->mMerge = $request->wasPosted() && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) );
+               $this->mMerge = $request->wasPosted()
+                       && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) );
+
                // target page
                if ( $this->mSubmitted ) {
                        $this->mTargetObj = Title::newFromURL( $this->mTarget );
@@ -203,7 +231,10 @@ class SpecialMergeHistory extends SpecialPage {
                                        <tr>
                                                <td>&#160;</td>
                                                <td class="mw-submit">' .
-                                       Xml::submitButton( $this->msg( 'mergehistory-submit' )->text(), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) .
+                                       Xml::submitButton(
+                                               $this->msg( 'mergehistory-submit' )->text(),
+                                               array( 'name' => 'merge', 'id' => 'mw-merge-submit' )
+                                       ) .
                                        '</td>
                                        </tr>' .
                                        Xml::closeElement( 'table' ) .
@@ -290,7 +321,8 @@ class SpecialMergeHistory extends SpecialPage {
                $comment = Linker::revComment( $rev );
 
                return Html::rawElement( 'li', array(),
-                       $this->msg( 'mergehistory-revisionrow' )->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
+                       $this->msg( 'mergehistory-revisionrow' )
+                               ->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
        }
 
        function merge() {
@@ -434,7 +466,11 @@ class SpecialMergeHistory extends SpecialPage {
 }
 
 class MergeHistoryPager extends ReverseChronologicalPager {
-       public $mForm, $mConds;
+       /** @var IContextSource */
+       public $mForm;
+
+       /** @var array */
+       public $mConds;
 
        function __construct( $form, $conds = array(), $source, $dest ) {
                $this->mForm = $form;
index 14d671c..dce5ad9 100644 (file)
  * @ingroup SpecialPage
  */
 class MovePageForm extends UnlistedSpecialPage {
-       /**
-        * Objects
-        * @var Title
-        */
-       var $oldTitle, $newTitle;
-       // Text input
-       var $reason;
+       /** @var Title */
+       protected $oldTitle;
+
+       /** @var Title */
+       protected $newTitle;
+
+
+       /** @var string Text input */
+       protected $reason;
+
        // Checks
-       var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared;
+
+       /** @var bool */
+       protected $moveTalk;
+
+       /** @var bool */
+       protected $deleteAndMove;
+
+       /** @var bool */
+       protected $moveSubpages;
+
+       /** @var bool */
+       protected $fixRedirects;
+
+       /** @var bool */
+       protected $leaveRedirect;
+
+       /** @var bool */
+       protected $moveOverShared;
 
        private $watch = false;
 
@@ -685,17 +705,20 @@ class MovePageForm extends UnlistedSpecialPage {
                                        );
 
                                        $newLink = Linker::linkKnown( $newSubpage );
-                                       $extraOutput[] = $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
+                                       $extraOutput[] = $this->msg( 'movepage-page-moved' )
+                                               ->rawParams( $oldLink, $newLink )->escaped();
                                        ++$count;
 
                                        if ( $count >= $wgMaximumMovedPages ) {
-                                               $extraOutput[] = $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
+                                               $extraOutput[] = $this->msg( 'movepage-max-pages' )
+                                                       ->numParams( $wgMaximumMovedPages )->escaped();
                                                break;
                                        }
                                } else {
                                        $oldLink = Linker::linkKnown( $oldSubpage );
                                        $newLink = Linker::link( $newSubpage );
-                                       $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped();
+                                       $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
+                                               ->rawParams( $oldLink, $newLink )->escaped();
                                }
                        }
                }
index 6891b16..147d176 100644 (file)
@@ -76,7 +76,7 @@ class NewFilesPager extends ReverseChronologicalPager {
        /**
         * @var ImageGallery
         */
-       var $gallery;
+       protected $gallery;
 
        function __construct( IContextSource $context, $par = null ) {
                $this->like = $context->getRequest()->getText( 'like' );
index 66ec693..505a1ec 100644 (file)
  * @ingroup SpecialPage
  */
 class SpecialNewpages extends IncludableSpecialPage {
-       // Stored objects
-
        /**
         * @var FormOptions
         */
        protected $opts;
        protected $customFilters;
 
-       // Some internal settings
        protected $showNavigation = false;
 
        public function __construct() {
@@ -394,7 +391,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                        $oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped();
                }
 
-               return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
+               return "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} "
+                       . "{$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n";
        }
 
        /**
index 6edf2c0..7554e37 100644 (file)
@@ -27,7 +27,6 @@
  * @ingroup SpecialPage
  */
 class SpecialProtectedpages extends SpecialPage {
-
        protected $IdLevel = 'level';
        protected $IdType = 'type';
 
@@ -438,7 +437,11 @@ class ProtectedPagesPager extends TablePager {
                                        );
                                } else {
                                        $username = UserCache::singleton()->getProp( $value, 'name' );
-                                       if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_USER, $this->getUser() ) ) {
+                                       if ( LogEventsList::userCanBitfield(
+                                               $row->log_deleted,
+                                               LogPage::DELETED_USER,
+                                               $this->getUser()
+                                       ) ) {
                                                if ( $username === false ) {
                                                        $formatted = htmlspecialchars( $value );
                                                } else {
@@ -473,7 +476,11 @@ class ProtectedPagesPager extends TablePager {
                                                $this->msg( 'protectedpages-unknown-reason' )->escaped()
                                        );
                                } else {
-                                       if ( LogEventsList::userCanBitfield( $row->log_deleted, LogPage::DELETED_COMMENT, $this->getUser() ) ) {
+                                       if ( LogEventsList::userCanBitfield(
+                                               $row->log_deleted,
+                                               LogPage::DELETED_COMMENT,
+                                               $this->getUser()
+                                       ) ) {
                                                $formatted = Linker::formatComment( $value !== null ? $value : '' );
                                        } else {
                                                $formatted = $this->msg( 'rev-deleted-comment' )->escaped();
index 3cda8c6..797f588 100644 (file)
@@ -132,7 +132,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                // $this->ids = array_map( 'intval', $this->ids );
                $this->ids = array_unique( array_filter( $this->ids ) );
 
-               if ( $request->getVal( 'action' ) == 'historysubmit' || $request->getVal( 'action' ) == 'revisiondelete' ) {
+               if ( $request->getVal( 'action' ) == 'historysubmit'
+                       || $request->getVal( 'action' ) == 'revisiondelete'
+               ) {
                        // For show/hide form submission from history page
                        // Since we are access through index.php?title=XXX&action=historysubmit
                        // getFullTitle() will contain the target title and not our title
@@ -162,7 +164,11 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) );
 
                # Allow the list type to adjust the passed target
-               $this->targetObj = RevisionDeleter::suggestTarget( $this->typeName, $this->targetObj, $this->ids );
+               $this->targetObj = RevisionDeleter::suggestTarget(
+                       $this->typeName,
+                       $this->targetObj,
+                       $this->ids
+               );
 
                $this->otherReason = $request->getVal( 'wpReason' );
                # We need a target page!
@@ -277,7 +283,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * Show a deleted file version requested by the visitor.
-        * TODO Mostly copied from Special:Undelete. Refactor.
+        * @todo Mostly copied from Special:Undelete. Refactor.
         * @param string $archiveName
         */
        protected function tryShowFile( $archiveName ) {
@@ -326,7 +332,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                # a user without appropriate permissions can toddle off and
                # nab the image, and Squid will serve it
                $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
-               $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
+               $this->getRequest()->response()->header(
+                       'Cache-Control: no-cache, no-store, max-age=0, must-revalidate'
+               );
                $this->getRequest()->response()->header( 'Pragma: no-cache' );
 
                $key = $oimage->getStorageKey();
@@ -364,14 +372,18 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $numRevisions = 0;
                // Live revisions...
                $list = $this->getList();
+               // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
                for ( $list->reset(); $list->current(); $list->next() ) {
+                       // @codingStandardsIgnoreEnd
                        $item = $list->current();
+
                        if ( !$item->canView() ) {
                                if ( !$this->submitClicked ) {
                                        throw new PermissionsError( 'suppressrevision' );
                                }
                                $userAllowed = false;
                        }
+
                        $numRevisions++;
                        $this->getOutput()->addHTML( $item->getHTML() );
                }
@@ -413,7 +425,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                                Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
-                                               Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) .
+                                               Xml::input(
+                                                       'wpReason',
+                                                       60,
+                                                       $this->otherReason,
+                                                       array( 'id' => 'wpReason', 'maxlength' => 100 )
+                                               ) .
                                        '</td>' .
                                "</tr><tr>\n" .
                                        '<td></td>' .
@@ -454,10 +471,15 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         */
        protected function addUsageText() {
                // Messages: revdelete-text-text, revdelete-text-file, logdelete-text
-               $this->getOutput()->wrapWikiMsg( "<strong>$1</strong>\n$2", $this->typeLabels['text'], 'revdelete-text-others' );
+               $this->getOutput()->wrapWikiMsg(
+                       "<strong>$1</strong>\n$2", $this->typeLabels['text'],
+                       'revdelete-text-others'
+               );
+
                if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
                        $this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
                }
+
                if ( $this->mIsAllowed ) {
                        $this->getOutput()->addWikiMsg( 'revdelete-confirm' );
                }
@@ -473,26 +495,38 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                if ( $list->length() == 1 ) {
                        $list->reset();
                        $bitfield = $list->current()->getBits(); // existing field
+
                        if ( $this->submitClicked ) {
                                $bitfield = RevisionDeleter::extractBitfield( $this->extractBitParams(), $bitfield );
                        }
+
                        foreach ( $this->checks as $item ) {
                                // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
                                // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted
                                list( $message, $name, $field ) = $item;
-                               $innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field );
+                               $innerHTML = Xml::checkLabel(
+                                       $this->msg( $message )->text(),
+                                       $name,
+                                       $name,
+                                       $bitfield & $field
+                               );
+
                                if ( $field == Revision::DELETED_RESTRICTED ) {
                                        $innerHTML = "<b>$innerHTML</b>";
                                }
+
                                $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
                                $html .= "<tr>$line</tr>\n";
                        }
                } else {
                        // Otherwise, use tri-state radios
                        $html .= '<tr>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
-                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">'
+                               . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
                        $html .= "<th></th></tr>\n";
                        foreach ( $this->checks as $item ) {
                                // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name,
@@ -535,16 +569,20 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        return false;
                }
                $bitParams = $this->extractBitParams();
-               $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' ); // from dropdown
+               // from dropdown
+               $listReason = $this->getRequest()->getText( 'wpRevDeleteReasonList', 'other' );
                $comment = $listReason;
                if ( $comment != 'other' && $this->otherReason != '' ) {
                        // Entry from drop down menu + additional comment
-                       $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason;
+                       $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+                               . $this->otherReason;
                } elseif ( $comment == 'other' ) {
                        $comment = $this->otherReason;
                }
                # Can the user set this field?
-               if ( $bitParams[Revision::DELETED_RESTRICTED] == 1 && !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
+               if ( $bitParams[Revision::DELETED_RESTRICTED] == 1
+                       && !$this->getUser()->isAllowed( 'suppressrevision' )
+               ) {
                        throw new PermissionsError( 'suppressrevision' );
                }
                # If the save went through, go to success message...
@@ -567,7 +605,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        protected function success() {
                // Messages: revdelete-success, logdelete-success
                $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
-               $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeLabels['success'] );
+               $this->getOutput()->wrapWikiMsg(
+                       "<span class=\"success\">\n$1\n</span>",
+                       $this->typeLabels['success']
+               );
                $this->wasSaved = true;
                $this->revDelList->reloadFromMaster();
                $this->showForm();
index 10e7009..63eff36 100644 (file)
@@ -66,12 +66,13 @@ class SpecialRunJobs extends UnlistedSpecialPage {
 
                // Constant-time signature verification
                // http://www.emerose.com/timing-attacks-explained
-               // @todo: make a common method for this
+               // @todo Make a common method for this
                if ( !is_string( $rSig ) || strlen( $rSig ) !== strlen( $cSig ) ) {
                        $verified = false;
                } else {
                        $result = 0;
-                       for ( $i = 0; $i < strlen( $cSig ); $i++ ) {
+                       $cSigLength = strlen( $cSig );
+                       for ( $i = 0; $i < $cSigLength; $i++ ) {
                                $result |= ord( $cSig[$i] ) ^ ord( $rSig[$i] );
                        }
                        $verified = ( $result == 0 );
index c2b5f9b..2713a5f 100644 (file)
@@ -226,7 +226,11 @@ class SpecialSearch extends SpecialPage {
                                $out->addHTML(
                                        Xml::openElement( 'fieldset' ) .
                                        Xml::element( 'legend', null, $this->msg( 'search-external' )->text() ) .
-                                       Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), $this->msg( 'searchdisabled' )->text() ) .
+                                       Xml::element(
+                                               'p',
+                                               array( 'class' => 'mw-searchdisabled' ),
+                                               $this->msg( 'searchdisabled' )->text()
+                                       ) .
                                        $this->msg( 'googlesearch' )->rawParams(
                                                htmlspecialchars( $term ),
                                                'UTF-8',
@@ -284,7 +288,8 @@ class SpecialSearch extends SpecialPage {
                                $stParams
                        );
 
-                       $this->didYouMeanHtml = '<div class="searchdidyoumean">' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+                       $this->didYouMeanHtml = '<div class="searchdidyoumean">'
+                               . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
                }
 
                if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
@@ -363,7 +368,10 @@ class SpecialSearch extends SpecialPage {
                        // Show the create link ahead
                        $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
                        if ( $totalRes > $this->limit || $this->offset ) {
-                               $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
+                               $prevnext = $this->getLanguage()->viewPrevNext(
+                                       $this->getPageTitle(),
+                                       $this->offset,
+                                       $this->limit,
                                        $this->powerSearchOptions() + array( 'search' => $term ),
                                        max( $titleMatchesNum, $textMatchesNum ) < $this->limit
                                );
@@ -444,7 +452,11 @@ class SpecialSearch extends SpecialPage {
                } else {
                        $messageName = 'searchmenu-new-nocreate';
                }
-               $params = array( $messageName, wfEscapeWikiText( $title->getPrefixedText() ), Message::numParam( $num ) );
+               $params = array(
+                       $messageName,
+                       wfEscapeWikiText( $title->getPrefixedText() ),
+                       Message::numParam( $num )
+               );
                wfRunHooks( 'SpecialSearchCreateLink', array( $title, &$params ) );
 
                // Extensions using the hook might still return an empty $messageName
@@ -708,7 +720,8 @@ class SpecialSearch extends SpecialPage {
                        &$score, &$size, &$date, &$related,
                        &$html
                ) ) ) {
-                       $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
+                       $html = "<li><div class='mw-search-result-heading'>" .
+                               "{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
                                "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
                                "</li>\n";
                }
@@ -734,7 +747,8 @@ class SpecialSearch extends SpecialPage {
 
                // work out custom project captions
                $customCaptions = array();
-               $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line <iwprefix>:<caption>
+               // format per line <iwprefix>:<caption>
+               $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() );
                foreach ( $customLines as $line ) {
                        $parts = explode( ":", $line, 2 );
                        if ( count( $parts ) == 2 ) { // validate line
@@ -756,8 +770,7 @@ class SpecialSearch extends SpecialPage {
                        }
                }
 
-
-               // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
+               // @todo Should support paging in a non-confusing way (not sure how though, maybe via ajax)..
                $out .= "</ul></div>\n";
 
                // convert the whole thing to desired language variant
index 7fe3bd9..83e731a 100644 (file)
@@ -36,17 +36,76 @@ class GenerateJsonI18n extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Build JSON messages files from a PHP messages file";
-               $this->addArg( 'phpfile', 'PHP file defining a $messages array', true );
-               $this->addArg( 'jsondir', 'Directory to write JSON files to. ' .
-                       'Required unless <phpfile> exists and --shim-only is specified', false );
+
+               $this->addArg( 'phpfile', 'PHP file defining a $messages array', false );
+               $this->addArg( 'jsondir', 'Directory to write JSON files to', false );
                $this->addOption( 'langcode', 'Language code; only needed for converting core i18n files',
                        false, true );
+               $this->addOption( 'extension', 'Perform default conversion on an extension',
+                       false, true );
                $this->addOption( 'shim-only', 'Only create or update the backward-compatibility shim' );
+               $this->addOption( 'supplementary', 'Find supplementary i18n files in subdirs and convert those',
+                       false, false );
        }
 
        public function execute() {
+               global $IP;
+
                $phpfile = $this->getArg( 0 );
                $jsondir = $this->getArg( 1 );
+               $extension = $this->getOption( 'extension' );
+               $convertSupplementaryI18nFiles = $this->hasOption( 'supplementary' );
+
+               if ( $extension ) {
+                       if ( $phpfile ) {
+                               $this->error( "The phpfile is already specified, conflicts with --extension.\n", 1 );
+                       }
+                       $phpfile = "$IP/extensions/$extension/$extension.i18n.php";
+               }
+
+               if ( !$phpfile ) {
+                       $this->error( "I'm here for an argument!\n" );
+                       $this->maybeHelp( true );
+                       // dies.
+               }
+
+               if ( $convertSupplementaryI18nFiles ) {
+                       if ( is_readable( $phpfile ) ) {
+                               $this->transformI18nFile( $phpfile, $jsondir );
+                       } else {
+                               // This is non-fatal because we might want to continue searching for
+                               // i18n files in subdirs even if the extension does not include a
+                               // primary i18n.php.
+                               $this->error( "Warning: no primary i18n file was found." );
+                       }
+                       $this->output( "Searching for supplementary i18n files...\n" );
+                       $dir_iterator = new RecursiveDirectoryIterator( dirname( $phpfile ) );
+                       $iterator = new RecursiveIteratorIterator( $dir_iterator, RecursiveIteratorIterator::LEAVES_ONLY );
+                       foreach ( $iterator as $path => $fileObject ) {
+                               if ( fnmatch( "*.i18n.php", $fileObject->getFilename() ) ) {
+                                       $this->output( "Converting $path.\n" );
+                                       $this->transformI18nFile( $path );
+                               }
+                       }
+               } else {
+                       // Just convert the primary i18n file.
+                       $this->transformI18nFile( $phpfile, $jsondir );
+               }
+       }
+
+       public function transformI18nFile( $phpfile, $jsondir = null ) {
+               if ( !$jsondir ) {
+                       // Assume the json directory should be in the same directory as the
+                       // .i18n.php file.
+                       $jsondir = dirname( $phpfile ) . "/i18n";
+               }
+               if ( !is_dir( $jsondir ) ) {
+                       $this->output( "Creating directory $jsondir.\n" );
+                       $success = mkdir( $jsondir );
+                       if ( !$success ) {
+                               $this->error( "Could not create directory $jsondir\n", 1 );
+                       }
+               }
 
                if ( $this->hasOption( 'shim-only' ) ) {
                        $this->shimOnly( $phpfile, $jsondir );
diff --git a/maintenance/pageExists.php b/maintenance/pageExists.php
new file mode 100644 (file)
index 0000000..c4b208a
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * @ingroup Maintenance
+ */
+class PageExists extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->mDescription = "Report whether a specific page exists";
+               $this->addArg( 'title', 'Page title to check whether it exists' );
+       }
+
+       public function execute() {
+               $titleArg = $this->getArg();
+               $title = Title::newFromText( $titleArg );
+               $pageExists = $title && $title->exists();
+
+               $text = '';
+               $code = 0;
+               if ( $pageExists ) {
+                       $text = "{$title} exists.";
+               } else {
+                       $text = "{$title} doesn't exist.";
+                       $code = 1;
+               }
+               $this->output( $text );
+               $this->error( '', $code );
+       }
+}
+
+$maintClass = "PageExists";
+require_once RUN_MAINTENANCE_IF_MAIN;
+
index aa33d86..af2dee1 100644 (file)
        function doWatchInternal( pages, ok, err, addParams ) {
                // XXX: Parameter addParams is undocumented because we inherit this
                // documentation in the public method...
-               var apiPromise = this.post(
+               var apiPromise = this.postWithToken( 'watch',
                        $.extend(
                                {
                                        action: 'watch',
                                        titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ),
-                                       token: mw.user.tokens.get( 'watchToken' ),
                                        uselang: mw.config.get( 'wgUserLanguage' )
                                },
                                addParams
index b64ceb0..a6d3b55 100644 (file)
@@ -104,16 +104,6 @@ img.thumbborder {
        border: 1px solid #dddddd;
 }
 
-/* table standards */
-table.rimage {
-       float: right;
-       width: 1pt;
-       position: relative;
-       margin-left: 1em;
-       margin-bottom: 1em;
-       text-align: center;
-}
-
 body {
        background: white;
        color: black;
@@ -277,7 +267,6 @@ span.texhtml {
 /* Galleries (see shared.css for more info) */
 li.gallerybox {
        vertical-align: top;
-       display: -moz-inline-box;
        display: inline-block;
 }
 
index ecfcfa3..2add9f2 100644 (file)
@@ -491,4 +491,18 @@ class DummyContentForTesting extends AbstractContent {
        ) {
                return new ParserOutput( $this->getNativeData() );
        }
+
+       /**
+        * @see AbstractContent::fillParserOutput()
+        *
+        * @param Title $title Context title for parsing
+        * @param int|null $revId Revision ID (for {{REVISIONID}})
+        * @param ParserOptions|null $options Parser options
+        * @param bool $generateHtml Whether or not to generate HTML
+        * @param ParserOutput &$output The output object to fill (reference).
+        */
+       protected function fillParserOutput( Title $title, $revId,
+                       ParserOptions $options, $generateHtml, ParserOutput &$output ) {
+               $output = new ParserOutput( $this->getNativeData() );
+       }
 }
index bd6d41f..40484d3 100644 (file)
@@ -5,7 +5,7 @@
  * @group Database
  *        ^--- needed, because we do need the database to test link updates
  */
-class CssContentTest extends MediaWikiTestCase {
+class CssContentTest extends JavaScriptContentTest {
 
        protected function setUp() {
                parent::setUp();
index 253a035..03cbbc0 100644 (file)
@@ -7,14 +7,21 @@
  */
 class TextContentTest extends MediaWikiLangTestCase {
        protected $context;
+       protected $savedContentGetParserOutput;
 
        protected function setUp() {
+               global $wgHooks;
+
                parent::setUp();
 
                // Anon user
                $user = new User();
                $user->setName( '127.0.0.1' );
 
+               $this->context = new RequestContext( new FauxRequest() );
+               $this->context->setTitle( Title::newFromText( 'Test' ) );
+               $this->context->setUser( $user );
+
                $this->setMwGlobals( array(
                        'wgUser' => $user,
                        'wgTextModelsToParse' => array(
@@ -26,9 +33,22 @@ class TextContentTest extends MediaWikiLangTestCase {
                        'wgAlwaysUseTidy' => false,
                ) );
 
-               $this->context = new RequestContext( new FauxRequest() );
-               $this->context->setTitle( Title::newFromText( 'Test' ) );
-               $this->context->setUser( $user );
+               // bypass hooks that force custom rendering
+               if ( isset( $wgHooks['ContentGetParserOutput'] )  ) {
+                       $this->savedContentGetParserOutput = $wgHooks['ContentGetParserOutput'];
+                       unset( $wgHooks['ContentGetParserOutput'] );
+               }
+       }
+
+       public function teardown() {
+               global $wgHooks;
+
+               // restore hooks that force custom rendering
+               if ( $this->savedContentGetParserOutput !== null ) {
+                       $wgHooks['ContentGetParserOutput'] = $this->savedContentGetParserOutput;
+               }
+
+               parent::teardown();
        }
 
        public function newContent( $text ) {