From f0e26d680b8cbb35f55b47a83e3f15fad3bcbb32 Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Thu, 2 Apr 2020 00:25:36 +0000 Subject: [PATCH] Remove use of Revision::newFromTitle Bug: T249183 Change-Id: I0532af197c7bf4ae88c85c27cdfb5e55ea46feb3 --- SimpleCaptcha/SimpleCaptcha.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/SimpleCaptcha/SimpleCaptcha.php b/SimpleCaptcha/SimpleCaptcha.php index 63ee8160d..696f8777e 100644 --- a/SimpleCaptcha/SimpleCaptcha.php +++ b/SimpleCaptcha/SimpleCaptcha.php @@ -2,6 +2,9 @@ use MediaWiki\Auth\AuthenticationRequest; use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\RevisionAccessException; +use MediaWiki\Revision\RevisionLookup; +use MediaWiki\Revision\SlotRecord; use Wikimedia\IPUtils; /** @@ -1092,13 +1095,21 @@ class SimpleCaptcha { * @return string * @private */ - private function loadText( $title, $section, $flags = Revision::READ_LATEST ) { - $rev = Revision::newFromTitle( $title, 0, $flags ); - if ( $rev === null ) { + private function loadText( $title, $section, $flags = RevisionLookup::READ_LATEST ) { + $revRecord = MediaWikiServices::getInstance() + ->getRevisionLookup() + ->getRevisionByTitle( $title, 0, $flags ); + + if ( $revRecord === null ) { return ""; } - $content = $rev->getContent(); + try { + $content = $revRecord->getContent( SlotRecord::MAIN ); + } catch ( RevisionAccessException $e ) { + return ''; + } + $text = ContentHandler::getContentText( $content ); if ( $section !== '' ) { return MediaWikiServices::getInstance()->getParser()