From 5b40c74620cae9da879068d9912eade8f943e057 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Sun, 22 Jun 2014 07:50:10 -0400 Subject: [PATCH] Combine SpecialPageBeforeFormDisplay set of hooks into one Hooks with dynamically generated names cannot be documented in the normal manner, and indeed this set, added in r86482 / 10d93c34cb17, was not. In contrast, every other hook in core has a name that is a fixed string and thus is easy to grep for, create a manual page title for, and so on. Conceptually, each hook's name should correspond to one or more locations at which code can be inserted. So I changed the code to use hook name "SpecialPageBeforeFormDisplay" for all FormSpecialPages and added the special page name as a parameter, which is consistent with existing hook "ActionBeforeFormDisplay". From extensions in Gerrit, the only use I found was in StopForumSpam, which is updated to use the new hook in Id474915a. So I chose to break backward compatibility instead of using a hack to hide the old hooks from maintenance/findHooks.php. After three years, the script again reports, "Looks good!" Change-Id: I7ea6521b47fb034bc367a1d06d477a7654035a5f --- RELEASE-NOTES-1.24 | 3 +++ docs/hooks.txt | 4 ++++ includes/specialpage/FormSpecialPage.php | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 899d2118c4..7cc8b130f1 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -197,6 +197,9 @@ changes to languages because of Bugzilla reports. * Removed DatabaseMysqlBase::getLagFromProcesslist(). (deprecated since 1.19) * Removed LoadBalancer::closeConnecton(). (deprecated since 1.18) * Removed ApiBase::createContext(). (deprecated since 1.19) +* BREAKING CHANGE: The undocumented Special{$this->getName()}BeforeFormDisplay + set of hooks has been removed and replaced by a single new hook + SpecialPageBeforeFormDisplay. ==== Renamed classes ==== * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression diff --git a/docs/hooks.txt b/docs/hooks.txt index 82b418825c..1673f06543 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2354,6 +2354,10 @@ software. $software: The array of software in format 'name' => 'version'. See SpecialVersion::softwareInformation(). +'SpecialPageBeforeFormDisplay': Before executing the HTMLForm object. +$name: name of the special page +&$form: HTMLForm object + 'SpecialBlockModifyFormFields': Add more fields to Special:Block $sp: SpecialPage object, for context &$fields: Current HTMLForm fields diff --git a/includes/specialpage/FormSpecialPage.php b/includes/specialpage/FormSpecialPage.php index 60203961eb..1d8f57a221 100644 --- a/includes/specialpage/FormSpecialPage.php +++ b/includes/specialpage/FormSpecialPage.php @@ -106,7 +106,7 @@ abstract class FormSpecialPage extends SpecialPage { $this->alterForm( $form ); // Give hooks a chance to alter the form, adding extra fields or text etc - wfRunHooks( "Special{$this->getName()}BeforeFormDisplay", array( &$form ) ); + wfRunHooks( 'SpecialPageBeforeFormDisplay', array( $this->getName(), &$form ) ); return $form; } -- 2.20.1