* Initialize various variables and generate the template
*/
function outputPage() {
- Profiler::instance()->setTemplated( true );
+ Profiler::instance()->setAllowOutput();
$out = $this->getOutput();
$this->initPage( $out );
$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 {
$request = $this->getRequest();
$pageurl = $title->getLocalURL();
$authManager = AuthManager::singleton();
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
/* set up the default links for the personal toolbar */
$personal_urls = [];
];
// 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
}
if ( $authManager->canAuthenticateNow() ) {
- $key = User::groupHasPermission( '*', 'read' )
+ $key = $permissionManager->groupHasPermission( '*', 'read' )
? 'login'
: 'login-private';
$personal_urls[$key] = $login_url;
$out = $this->getOutput();
$request = $this->getRequest();
$user = $this->getUser();
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
$content_navigation = [
'namespaces' => [],
// 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;
}
// 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' : '';
// 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()
'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' )
];
}
- 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,
}
} 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" )
}
}
- 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] = [
}
// 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
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(),