Merge "Relax phpdoc of PermissionError to match actual usage"
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index ea66900..c039388 100644 (file)
@@ -202,6 +202,7 @@ class InfoAction extends FormlessAction {
                $title = $this->getTitle();
                $id = $title->getArticleID();
                $config = $this->context->getConfig();
+               $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
 
                $pageCounts = $this->pageCounts( $this->page );
 
@@ -279,9 +280,18 @@ class InfoAction extends FormlessAction {
                        . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() ];
 
                // 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' ) ) {
+                       $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
+                               SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
+                               $this->msg( 'pageinfo-content-model-change' )->text()
+                       ) )->escaped();
+               }
+
                $pageInfo['header-basic'][] = [
                        $this->msg( 'pageinfo-content-model' ),
-                       htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) )
+                       $modelHtml
                ];
 
                // Search engine status
@@ -621,14 +631,15 @@ class InfoAction extends FormlessAction {
                                        $more = null;
                                }
 
+                               $templateListFormatter = new TemplatesOnThisPageFormatter(
+                                       $this->getContext(),
+                                       $linkRenderer
+                               );
+
                                $pageInfo['header-properties'][] = [
                                        $this->msg( 'pageinfo-templates' )
                                                ->numParams( $pageCounts['transclusion']['from'] ),
-                                       Linker::formatTemplates(
-                                               $transcludedTemplates,
-                                               false,
-                                               false,
-                                               $more )
+                                       $templateListFormatter->format( $transcludedTemplates, false, $more )
                                ];
                        }
 
@@ -644,14 +655,15 @@ class InfoAction extends FormlessAction {
                                        $more = null;
                                }
 
+                               $templateListFormatter = new TemplatesOnThisPageFormatter(
+                                       $this->getContext(),
+                                       $linkRenderer
+                               );
+
                                $pageInfo['header-properties'][] = [
                                        $this->msg( 'pageinfo-transclusions' )
                                                ->numParams( $pageCounts['transclusion']['to'] ),
-                                       Linker::formatTemplates(
-                                               $transcludedTargets,
-                                               false,
-                                               false,
-                                               $more )
+                                       $templateListFormatter->format( $transcludedTargets, false, $more )
                                ];
                        }
                }
@@ -676,9 +688,8 @@ class InfoAction extends FormlessAction {
                                $title = $page->getTitle();
                                $id = $title->getArticleID();
 
-                               $dbr = wfGetDB( DB_SLAVE );
-                               $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' );
-
+                               $dbr = wfGetDB( DB_REPLICA );
+                               $dbrWatchlist = wfGetDB( DB_REPLICA, 'watchlist' );
                                $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
 
                                $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();