Fix linking Special:ChangeContentModel from action=info
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 29 Oct 2016 18:06:15 +0000 (20:06 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 11 Nov 2016 16:46:11 +0000 (17:46 +0100)
Just link the special page, when it is there, means checking
$wgContentHandlerUseDB

Change Title::quickUserCan to Title::userCan and pass a user object to
avoid a global..
Change some other places to use the local variable, instead of calling
the context source again.

Change-Id: I561899446235165fb77b626b55f35ce716d798c9

includes/actions/InfoAction.php

index be3be85..705f5fd 100644 (file)
@@ -262,7 +262,7 @@ class InfoAction extends FormlessAction {
                $pageLang = $title->getPageLanguage()->getCode();
 
                if ( $config->get( 'PageLanguageUseDB' )
-                       && $this->getTitle()->userCan( 'pagelang', $this->getUser() )
+                       && $title->userCan( 'pagelang', $user )
                ) {
                        // Link to Special:PageLanguage with pre-filled page title if user has permissions
                        $titleObj = SpecialPage::getTitleFor( 'PageLanguage', $title->getPrefixedText() );
@@ -282,7 +282,9 @@ class InfoAction extends FormlessAction {
                // Content model of the page
                $modelHtml = htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) );
                // If the user can change it, add a link to Special:ChangeContentModel
-               if ( $title->quickUserCan( 'editcontentmodel' ) ) {
+               if ( $config->get( 'ContentHandlerUseDB' )
+                       && $title->userCan( 'editcontentmodel', $user )
+               ) {
                        $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
                                SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
                                $this->msg( 'pageinfo-content-model-change' )->text()
@@ -474,7 +476,7 @@ class InfoAction extends FormlessAction {
                        }
                        $expiry = $title->getRestrictionExpiry( $restrictionType );
                        $formattedexpiry = $this->msg( 'parentheses',
-                               $this->getLanguage()->formatExpiry( $expiry ) )->escaped();
+                               $lang->formatExpiry( $expiry ) )->escaped();
                        $message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
 
                        // Messages: restriction-edit, restriction-move, restriction-create,