+ protected static $pageId;
+ protected static $revIds = [];
+
+ public function addDBDataOnce() {
+ $user = static::getTestSysop()->getUser();
+ $title = Title::newFromText( __CLASS__ );
+ $page = WikiPage::factory( $title );
+
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( 'Test for revdel', $title, CONTENT_MODEL_WIKITEXT ),
+ __METHOD__ . ' Test for revdel', 0, false, $user
+ );
+ if ( !$status->isOk() ) {
+ $this->fail( "Failed to create $title: " . $status->getWikiText( false, false, 'en' ) );
+ }
+ self::$pageId = $status->value['revision']->getPage();
+ self::$revIds['revdel'] = $status->value['revision']->getId();
+
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( 'Test for oldid', $title, CONTENT_MODEL_WIKITEXT ),
+ __METHOD__ . ' Test for oldid', 0, false, $user
+ );
+ if ( !$status->isOk() ) {
+ $this->fail( "Failed to edit $title: " . $status->getWikiText( false, false, 'en' ) );
+ }
+ self::$revIds['oldid'] = $status->value['revision']->getId();
+
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( 'Test for latest', $title, CONTENT_MODEL_WIKITEXT ),
+ __METHOD__ . ' Test for latest', 0, false, $user
+ );
+ if ( !$status->isOk() ) {
+ $this->fail( "Failed to edit $title: " . $status->getWikiText( false, false, 'en' ) );
+ }
+ self::$revIds['latest'] = $status->value['revision']->getId();
+
+ RevisionDeleter::createList(
+ 'revision', RequestContext::getMain(), $title, [ self::$revIds['revdel'] ]
+ )->setVisibility( [
+ 'value' => [
+ Revision::DELETED_TEXT => 1,
+ ],
+ 'comment' => 'Test for revdel',
+ ] );
+
+ Title::clearCaches(); // Otherwise it has the wrong latest revision for some reason