X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkinTemplate.php;h=327061c68120d23e405b475f43211f9d7dea4df4;hb=3bbda79f1f09649bc4d036f2810117df46166f9c;hp=d1345b8e64b90f0e8a6f4314e96299106b1742de;hpb=ab2e77bb5d228683c2458bcec16559ac10cd2c01;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index d1345b8e64..327061c681 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -208,7 +208,7 @@ class SkinTemplate extends Skin { * Initialize various variables and generate the template */ function outputPage() { - Profiler::instance()->setTemplated( true ); + Profiler::instance()->setAllowOutput(); $out = $this->getOutput(); $this->initPage( $out ); @@ -371,11 +371,12 @@ class SkinTemplate extends Skin { $tpl->set( 'credits', false ); $tpl->set( 'numberofwatchingusers', false ); if ( $title->exists() ) { - if ( $out->isArticle() && $this->isRevisionCurrent() ) { + if ( $out->isArticle() && $out->isRevisionCurrent() ) { if ( $wgMaxCredits != 0 ) { /** @var CreditsAction $action */ $action = Action::factory( 'credits', $this->getWikiPage(), $this->getContext() ); + '@phan-var CreditsAction $action'; $tpl->set( 'credits', $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); } else { @@ -594,7 +595,7 @@ class SkinTemplate extends Skin { # $this->getTitle() will just give Special:Badtitle, which is # not especially useful as a returnto parameter. Use the title # from the request instead, if there was one. - if ( $this->getUser()->isAllowed( 'read' ) ) { + if ( $permissionManager->userHasRight( $this->getUser(), 'read' ) ) { $page = $this->getTitle(); } else { $page = Title::newFromText( $request->getVal( 'title', '' ) ); @@ -635,7 +636,7 @@ class SkinTemplate extends Skin { 'active' => ( $href == $pageurl ) ]; - if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) { + if ( $permissionManager->userHasRight( $this->getUser(), 'viewmywatchlist' ) ) { $href = self::makeSpecialUrl( 'Watchlist' ); $personal_urls['watchlist'] = [ 'text' => $this->msg( 'mywatchlist' )->text(), @@ -688,9 +689,8 @@ class SkinTemplate extends Skin { $useCombinedLoginLink = false; } - $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink - ? 'nav-login-createaccount' - : 'pt-login'; + $loginlink = $permissionManager->userHasRight( $this->getUser(), 'createaccount' ) + && $useCombinedLoginLink ? 'nav-login-createaccount' : 'pt-login'; $login_url = [ 'text' => $this->msg( $loginlink )->text(), @@ -726,7 +726,7 @@ class SkinTemplate extends Skin { if ( $authManager->canCreateAccounts() - && $this->getUser()->isAllowed( 'createaccount' ) + && $permissionManager->userHasRight( $this->getUser(), 'createaccount' ) && !$useCombinedLoginLink ) { $personal_urls['createaccount'] = $createaccount_url; @@ -884,6 +884,7 @@ class SkinTemplate extends Skin { $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $content_navigation = [ 'namespaces' => [], @@ -895,7 +896,7 @@ class SkinTemplate extends Skin { // parameters $action = $request->getVal( 'action', 'view' ); - $userCanRead = $title->quickUserCan( 'read', $user ); + $userCanRead = $permissionManager->quickUserCan( 'read', $user, $title ); // Avoid PHP 7.1 warning of passing $this by reference $skinTemplate = $this; @@ -965,8 +966,9 @@ class SkinTemplate extends Skin { } // Checks if user can edit the current page if it exists or create it otherwise - if ( $title->quickUserCan( 'edit', $user ) - && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) + if ( $permissionManager->quickUserCan( 'edit', $user, $title ) && + ( $title->exists() || + $permissionManager->quickUserCan( 'create', $user, $title ) ) ) { // Builds CSS class for talk page links $isTalkClass = $isTalk ? ' istalk' : ''; @@ -975,7 +977,7 @@ class SkinTemplate extends Skin { // Whether to show the "Add a new section" tab // Checks if this is a current rev of talk page and is not forced to be hidden $showNewSection = !$out->forceHideNewSectionLink() - && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() ); + && ( ( $isTalk && $out->isRevisionCurrent() ) || $out->showNewSectionLink() ); $section = $request->getVal( 'section' ); if ( $title->exists() @@ -1031,7 +1033,7 @@ class SkinTemplate extends Skin { 'href' => $title->getLocalURL( 'action=history' ), ]; - if ( $title->quickUserCan( 'delete', $user ) ) { + if ( $permissionManager->quickUserCan( 'delete', $user, $title ) ) { $content_navigation['actions']['delete'] = [ 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false, 'text' => wfMessageFallback( "$skname-action-delete", 'delete' ) @@ -1040,7 +1042,7 @@ class SkinTemplate extends Skin { ]; } - if ( $title->quickUserCan( 'move', $user ) ) { + if ( $permissionManager->quickUserCan( 'move', $user, $title ) ) { $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() ); $content_navigation['actions']['move'] = [ 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false, @@ -1051,13 +1053,14 @@ class SkinTemplate extends Skin { } } else { // article doesn't exist or is deleted - if ( $title->quickUserCan( 'deletedhistory', $user ) ) { + if ( $permissionManager->quickUserCan( 'deletedhistory', $user, $title ) ) { $n = $title->isDeleted(); if ( $n ) { $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() ); // If the user can't undelete but can view deleted // history show them a "View .. deleted" tab instead. - $msgKey = $title->quickUserCan( 'undelete', $user ) ? 'undelete' : 'viewdeleted'; + $msgKey = $permissionManager->quickUserCan( 'undelete', + $user, $title ) ? 'undelete' : 'viewdeleted'; $content_navigation['actions']['undelete'] = [ 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false, 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" ) @@ -1068,9 +1071,9 @@ class SkinTemplate extends Skin { } } - if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() && - MediaWikiServices::getInstance()->getPermissionManager() - ->getNamespaceRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ] + if ( $permissionManager->quickUserCan( 'protect', $user, $title ) && + $title->getRestrictionTypes() && + $permissionManager->getNamespaceRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ] ) { $mode = $title->isProtected() ? 'unprotect' : 'protect'; $content_navigation['actions'][$mode] = [ @@ -1082,9 +1085,8 @@ class SkinTemplate extends Skin { } // Checks if the user is logged in - if ( $this->loggedin && MediaWikiServices::getInstance() - ->getPermissionManager() - ->userHasAllRights( $user, 'viewmywatchlist', 'editmywatchlist' ) + if ( $this->loggedin && $permissionManager->userHasAllRights( $user, + 'viewmywatchlist', 'editmywatchlist' ) ) { /** * The following actions use messages which, if made particular to @@ -1295,7 +1297,7 @@ class SkinTemplate extends Skin { if ( $out->isArticle() ) { // Also add a "permalink" while we're at it - $revid = $this->getRevisionId(); + $revid = $this->getOutput()->getRevisionId(); if ( $revid ) { $nav_urls['permalink'] = [ 'text' => $this->msg( 'permalink' )->text(), @@ -1341,7 +1343,10 @@ class SkinTemplate extends Skin { 'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser ) ]; - if ( $this->getUser()->isAllowed( 'block' ) ) { + if ( MediawikiServices::getInstance() + ->getPermissionManager() + ->userHasRight( $this->getUser(), 'block' ) + ) { $nav_urls['blockip'] = [ 'text' => $this->msg( 'blockip', $rootUser )->text(), 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )