From dee0d1ce4e428bd6863466f43f08a9bf00b4fef2 Mon Sep 17 00:00:00 2001 From: Reedy Date: Wed, 5 Oct 2016 01:20:08 +0100 Subject: [PATCH] Mark 3 hooks deprecated by ContentHandler as such ArticleViewCustom, EditPageGetDiffText and EditPageGetPreviewText hooks now marked as deprecated in 1.21. TitleIsCssOrJsPage and TitleIsWikitextPage deprecation version dropped from 1.25 to 1.21 to match other hooks. Bug: T145728 Bug: T147382 Bug: T147383 Bug: T147384 Bug: T147385 Bug: T147386 Change-Id: I59b6b9f253857eb1040dad879a71e0d8cf141553 --- RELEASE-NOTES-1.28 | 2 ++ includes/EditPage.php | 4 ++-- includes/content/ContentHandler.php | 4 ++-- includes/diff/DifferenceEngine.php | 6 +++++- includes/page/Article.php | 8 +++++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28 index 27e02a53fc..1ece2a4284 100644 --- a/RELEASE-NOTES-1.28 +++ b/RELEASE-NOTES-1.28 @@ -214,6 +214,8 @@ changes to languages because of Phabricator reports. * IP::isConfiguredProxy() and IP::isTrustedProxy() were removed. Callers should migrate to using the same functions on a ProxyLookup instance, obtainable from MediaWikiServices. +* The ArticleViewCustom, EditPageGetDiffText and EditPageGetPreviewText hooks will + now emit deprecation warnings if used. == Compatibility == diff --git a/includes/EditPage.php b/includes/EditPage.php index c0c0048db8..c1ba3cef8f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3416,7 +3416,7 @@ HTML } if ( $newContent ) { - ContentHandler::runLegacyHooks( 'EditPageGetDiffText', [ $this, &$newContent ] ); + ContentHandler::runLegacyHooks( 'EditPageGetDiffText', [ $this, &$newContent ], '1.21' ); Hooks::run( 'EditPageGetDiffContent', [ $this, &$newContent ] ); $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); @@ -3829,7 +3829,7 @@ HTML } $hook_args = [ $this, &$content ]; - ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args ); + ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args, '1.25' ); Hooks::run( 'EditPageGetPreviewContent', $hook_args ); $parserResult = $this->doPreviewParse( $content ); diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index d709c5c931..5755918046 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -243,7 +243,7 @@ abstract class ContentHandler { } // Hook can force JS/CSS - Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.25' ); + Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.21' ); // Is this a user subpage containing code? $isCodeSubpage = NS_USER == $ns @@ -258,7 +258,7 @@ abstract class ContentHandler { $isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage; // Hook can override $isWikitext - Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.25' ); + Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.21' ); if ( !$isWikitext ) { switch ( $ext ) { diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 1537535495..f27db07916 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -620,7 +620,11 @@ class DifferenceEngine extends ContextSource { } } elseif ( !Hooks::run( 'ArticleContentViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) { // Handled by extension - } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) { + } elseif ( !ContentHandler::runLegacyHooks( + 'ArticleViewCustom', + [ $this->mNewContent, $this->mNewPage, $out ], + '1.21' + ) ) { // NOTE: deprecated hook, B/C only // Handled by extension } else { diff --git a/includes/page/Article.php b/includes/page/Article.php index 338b1aeb89..022dd9478e 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -623,9 +623,11 @@ class Article implements Page { # Allow extensions do their own custom view for certain pages $outputDone = true; - } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', - [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) { - + } elseif ( !ContentHandler::runLegacyHooks( + 'ArticleViewCustom', + [ $this->fetchContentObject(), $this->getTitle(), $outputPage ], + '1.21' + ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; } -- 2.20.1