Page MenuHomePhorge

No OneTemporary

Size
14 KB
Referenced Files
None
Subscribers
None
diff --git a/RELEASE-NOTES-1.44 b/RELEASE-NOTES-1.44
index 253f1e64a13..d7eca0a5097 100644
--- a/RELEASE-NOTES-1.44
+++ b/RELEASE-NOTES-1.44
@@ -759,6 +759,12 @@ because of Phabricator reports.
* (T387995) Deprecated AbortTalkPageEmailNotification hook. Use the Notification
Middleware to filter our Talk Page notifications
* (T45646) The hook 'SkinCopyrightFooter' now emits deprecation warnings.
+* (T293512) ParserOutput::getText, deprecated in 1.42, now emits deprecation
+ warnings. It is expected to be removed in 1.45. Depending on the use case,
+ calling sites should either use ParserOutput::getRawText or call the
+ OutputTransform pipeline with ParserOutput::runOutputPipeline (unstable,
+ see T371004) or by invoking the pipeline directly (to be worked on in
+ T371008).
* …
=== Other changes in 1.44 ===
diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php
index f1e47627fd1..bc8032adbbc 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -2615,7 +2615,8 @@ class LocalFile extends File {
// Rendering failed.
return false;
}
- return $parseStatus->getValue()->getText();
+ // TODO T371004 move runOutputPipeline out of $parserOutput
+ return $parseStatus->getValue()->runOutputPipeline( $parserOptions, [] )->getContentHolderText();
}
/**
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index eeb1e2cac43..69f71f93c23 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -465,10 +465,9 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
* the default output pipeline on a ParserOutput; for now, use of
* ::runOutputPipeline() is preferred to ensure that ParserOptions are
* available.
- * Do NOT hard-deprecate this method until the corresponding patch
- * (1093952) is merged to CentralNotice wmf_deploy branch!
*/
public function getText( $options = [] ) {
+ wfDeprecated( __METHOD__, '1.42' );
$oldText = $this->mRawText; // T353257
$options += [ 'allowClone' => false ];
$po = $this->runPipelineInternal( null, $options );
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php
index fd561ebebb5..dc05e27badf 100644
--- a/tests/phpunit/includes/parser/ParserOutputTest.php
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -3,7 +3,6 @@
namespace MediaWiki\Tests\Parser;
use LogicException;
-use MediaWiki\Context\RequestContext;
use MediaWiki\Debug\MWDebug;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
@@ -18,7 +17,6 @@ use MediaWiki\Utils\MWTimestamp;
use MediaWikiLangTestCase;
use Wikimedia\Bcp47Code\Bcp47CodeValue;
use Wikimedia\Parsoid\Core\SectionMetadata;
-use Wikimedia\Parsoid\Core\TOCData;
use Wikimedia\TestingAccessWrapper;
use Wikimedia\Tests\SerializationTestTrait;
@@ -305,201 +303,6 @@ class ParserOutputTest extends MediaWikiLangTestCase {
$this->assertStringNotContainsString( 'class="', $text );
}
- /**
- * This test aims at being replaced by its version in DefaultOutputPipelineFactoryTest when
- * ParserOutput::getText gets deprecated.
- * @covers \MediaWiki\Parser\ParserOutput::getText
- * @dataProvider provideGetText
- * @param array $options Options to getText()
- * @param string $text Parser text
- * @param string $expect Expected output
- */
- public function testGetText( $options, $text, $expect ) {
- // Avoid other skins affecting the section edit links
- $this->overrideConfigValue( MainConfigNames::DefaultSkin, 'fallback' );
- RequestContext::resetMain();
-
- $this->overrideConfigValues( [
- MainConfigNames::ScriptPath => '/w',
- MainConfigNames::Script => '/w/index.php',
- ] );
-
- $po = new ParserOutput( $text );
- self::initSections( $po );
- $actual = $po->getText( $options );
- $this->assertSame( $expect, $actual );
- }
-
- private static function initSections( ParserOutput $po ): void {
- $po->setTOCData( new TOCData(
- SectionMetadata::fromLegacy( [
- 'index' => "1",
- 'level' => 1,
- 'toclevel' => 1,
- 'number' => "1",
- 'line' => "Section 1",
- 'anchor' => "Section_1"
- ] ),
- SectionMetadata::fromLegacy( [
- 'index' => "2",
- 'level' => 1,
- 'toclevel' => 1,
- 'number' => "2",
- 'line' => "Section 2",
- 'anchor' => "Section_2"
- ] ),
- SectionMetadata::fromLegacy( [
- 'index' => "3",
- 'level' => 2,
- 'toclevel' => 2,
- 'number' => "2.1",
- 'line' => "Section 2.1",
- 'anchor' => "Section_2.1"
- ] ),
- SectionMetadata::fromLegacy( [
- 'index' => "4",
- 'level' => 1,
- 'toclevel' => 1,
- 'number' => "3",
- 'line' => "Section 3",
- 'anchor' => "Section_3"
- ] ),
- ) );
- }
-
- public static function provideGetText() {
- $text = <<<EOF
-<p>Test document.
-</p>
-<meta property="mw:PageProp/toc" />
-<div class="mw-heading mw-heading2"><h2 id="Section_1">Section 1</h2><mw:editsection page="Test Page" section="1">Section 1</mw:editsection></div>
-<p>One
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_2">Section 2</h2><mw:editsection page="Test Page" section="2">Section 2</mw:editsection></div>
-<p>Two
-</p>
-<div class="mw-heading mw-heading3"><h3 id="Section_2.1">Section 2.1</h3></div>
-<p>Two point one
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_3">Section 3</h2><mw:editsection page="Test Page" section="4">Section 3</mw:editsection></div>
-<p>Three
-</p>
-EOF;
-
- $dedupText = <<<EOF
-<p>This is a test document.</p>
-<style data-mw-deduplicate="duplicate1">.Duplicate1 {}</style>
-<style data-mw-deduplicate="duplicate1">.Duplicate1 {}</style>
-<style data-mw-deduplicate="duplicate2">.Duplicate2 {}</style>
-<style data-mw-deduplicate="duplicate1">.Duplicate1 {}</style>
-<style data-mw-deduplicate="duplicate2">.Duplicate2 {}</style>
-<style data-mw-not-deduplicate="duplicate1">.Duplicate1 {}</style>
-<style data-mw-deduplicate="duplicate1">.Same-attribute-different-content {}</style>
-<style data-mw-deduplicate="duplicate3">.Duplicate1 {}</style>
-<style>.Duplicate1 {}</style>
-EOF;
-
- return [
- 'No options' => [
- [], $text, <<<EOF
-<p>Test document.
-</p>
-<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
-<ul>
-<li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a></li>
-<li class="toclevel-1 tocsection-2"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a>
-<ul>
-<li class="toclevel-2 tocsection-3"><a href="#Section_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Section 2.1</span></a></li>
-</ul>
-</li>
-<li class="toclevel-1 tocsection-4"><a href="#Section_3"><span class="tocnumber">3</span> <span class="toctext">Section 3</span></a></li>
-</ul>
-</div>
-
-<div class="mw-heading mw-heading2"><h2 id="Section_1">Section 1</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>One
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_2">Section 2</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>Two
-</p>
-<div class="mw-heading mw-heading3"><h3 id="Section_2.1">Section 2.1</h3></div>
-<p>Two point one
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_3">Section 3</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=4" title="Edit section: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>Three
-</p>
-EOF
- ],
- 'Disable section edit links' => [
- [ 'enableSectionEditLinks' => false ], $text, <<<EOF
-<p>Test document.
-</p>
-<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
-<ul>
-<li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a></li>
-<li class="toclevel-1 tocsection-2"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a>
-<ul>
-<li class="toclevel-2 tocsection-3"><a href="#Section_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Section 2.1</span></a></li>
-</ul>
-</li>
-<li class="toclevel-1 tocsection-4"><a href="#Section_3"><span class="tocnumber">3</span> <span class="toctext">Section 3</span></a></li>
-</ul>
-</div>
-
-<div class="mw-heading mw-heading2"><h2 id="Section_1">Section 1</h2></div>
-<p>One
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_2">Section 2</h2></div>
-<p>Two
-</p>
-<div class="mw-heading mw-heading3"><h3 id="Section_2.1">Section 2.1</h3></div>
-<p>Two point one
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_3">Section 3</h2></div>
-<p>Three
-</p>
-EOF
- ],
- 'Disable TOC, but wrap' => [
- [ 'allowTOC' => false, 'wrapperDivClass' => 'mw-parser-output' ], $text, <<<EOF
-<div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><p>Test document.
-</p>
-
-<div class="mw-heading mw-heading2"><h2 id="Section_1">Section 1</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>One
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_2">Section 2</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>Two
-</p>
-<div class="mw-heading mw-heading3"><h3 id="Section_2.1">Section 2.1</h3></div>
-<p>Two point one
-</p>
-<div class="mw-heading mw-heading2"><h2 id="Section_3">Section 3</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Test_Page&amp;action=edit&amp;section=4" title="Edit section: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></div>
-<p>Three
-</p></div>
-EOF
- ],
- 'Style deduplication' => [
- [], $dedupText, <<<EOF
-<p>This is a test document.</p>
-<style data-mw-deduplicate="duplicate1">.Duplicate1 {}</style>
-<link rel="mw-deduplicated-inline-style" href="mw-data:duplicate1" />
-<style data-mw-deduplicate="duplicate2">.Duplicate2 {}</style>
-<link rel="mw-deduplicated-inline-style" href="mw-data:duplicate1" />
-<link rel="mw-deduplicated-inline-style" href="mw-data:duplicate2" />
-<style data-mw-not-deduplicate="duplicate1">.Duplicate1 {}</style>
-<link rel="mw-deduplicated-inline-style" href="mw-data:duplicate1" />
-<style data-mw-deduplicate="duplicate3">.Duplicate1 {}</style>
-<style>.Duplicate1 {}</style>
-EOF
- ],
- 'Style deduplication disabled' => [
- [ 'deduplicateStyles' => false ], $dedupText, $dedupText
- ],
- ];
- // phpcs:enable
- }
-
/**
* @covers \MediaWiki\Parser\ParserOutput::hasText
*/
@@ -525,18 +328,6 @@ EOF
$this->assertFalse( $po->hasText() );
}
- /**
- * This test aims at being replaced by its version in DefaultOutputPipelineFactoryTest when
- * ParserOutput::getText gets deprecated.
- * @covers \MediaWiki\Parser\ParserOutput::getText
- */
- public function testGetText_failsIfNoText() {
- $po = new ParserOutput( null );
-
- $this->expectException( LogicException::class );
- $po->getText();
- }
-
/**
* @covers \MediaWiki\Parser\ParserOutput::getRawText
*/
diff --git a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewCurrentTest.php b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewCurrentTest.php
index a0fcd11504d..8e3732b62f6 100644
--- a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewCurrentTest.php
+++ b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewCurrentTest.php
@@ -121,7 +121,7 @@ class PoolWorkArticleViewCurrentTest extends PoolWorkArticleViewTest {
// The parser output cached but $work2 should now be also visible to $work1
$status1 = $work1->getCachedWork();
$this->assertInstanceOf( ParserOutput::class, $status1->getValue() );
- $this->assertSame( $status2->getValue()->getText(), $status1->getValue()->getText() );
+ $this->assertSame( $status2->getValue()->getRawText(), $status1->getValue()->getRawText() );
}
public function testFallbackFromOutdatedParserCache() {
diff --git a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
index be51c137d11..64397c11ba6 100644
--- a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
+++ b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
@@ -83,12 +83,12 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
$work = $this->newPoolWorkArticleView( $page, $rev1, $options );
/** @var Status $status */
$status = $work->execute();
- $this->assertStringContainsString( 'First', $status->getValue()->getText() );
+ $this->assertStringContainsString( 'First', $status->getValue()->getRawText() );
$work = $this->newPoolWorkArticleView( $page, $rev2, $options );
/** @var Status $status */
$status = $work->execute();
- $this->assertStringContainsString( 'Second', $status->getValue()->getText() );
+ $this->assertStringContainsString( 'Second', $status->getValue()->getRawText() );
}
public function testDoWorkParserCache() {
@@ -121,7 +121,7 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
/** @var Status $status */
$status = $work->execute();
- $text = $status->getValue()->getText();
+ $text = $status->getValue()->getRawText();
$this->assertStringContainsString( 'YES!', $text );
$this->assertStringNotContainsString( 'NOPE', $text );
}
@@ -179,7 +179,7 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
$expected = strval( $callback( $rev ) );
$output = $status->getValue();
- $this->assertStringContainsString( $expected, $output->getText() );
+ $this->assertStringContainsString( $expected, $output->getRawText() );
}
public function testDoWorkDeletedContent() {

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (22 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227707
Default Alt Text
(14 KB)

Event Timeline