*
* @file
*/
+use MediaWiki\MediaWikiServices;
/**
* Class for viewing MediaWiki article and history.
* @since 1.21
*/
protected function getContentObject() {
-
if ( $this->mPage->getId() === 0 ) {
# If this is a MediaWiki:x message, then load the messages
# and return the message value for x.
$useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
if ( $user->getStubThreshold() ) {
- $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
}
$this->showRedirectedFromHeader();
$outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
if ( !Hooks::run( 'ArticleContentViewCustom',
- [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
-
+ [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] )
+ ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
}
$this->showViewFooter();
$this->mPage->doViewUpdates( $user, $oldid );
- $outputPage->addModules( 'mediawiki.action.view.postEdit' );
+ # Load the postEdit module if the user just saved this revision
+ # See also EditPage::setPostEditCookie
+ $request = $this->getContext()->getRequest();
+ $cookieKey = EditPage::POST_EDIT_COOKIE_KEY_PREFIX . $this->getRevIdFetched();
+ $postEdit = $request->getCookie( $cookieKey );
+ if ( $postEdit ) {
+ # Clear the cookie. This also prevents caching of the response.
+ $request->response()->clearCookie( $cookieKey );
+ $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
+ $outputPage->addModules( 'mediawiki.action.view.postEdit' );
+ }
}
/**
$ns = $this->getTitle()->getNamespace();
- # Don't index user and user talk pages for blocked users (bug 11443)
+ # Don't index user and user talk pages for blocked users (T13443)
if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
$specificTarget = null;
$vagueTarget = null;
}
if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
- # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
+ # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
$policy = array_merge(
$policy,
self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
}
// Check for cached results
- $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
if ( $cache->get( $key ) ) {
return false;
}
* @since 1.27
*/
public static function purgePatrolFooterCache( $articleID ) {
- $cache = ObjectCache::getMainWANInstance();
- $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
}
/**
|| $title->getNamespace() == NS_USER_TALK
) {
$rootPart = explode( '/', $title->getText() )[0];
- $user = User::newFromName( $rootPart, false /* allow IP users*/ );
+ $user = User::newFromName( $rootPart, false /* allow IP users */ );
$ip = User::isIP( $rootPart );
$block = Block::newFromTarget( $user, $user );
# Show delete and move logs if there were any such events.
# The logging query can DOS the site when bots/crawlers cause 404 floods,
# so be careful showing this. 404 pages must be cheap as they are hard to cache.
- $cache = ObjectCache::getMainStashInstance();
- $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
+ $cache = MediaWikiServices::getInstance()->getMainObjectStash();
+ $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
$loggedIn = $this->getContext()->getUser()->isLoggedIn();
if ( $loggedIn || $cache->get( $key ) ) {
$logTypes = [ 'delete', 'move' ];
- $conds = [ "log_action != 'revision'" ];
+
+ $dbr = wfGetDB( DB_REPLICA );
+
+ $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
// Give extensions a chance to hide their (unrelated) log entries
Hooks::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
LogEventsList::showLogExtract(
* @param bool $appendSubtitle [optional]
* @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
* @return string Containing HTML with redirect link
+ *
+ * @deprecated since 1.30
*/
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
$lang = $this->getTitle()->getPageLanguage();
/**
* Call to WikiPage function for backwards compatibility.
* @see WikiPage::doPurge
+ * @note In 1.28 (and only 1.28), this took a $flags parameter that
+ * controlled how much purging was done.
*/
- public function doPurge( $flags = WikiPage::PURGE_ALL ) {
- return $this->mPage->doPurge( $flags );
+ public function doPurge() {
+ return $this->mPage->doPurge();
}
/**
* Call to WikiPage function for backwards compatibility.
* @see WikiPage::getLastPurgeTimestamp
+ * @deprecated since 1.29
*/
public function getLastPurgeTimestamp() {
+ wfDeprecated( __METHOD__, '1.29' );
return $this->mPage->getLastPurgeTimestamp();
}