MaxSem has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/367633 )
Change subject: Don't call ParserOuptut::setTOCEnabled() ...................................................................... Don't call ParserOuptut::setTOCEnabled() It's not really needed. Add tests verifying that. Bug: T168040 Change-Id: I49cf58d92620ad53dd833bc8ce0d2443a00b48e4 --- M includes/ApiQueryExtracts.php M tests/phpunit/ExtractFormatterTest.php 2 files changed, 16 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts refs/changes/33/367633/1 diff --git a/includes/ApiQueryExtracts.php b/includes/ApiQueryExtracts.php index 38db171..e760db4 100644 --- a/includes/ApiQueryExtracts.php +++ b/includes/ApiQueryExtracts.php @@ -218,7 +218,6 @@ if ( $page->shouldCheckParserCache( $this->parserOptions, 0 ) ) { $pout = ParserCache::singleton()->get( $page, $this->parserOptions ); if ( $pout ) { - $pout->setTOCEnabled( false ); $text = $pout->getText(); if ( $this->params['intro'] ) { $text = $this->getFirstSection( $text, false ); diff --git a/tests/phpunit/ExtractFormatterTest.php b/tests/phpunit/ExtractFormatterTest.php index 4b53a99..b7bb25f 100644 --- a/tests/phpunit/ExtractFormatterTest.php +++ b/tests/phpunit/ExtractFormatterTest.php @@ -21,12 +21,16 @@ $fmt = new ExtractFormatter( $text, $plainText, $config ); $fmt->remove( '.metadata' ); // Will be added via $wgExtractsRemoveClasses on WMF $text = trim( $fmt->getText() ); + //$text = str_replace( "\1", '', str_replace( "\2", '', $text ) ); $this->assertEquals( $expected, $text ); } public function provideExtracts() { // @codingStandardsIgnoreStart $dutch = '<b>Dutch</b> (<span class="unicode haudio" style="white-space:nowrap;"><span class="fn"><a href="/wiki/File:Nl-Nederlands.ogg" title="About this sound"><img alt="About this sound" src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/11px-Loudspeaker.svg.png" width="11" height="11" srcset="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/17px-Loudspeaker.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/22px-Loudspeaker.svg.png 2x" /></a> <a href="https://upload.wikimedia.org/wikipedia/commons/d/db/Nl-Nederlands.ogg" class="internal" title="Nl-Nederlands.ogg"><i>Nederlands</i></a></span> <small class="metadata audiolinkinfo" style="cursor:help;">(<a href="/w/index.php?title=Wikipedia:Media_help&action=edit&redlink=1" class="new" title="Wikipedia:Media help (page does not exist)"><span style="cursor:help;">help</span></a>ยท<a href="/wiki/File:Nl-Nederlands.ogg" title="File:Nl-Nederlands.ogg"><span style="cursor:help;">info</span></a>)</small></span>) is a <a href="/w/index.php?title=West_Germanic_languages&action=edit&redlink=1" class="new" title="West Germanic languages (page does not exist)">West Germanic language</a> and the native language of most of the population of the <a href="/w/index.php?title=Netherlands&action=edit&redlink=1" class="new" title="Netherlands (page does not exist)">Netherlands</a>'; + $tocText = 'Lead<div id="toc" class="toc">TOC goes here</div> +<h1>Section</h1> +<p>Section text</p>'; // @codingStandardsIgnoreEnd return [ @@ -52,6 +56,18 @@ '<span class="foo"><span style="bar: baz;" lang="qux">quux</span></span>', false, ], + [ + // Verify that TOC is properly removed (HTML mode) + "Lead\n<h1>Section</h1>\n<p>Section text</p>", + $tocText, + false, + ], + [ + // Verify that TOC is properly removed (plain text mode) + "Lead\n\n\x01\x021\2\1Section\nSection text", + $tocText, + true, + ], ]; } -- To view, visit https://gerrit.wikimedia.org/r/367633 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49cf58d92620ad53dd833bc8ce0d2443a00b48e4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TextExtracts Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits