Merge "Remove unused imports from test classes"
[lhc/web/wiklou.git] / includes / page / Article.php
index 6e3bace..a493854 100644 (file)
@@ -388,9 +388,12 @@ class Article implements Page {
                $this->mContentObject = $content;
                $this->mRevIdFetched = $this->mRevision->getId();
 
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $articlePage = $this;
+
                ContentHandler::runLegacyHooks(
                        'ArticleAfterFetchContentObject',
-                       [ &$this, &$this->mContentObject ],
+                       [ &$articlePage, &$this->mContentObject ],
                        '1.21'
                );
 
@@ -525,7 +528,9 @@ class Article implements Page {
                while ( !$outputDone && ++$pass ) {
                        switch ( $pass ) {
                                case 1:
-                                       Hooks::run( 'ArticleViewHeader', [ &$this, &$outputDone, &$useParserCache ] );
+                                       // Avoid PHP 7.1 warning of passing $this by reference
+                                       $articlePage = $this;
+                                       Hooks::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
                                        break;
                                case 2:
                                        # Early abort if the page doesn't exist
@@ -863,9 +868,12 @@ class Article implements Page {
                $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
 
                if ( isset( $this->mRedirectedFrom ) ) {
+                       // Avoid PHP 7.1 warning of passing $this by reference
+                       $articlePage = $this;
+
                        // This is an internally redirected page view.
                        // We'll need a backlink to the source page for navigation.
-                       if ( Hooks::run( 'ArticleViewRedirect', [ &$this ] ) ) {
+                       if ( Hooks::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
                                $redir = Linker::linkKnown(
                                        $this->mRedirectedFrom,
                                        null,
@@ -1295,7 +1303,10 @@ class Article implements Page {
         * @param int $oldid Revision ID of this article revision
         */
        public function setOldSubtitle( $oldid = 0 ) {
-               if ( !Hooks::run( 'DisplayOldSubtitle', [ &$this, &$oldid ] ) ) {
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $articlePage = $this;
+
+               if ( !Hooks::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
                        return;
                }
 
@@ -1662,6 +1673,15 @@ class Article implements Page {
                $title = $this->getTitle();
                $ctx = $this->getContext();
                $outputPage = $ctx->getOutput();
+               if ( !wfMessage( 'deletereason-dropdown' )->inContentLanguage()->isDisabled() ) {
+                       $reasonsList = Xml::getArrayFromWikiTextList(
+                               wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text()
+                       );
+                       $outputPage->addModules( 'mediawiki.reasonSuggest' );
+                       $outputPage->addJsConfigVars( [
+                               'reasons' => $reasonsList
+                       ] );
+               }
                $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
                $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
                $outputPage->addBacklinkSubtitle( $title );
@@ -1676,7 +1696,6 @@ class Article implements Page {
                Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
 
                $user = $this->getContext()->getUser();
-
                if ( $user->isAllowed( 'suppressrevision' ) ) {
                        $suppress = Html::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
                                Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
@@ -1686,7 +1705,6 @@ class Article implements Page {
                        $suppress = '';
                }
                $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
-
                $form = Html::openElement( 'form', [ 'method' => 'post',
                        'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
                        Html::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
@@ -1858,7 +1876,9 @@ class Article implements Page {
                                && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
                        // Extension may have reason to disable file caching on some pages.
                        if ( $cacheable ) {
-                               $cacheable = Hooks::run( 'IsFileCacheable', [ &$this ] );
+                               // Avoid PHP 7.1 warning of passing $this by reference
+                               $articlePage = $this;
+                               $cacheable = Hooks::run( 'IsFileCacheable', [ &$articlePage ] );
                        }
                }