From f14fad35381572bf805dd0eea6668d35f8d7b9af Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Thu, 6 Feb 2020 19:51:52 +0000 Subject: [PATCH] Remove ArticleContentViewCustom hook, deprecated and unused Bug: T241351 Change-Id: Ie37ed9265511e3051ea60c6898febb567d5283df --- RELEASE-NOTES-1.35 | 3 +- docs/contenthandler.md | 2 +- docs/hooks.txt | 7 ---- includes/diff/DifferenceEngine.php | 5 --- includes/page/Article.php | 6 ---- .../phpunit/includes/page/ArticleViewTest.php | 36 ------------------- 6 files changed, 3 insertions(+), 56 deletions(-) diff --git a/RELEASE-NOTES-1.35 b/RELEASE-NOTES-1.35 index 0119aaf31ba..d52a92fa62c 100644 --- a/RELEASE-NOTES-1.35 +++ b/RELEASE-NOTES-1.35 @@ -290,7 +290,8 @@ because of Phabricator reports. have been removed without deprecation. * The support for old signature for ParserFactory::__construct was deprecated in 1.34 and now has been removed. -* SpecialRecentChanges::filterByCategories(), deprecated in 1.31, was removed +* SpecialRecentChanges::filterByCategories(), deprecated in 1.31, was removed. +* The `ArticleContentViewCustom` hook, deprecated in 1.32, was removed. * … === Deprecations in 1.35 === diff --git a/docs/contenthandler.md b/docs/contenthandler.md index 262389364ff..03f12cb9278 100644 --- a/docs/contenthandler.md +++ b/docs/contenthandler.md @@ -81,7 +81,7 @@ Besides some functions, some hooks have also been replaced by new versions (see * `ArticleInsertComplete` was replaced by `PageContentInsertComplete` * `ArticleSave` was replaced by `PageContentSave` * `ArticleSaveComplete` was replaced by `PageContentSaveComplete` -* `ArticleViewCustom` was replaced by `ArticleContentViewCustom` (also consider a custom implementation of the view action) +* `ArticleViewCustom` was replaced by `ArticleContentViewCustom`, which was later removed entirely * `EditFilterMerged` was replaced by `EditFilterMergedContent` * `EditPageGetDiffText` was replaced by `EditPageGetDiffContent` * `EditPageGetPreviewText` was replaced by `EditPageGetPreviewContent` diff --git a/docs/hooks.txt b/docs/hooks.txt index 7ee2a72047a..df4ea5d50c3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -606,13 +606,6 @@ $title: title of the page $oldid: the requested revision id, or 0 for the currrent revision. $output: a ParserOutput object -'ArticleContentViewCustom': DEPRECATED since 1.32, use ArticleRevisionViewCustom instead, -or provide an appropriate ContentHandler. Allows to output the text of the article in a -different format than wikitext. -$content: content of the page, as a Content object -$title: title of the page -$output: a ParserOutput object - 'ArticleDelete': Before an article is deleted. &$wikiPage: the WikiPage (object) being deleted &$user: the user (object) deleting the article diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 5468659aba9..961b2764962 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -942,11 +942,6 @@ class DifferenceEngine extends ContextSource { ) { // Handled by extension // NOTE: sync with hooks called in Article::view() - } elseif ( !Hooks::run( 'ArticleContentViewCustom', - [ $this->mNewContent, $this->mNewPage, $out ], '1.32' ) - ) { - // Handled by extension - // NOTE: sync with hooks called in Article::view() } else { // Normal page if ( $this->getTitle()->equals( $this->mNewPage ) ) { diff --git a/includes/page/Article.php b/includes/page/Article.php index 87575c6ff29..13b95535b4a 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -774,12 +774,6 @@ class Article implements Page { // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision() // Allow extensions do their own custom view for certain pages $outputDone = true; - } elseif ( !Hooks::run( 'ArticleContentViewCustom', - [ $this->fetchContentObject(), $this->getTitle(), $outputPage ], '1.32' ) - ) { - // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision() - // Allow extensions do their own custom view for certain pages - $outputDone = true; } break; case 4: diff --git a/tests/phpunit/includes/page/ArticleViewTest.php b/tests/phpunit/includes/page/ArticleViewTest.php index d2c5144a479..5a12c92086a 100644 --- a/tests/phpunit/includes/page/ArticleViewTest.php +++ b/tests/phpunit/includes/page/ArticleViewTest.php @@ -435,42 +435,6 @@ class ArticleViewTest extends MediaWikiTestCase { $this->assertSame( 'Hook Title', $output->getPageTitle() ); } - public function testArticleContentViewCustomHook() { - $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] ); - - $article = new Article( $page->getTitle(), 0 ); - $article->getContext()->getOutput()->setTitle( $page->getTitle() ); - - // use ArticleViewHeader hook to bypass the parser cache - $this->setTemporaryHook( - 'ArticleViewHeader', - function ( Article $articlePage, &$outputDone, &$useParserCache ) use ( $article ) { - $useParserCache = false; - } - ); - - $this->setTemporaryHook( - 'ArticleContentViewCustom', - function ( Content $content, Title $title, OutputPage $output ) use ( $page ) { - $this->assertSame( $page->getTitle(), $title, '$title' ); - $this->assertSame( 'Test A', $content->getText(), '$content' ); - - $output->addHTML( 'Hook Text' ); - return false; - } - ); - - $this->hideDeprecated( - 'ArticleContentViewCustom hook (used in hook-ArticleContentViewCustom-closure)' - ); - - $article->view(); - - $output = $article->getContext()->getOutput(); - $this->assertStringNotContainsString( 'Test A', $this->getHtml( $output ) ); - $this->assertStringContainsString( 'Hook Text', $this->getHtml( $output ) ); - } - public function testArticleRevisionViewCustomHook() { $page = $this->getPage( __METHOD__, [ 1 => 'Test A' ] );