phpmediawikimediawiki-extensions

Build revision object using revision id


I am trying to get some content of a particular revision.I am not sure on how to build a revision object using revision id.

$prevId = ApprovedRevs::getPublishedRevID($titleObject);
$revision = ??  how to build this object using above $prevId ??
$content = $revision->getContent(Revision::RAW);
$content = ContentHandler::getContentText($content);
return $content;

Solution

  • The simplest way is

    $revision = \MediaWiki\MediaWikiServices::getInstance()->getRevisionLookup()->getRevisionById( $prevId );
    if ( !$revision ) { /* panic */ }
    

    although the more conventional way of structuring the code would be using dependency injection.