X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkinTemplate.php;h=70df73bc21322601ab7648b5e82ca3d9b4dcf2dc;hb=13fb29a9afd3729fea842856ad0d595e3f86f065;hp=af7ec294e99bb07a76514f773f05b1bf86b7e970;hpb=4d6d27b07bf47d09ed255118399502ea831b2fcb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index af7ec294e9..70df73bc21 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 { @@ -585,6 +586,7 @@ class SkinTemplate extends Skin { $request = $this->getRequest(); $pageurl = $title->getLocalURL(); $authManager = AuthManager::singleton(); + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); /* set up the default links for the personal toolbar */ $personal_urls = []; @@ -704,7 +706,7 @@ class SkinTemplate extends Skin { ]; // No need to show Talk and Contributions to anons if they can't contribute! - if ( User::groupHasPermission( '*', 'edit' ) ) { + if ( $permissionManager->groupHasPermission( '*', 'edit' ) ) { // Because of caching, we can't link directly to the IP talk and // contributions pages. Instead we use the special page shortcuts // (which work correctly regardless of caching). This means we can't @@ -732,7 +734,7 @@ class SkinTemplate extends Skin { } if ( $authManager->canAuthenticateNow() ) { - $key = User::groupHasPermission( '*', 'read' ) + $key = $permissionManager->groupHasPermission( '*', 'read' ) ? 'login' : 'login-private'; $personal_urls[$key] = $login_url; @@ -883,6 +885,7 @@ class SkinTemplate extends Skin { $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); $content_navigation = [ 'namespaces' => [], @@ -894,7 +897,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; @@ -964,8 +967,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' : ''; @@ -974,7 +978,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() @@ -1030,7 +1034,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' ) @@ -1039,7 +1043,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, @@ -1050,13 +1054,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" ) @@ -1067,9 +1072,10 @@ class SkinTemplate extends Skin { } } - if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() && - MediaWikiServices::getInstance()->getNamespaceInfo()-> - getRestrictionLevels( $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] = [ @@ -1081,7 +1087,9 @@ class SkinTemplate extends Skin { } // Checks if the user is logged in - if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) { + if ( $this->loggedin && $permissionManager->userHasAllRights( $user, + 'viewmywatchlist', 'editmywatchlist' ) + ) { /** * The following actions use messages which, if made particular to * the any specific skins, would break the Ajax code which makes this @@ -1291,7 +1299,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(),