* @ingroup DifferenceEngine
*/
-use MediaWiki\Storage\RevisionRecord;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Revision\SlotRecord;
/**
* DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
protected function getSlotContents() {
if ( $this->isContentOverridden ) {
return [
- 'main' => [
+ SlotRecord::MAIN => [
'old' => $this->mOldContent,
'new' => $this->mNewContent,
]
];
}
// move main slot to front
- if ( isset( $slots['main'] ) ) {
- $slots = [ 'main' => $slots['main'] ] + $slots;
+ if ( isset( $slots[SlotRecord::MAIN] ) ) {
+ $slots = [ SlotRecord::MAIN => $slots[SlotRecord::MAIN] ] + $slots;
}
return $slots;
}
foreach ( $this->getSlotDiffRenderers() as $role => $slotDiffRenderer ) {
$slotDiff = $slotDiffRenderer->getDiff( $slotContents[$role]['old'],
$slotContents[$role]['new'] );
- if ( $slotDiff && $role !== 'main' ) {
+ if ( $slotDiff && $role !== SlotRecord::MAIN ) {
// TODO use human-readable role name at least
$slotTitle = $role;
$difftext .= $this->getSlotHeader( $slotTitle );
return false;
}
- if ( $role !== 'main' ) {
+ if ( $role !== SlotRecord::MAIN ) {
// TODO use human-readable role name at least
$slotTitle = $role;
$slotDiff = $this->getSlotHeader( $slotTitle ) . $slotDiff;
$this->mOldPage = Title::newFromLinkTarget( $oldRevision->getPageAsLinkTarget() );
// This method is meant for edit diffs and such so there is no reason to provide a
// revision that's not readable to the user, but check it just in case.
- $this->mOldContent = $oldRevision ? $oldRevision->getContent( 'main',
+ $this->mOldContent = $oldRevision ? $oldRevision->getContent( SlotRecord::MAIN,
RevisionRecord::FOR_THIS_USER, $this->getUser() ) : null;
} else {
$this->mOldPage = null;
$this->mNewRev = new Revision( $newRevision );
$this->mNewid = $newRevision->getId();
$this->mNewPage = Title::newFromLinkTarget( $newRevision->getPageAsLinkTarget() );
- $this->mNewContent = $newRevision->getContent( 'main',
+ $this->mNewContent = $newRevision->getContent( SlotRecord::MAIN,
RevisionRecord::FOR_THIS_USER, $this->getUser() );
$this->mRevisionsIdsLoaded = $this->mRevisionsLoaded = true;
* @param Language $lang
* @since 1.19
*/
- public function setTextLanguage( $lang ) {
- if ( !$lang instanceof Language ) {
- wfDeprecated( __METHOD__ . ' with other type than Language for $lang', '1.32' );
- }
- $this->mDiffLang = wfGetLangObj( $lang );
+ public function setTextLanguage( Language $lang ) {
+ $this->mDiffLang = $lang;
}
/**