Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Revision class was soft deprecated
Browse files Browse the repository at this point in the history
Fixes #108

(cherry picked from commit 1427a7e)
  • Loading branch information
lens0021 committed Oct 6, 2020
1 parent b458a3b commit 7229b24
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions includes/specials/SpacialSanctions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Flow\Model\UUID;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionLookup;

class SpacialSanctions extends SpecialPage {
/**
Expand All @@ -23,8 +25,15 @@ class SpacialSanctions extends SpecialPage {
*/
protected $mNewRevisionId;

/**
* @var RevisionLookup
*/
protected $revLookup;

public function __construct() {
parent::__construct( 'Sanctions' );

$this->revLookup = MediaWikiServices::getInstance()->getRevisionLookup();
}

/**
Expand Down Expand Up @@ -84,6 +93,8 @@ public function execute( $subpage ) {
* @param string $subpage
*/
private function setParameter( $subpage ) {
$revLookup = $this->revLookup;

$parts = explode( '/', $subpage, 3 );

$targetName = '';
Expand Down Expand Up @@ -123,29 +134,31 @@ private function setParameter( $subpage ) {
return;
}

// Fetch newRivisionId
// Fetch newRevisionId
$newRevisionId = (int)$parts[ count( $parts ) - 1 ];

$newRevision = Revision::newFromId( $newRevisionId );
$newRevision = $revLookup->getRevisionById( $newRevisionId );
if ( !$newRevision ) {
$newRevisionId = null;
return;
}

// Fetch oldRivisionId
// Fetch oldRevisionId
if ( count( $parts ) == 3 ) {
$oldRevisionId = (int)$parts[1];
$oldRevision = Revision::newFromId( $oldRevisionId );
$oldRevision = $revLookup->getRevisionById( $oldRevisionId );
if ( !$oldRevision ) {
if ( $newRevision->getPrevious() ) {
$oldRevisionId = $newRevision->getPrevious()->getId();
$preRev = $revLookup->getPreviousRevision( $newRevision );
if ( $preRev ) {
$oldRevisionId = $preRev->getId();
} else {
$oldRevisionId = null;
}
}
} else {
if ( $newRevision->getPrevious() ) {
$oldRevisionId = $newRevision->getPrevious()->getId();
$preRev = $revLookup->getPreviousRevision( $newRevision );
if ( $preRev ) {
$oldRevisionId = $preRev->getId();
} else {
$oldRevisionId = null;
}
Expand Down Expand Up @@ -456,20 +469,20 @@ protected function makeDiffLink() {
return '';
}

$newRevision = Revision::newFromId( $newRevisionId );
$newRevision = $this->revLookup->getRevisionById( $newRevisionId );
$oldRevisionId = $this->mOldRevisionId;

$rt = '';
if ( $oldRevisionId != null ) {
$rt = wfMessage( 'sanctions-topic-diff', [
(string)$oldRevisionId,
(string)$newRevisionId,
$newRevision->getTitle()->getFullText()
(string)$newRevision->getPageAsLinkTarget()
] )->inContentLanguage()->text();
} else {
$rt = wfMessage( 'sanctions-topic-revision', [
(string)$newRevisionId,
$newRevision->getTitle()->getFullText()
(string)$newRevision->getPageAsLinkTarget()
] )->inContentLanguage()->text();
}

Expand Down

0 comments on commit 7229b24

Please sign in to comment.