*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\Database;
/**
* Displays information about a page.
$revid = $revision ? $revision->getId() : null;
}
if ( $revid !== null ) {
- $key = self::getCacheKey( $title, $revid );
- ObjectCache::getMainWANInstance()->delete( $key );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = self::getCacheKey( $cache, $title, $revid );
+ $cache->delete( $key );
}
}
// Language in which the page content is (supposed to be) written
$pageLang = $title->getPageLanguage()->getCode();
+ $pageLangHtml = $pageLang . ' - ' .
+ Language::fetchLanguageName( $pageLang, $lang->getCode() );
+ // Link to Special:PageLanguage with pre-filled page title if user has permissions
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() );
- $langDisp = $linkRenderer->makeLink(
- $titleObj,
- $this->msg( 'pageinfo-language' )->text()
- );
- } else {
- // Display just the message
- $langDisp = $this->msg( 'pageinfo-language' )->escaped();
+ $pageLangHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
+ SpecialPage::getTitleValueFor( 'PageLanguage', $title->getPrefixedText() ),
+ $this->msg( 'pageinfo-language-change' )->text()
+ ) )->escaped();
}
- $pageInfo['header-basic'][] = [ $langDisp,
- Language::fetchLanguageName( $pageLang, $lang->getCode() )
- . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() ];
+ $pageInfo['header-basic'][] = [
+ $this->msg( 'pageinfo-language' )->escaped(),
+ $pageLangHtml
+ ];
// 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()
}
$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,
protected function pageCounts( Page $page ) {
$fname = __METHOD__;
$config = $this->context->getConfig();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
- return ObjectCache::getMainWANInstance()->getWithSetCallback(
- self::getCacheKey( $page->getTitle(), $page->getLatest() ),
+ return $cache->getWithSetCallback(
+ self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
WANObjectCache::TTL_WEEK,
function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
$title = $page->getTitle();
$real_names = [];
$user_names = [];
$anon_ips = [];
- $linkRenderer = MediaWikiServices::getLinkRenderer();
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
# Sift for real versus user names
/** @var $user User */
}
/**
+ * @param WANObjectCache $cache
* @param Title $title
* @param int $revId
* @return string
*/
- protected static function getCacheKey( Title $title, $revId ) {
- return wfMemcKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
+ protected static function getCacheKey( WANObjectCache $cache, Title $title, $revId ) {
+ return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
}
}