From 47f861b6f620c1b69fdbde8249570ed7c99d1356 Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Thu, 24 Jun 2021 03:30:34 +0000 Subject: [PATCH] Pass a user to WikiPage::prepareContentForEdit() Bug: T285447 Change-Id: I4d277419106c3af5222377a863c80dd866ba188b --- includes/Variables/LazyVariableComputer.php | 12 ++++++++++-- tests/phpunit/LazyVariableComputerDBTest.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/Variables/LazyVariableComputer.php b/includes/Variables/LazyVariableComputer.php index b4f5b874b..9ea61a43a 100644 --- a/includes/Variables/LazyVariableComputer.php +++ b/includes/Variables/LazyVariableComputer.php @@ -189,7 +189,11 @@ class LazyVariableComputer { $new_text = $getVarCB( $textVar )->toString(); $content = ContentHandler::makeContent( $new_text, $article->getTitle() ); - $editInfo = $article->prepareContentForEdit( $content ); + $editInfo = $article->prepareContentForEdit( + $content, + null, + $parameters['contextUser'] + ); $result = array_keys( $editInfo->output->getExternalLinks() ); self::$profilingExtraTime += ( microtime( true ) - $startTime ); break; @@ -253,7 +257,11 @@ class LazyVariableComputer { $new_text = $getVarCB( $textVar )->toString(); $content = ContentHandler::makeContent( $new_text, $article->getTitle() ); - $editInfo = $article->prepareContentForEdit( $content ); + $editInfo = $article->prepareContentForEdit( + $content, + null, + $parameters['contextUser'] + ); if ( isset( $parameters['pst'] ) && $parameters['pst'] ) { $result = $editInfo->pstContent->serialize( $editInfo->format ); } else { diff --git a/tests/phpunit/LazyVariableComputerDBTest.php b/tests/phpunit/LazyVariableComputerDBTest.php index 2cdea41bd..a7e6615bd 100644 --- a/tests/phpunit/LazyVariableComputerDBTest.php +++ b/tests/phpunit/LazyVariableComputerDBTest.php @@ -46,7 +46,7 @@ class LazyVariableComputerDBTest extends MediaWikiIntegrationTestCase { ] ); $generator = AbuseFilterServices::getVariableGeneratorFactory()->newGenerator( $baseVars ); - $actualHolder = $generator->addEditVars( $page, $this->createMock( User::class ) ) + $actualHolder = $generator->addEditVars( $page, $this->getTestUser()->getUser() ) ->getVariableHolder(); $actual = AbuseFilterServices::getVariablesManager()->exportAllVars( $actualHolder );