use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\RevisionRenderer;
use MediaWiki\Revision\RevisionStore;
+use MediaWiki\Revision\SlotRoleRegistry;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Storage\DerivedPageDataUpdater;
use MediaWiki\Storage\PageUpdater;
return MediaWikiServices::getInstance()->getRevisionRenderer();
}
+ /**
+ * @return SlotRoleRegistry
+ */
+ private function getSlotRoleRegistry() {
+ return MediaWikiServices::getInstance()->getSlotRoleRegistry();
+ }
+
/**
* @return ParserCache
*/
// links.
$hasLinks = (bool)count( $editInfo->output->getLinks() );
} else {
- // NOTE: keep in sync with revisionRenderer::getLinkCount
+ // NOTE: keep in sync with RevisionRenderer::getLinkCount
+ // NOTE: keep in sync with DerivedPageDataUpdater::isCountable
$hasLinks = (bool)wfGetDB( DB_REPLICA )->selectField( 'pagelinks', 1,
[ 'pl_from' => $this->getId() ], __METHOD__ );
}
}
+ // TODO: MCR: determine $hasLinks for each slot, and use that info
+ // with that slot's Content's isCountable method. That requires per-
+ // slot ParserOutput in the ParserCache, or per-slot info in the
+ // pagelinks table.
return $content->isCountable( $hasLinks );
}
// rd_fragment and rd_interwiki were added later, populate them if empty
if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
+ // (T203942) We can't redirect to Media namespace because it's virtual.
+ // We don't want to modify Title objects farther down the
+ // line. So, let's fix this here by changing to File namespace.
+ if ( $row->rd_namespace == NS_MEDIA ) {
+ $namespace = NS_FILE;
+ } else {
+ $namespace = $row->rd_namespace;
+ }
$this->mRedirectTarget = Title::makeTitle(
- $row->rd_namespace, $row->rd_title,
+ $namespace, $row->rd_title,
$row->rd_fragment, $row->rd_interwiki
);
return $this->mRedirectTarget;
$dbw->startAtomic( __METHOD__ );
if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $truncatedFragment = $contLang->truncateForDatabase( $rt->getFragment(), 255 );
$dbw->upsert(
'redirect',
[
'rd_from' => $this->getId(),
'rd_namespace' => $rt->getNamespace(),
'rd_title' => $rt->getDBkey(),
- 'rd_fragment' => $rt->getFragment(),
+ 'rd_fragment' => $truncatedFragment,
'rd_interwiki' => $rt->getInterwiki(),
],
[ 'rd_from' ],
[
'rd_namespace' => $rt->getNamespace(),
'rd_title' => $rt->getDBkey(),
- 'rd_fragment' => $rt->getFragment(),
+ 'rd_fragment' => $truncatedFragment,
'rd_interwiki' => $rt->getInterwiki(),
],
__METHOD__
$this, // NOTE: eventually, PageUpdater should not know about WikiPage
$this->getRevisionStore(),
$this->getRevisionRenderer(),
+ $this->getSlotRoleRegistry(),
$this->getParserCache(),
JobQueueGroup::singleton(),
MessageCache::singleton(),
$this, // NOTE: eventually, PageUpdater should not know about WikiPage
$this->getDerivedDataUpdater( $user, null, $forUpdate, true ),
$this->getDBLoadBalancer(),
- $this->getRevisionStore()
+ $this->getRevisionStore(),
+ $this->getSlotRoleRegistry()
);
$pageUpdater->setUsePageCreationLog( $wgPageCreationLog );
}
$this->loadPageData( 'fromdbmaster' );
+ $this->mTitle->loadRestrictions( null, Title::READ_LATEST );
$restrictionTypes = $this->mTitle->getRestrictionTypes();
$id = $this->getId();
// in the job queue to avoid simultaneous deletion operations would add overhead.
// Number of archived revisions cannot be known beforehand, because edits can be made
// while deletion operations are being processed, changing the number of archivals.
- $archivedRevisionCount = $dbw->selectRowCount(
- 'archive', '1', [ 'ar_page_id' => $id ], __METHOD__
+ $archivedRevisionCount = (int)$dbw->selectField(
+ 'archive', 'COUNT(*)',
+ [
+ 'ar_namespace' => $this->getTitle()->getNamespace(),
+ 'ar_title' => $this->getTitle()->getDBkey(),
+ 'ar_page_id' => $id
+ ], __METHOD__
);
// Clone the title and wikiPage, so we have the information we need when
if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) {
$dbw->delete( 'revision_comment_temp', [ 'revcomment_rev' => $revids ], __METHOD__ );
}
- if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
+ if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
$dbw->delete( 'revision_actor_temp', [ 'revactor_rev' => $revids ], __METHOD__ );
}
if ( $wgUseRCPatrol ) {
// Mark all reverted edits as patrolled
- $set['rc_patrolled'] = RecentChange::PRC_PATROLLED;
+ $set['rc_patrolled'] = RecentChange::PRC_AUTOPATROLLED;
}
if ( count( $set ) ) {
// Do not include the namespace since there can be multiple aliases to it
// due to different namespace text definitions on different wikis. This only
// means that some cache invalidations happen that are not strictly needed.
- $cache->makeGlobalKey( 'interwiki-page', wfWikiID(), $title->getDBkey() )
+ $cache->makeGlobalKey(
+ 'interwiki-page',
+ WikiMap::getCurrentWikiDbDomain()->getId(),
+ $title->getDBkey()
+ )
);
} );
}