From 52c62c65cd7eec360b926fa1a1cbea0486fe0cf5 Mon Sep 17 00:00:00 2001 From: Prateek Saxena Date: Fri, 13 Jul 2018 07:32:13 +0530 Subject: [PATCH] LogEventsListGetExtraInputs: Keep $input and add $formDescriptor Follows-up on Iba3c6aa5ac40dcdee0792c2d045b238b02d76521. Bug: T117737 Bug: T199495 Change-Id: I697e158887fcca1da88763a4c929a981d9211490 --- RELEASE-NOTES-1.32 | 4 ++-- docs/hooks.txt | 1 + includes/logging/LogEventsList.php | 30 ++++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 5110e5190d..db2a98be5e 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -186,8 +186,6 @@ because of Phabricator reports. CapsuleMultiselectWidget. The following methods may no longer be used: * setItemsFromData: Use setValue instead * getItemsData: Use getItems instead and get the data property -* The hook 'LogEventsListGetExtraInputs' now needs a form descriptor array - and not plain HTML. * LanguageCode::bcp47() now always returns a valid BCP 47 code. This means that some MediaWiki-specific language codes, such as `simple`, are mapped into valid BCP 47 codes (eg `en-simple`). @@ -261,6 +259,8 @@ because of Phabricator reports. * (T100681) Use of the Parsoid v1 API with the VirtualRESTService, deprecated in MediaWiki 1.26, is now hard-deprecated. All known clients were converted to the Parsoid v3 API in May 2015. +* $input is deprecated in hook 'LogEventsListGetExtraInputs'. Use + $formDescriptor instead. === Other changes in 1.32 === * (T198811) The following tables have had their UNIQUE indexes turned into diff --git a/docs/hooks.txt b/docs/hooks.txt index c7874c33af..2d1e2a762d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2187,6 +2187,7 @@ $autocreated: Boolean, whether this was an auto-creation Special:Log for a specific log type $type: String of log type being displayed $logEventsList: LogEventsList object for context and access to the WebRequest +&$input: string HTML of an input element (deprecated, use $formDescriptor instead) &$formDescriptor: array HTMLForm's form descriptor 'LogEventsListShowLogExtract': Called before the string is added to OutputPage. diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index fdcaa1b43f..a7620fedd6 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -123,9 +123,19 @@ class LogEventsList extends ContextSource { $formDescriptor['page'] = $this->getTitleInputDesc( $title ); // Add extra inputs if any + // This could either be a form descriptor array or a string with raw HTML. + // We need it to work in both cases and show a deprecation warning if it + // is a string. See T199495. $extraInputsDescriptor = $this->getExtraInputsDesc( $types ); - if ( !empty( $extraInputsDescriptor ) ) { + if ( + is_array( $extraInputsDescriptor ) && + !empty( $extraInputsDescriptor ) + ) { $formDescriptor[ 'extra' ] = $extraInputsDescriptor; + } elseif ( is_string( $extraInputsDescriptor ) ) { + // We'll add this to the footer of the form later + $extraInputsString = $extraInputsDescriptor; + wfDeprecated( 'Using $input in LogEventsListGetExtraInputs hook', '1.32' ); } // Title pattern, if allowed @@ -165,6 +175,15 @@ class LogEventsList extends ContextSource { ->setSubmitText( $this->msg( 'logeventslist-submit' )->text() ) ->setWrapperLegendMsg( 'log' ); + // TODO This will should be removed at some point. See T199495. + if ( isset( $extraInputsString ) ) { + $htmlForm->addFooterText( Html::rawElement( + 'div', + null, + $extraInputsString + ) ); + } + $htmlForm->prepareForm()->displayForm( false ); } @@ -279,7 +298,7 @@ class LogEventsList extends ContextSource { /** * @param array $types - * @return array Form descriptor + * @return array|string Form descriptor or string with HTML */ private function getExtraInputsDesc( $types ) { if ( count( $types ) == 1 ) { @@ -297,9 +316,12 @@ class LogEventsList extends ContextSource { ]; } else { // Allow extensions to add their own extra inputs + // This could be an array or string. See T199495. + $input = ''; // Deprecated $formDescriptor = []; - Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$formDescriptor ] ); - return $formDescriptor; + Hooks::run( 'LogEventsListGetExtraInputs', [ $types[0], $this, &$input, &$formDescriptor ] ); + + return empty( $formDescriptor ) ? $input : $formDescriptor; } } -- 2.20.1