Page MenuHomePhabricator

Deprecation warning on Special:Log/pagetranslation
Closed, ResolvedPublic


I was reviewing patch for T192908 and while trying to reproduce bug in question, I opened page translation log (Special:Log/pagetranslation), which revealed deprecation warning: "Use of Using $input in LogEventsListGetExtraInputs hook was deprecated in MediaWiki 1.32."

deprecation-warning.png (128×1 px, 49 KB)

I think this happens after rMW52c62c65cd7e: LogEventsListGetExtraInputs: Keep $input and add $formDescriptor was merged.
Since that patch, we have:

$extraInputsDescriptor = $this->getExtraInputsDesc( $types );
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' );

In the first snippet, we see getExtraInputsDesc being invoked. Here is that method:

private function getExtraInputsDesc( $types ) {
	if ( count( $types ) == 1 ) {
		if ( $types[0] == 'suppress' ) {
			$offender = $this->getRequest()->getVal( 'offender' );
			$user = User::newFromName( $offender, false );
			if ( !$user || ( $user->getId() == 0 && !IP::isIPAddress( $offender ) ) ) {
				$offender = ''; // Blank field if invalid
			return [
				'type' => 'text',
				'label-message' => 'revdelete-offender',
				'name' => 'offender',
				'value' => $offender,
		} 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, &$input, &$formDescriptor ] );

			return empty( $formDescriptor ) ? $input : $formDescriptor;

	return [];

getExtraInputsDesc was called with "pagetranslation" type. So, $types param has one value and first check passes. That type ain't "suppess", so we enter else branch. $input is set to empty string and $formDescriptor to empty array. Hook is run with those two passed by reference. If there is no subscriptions to that hook, those variables stay empty string and empty array, respectively. Method returns one of those vars, which turns out to be $input if there aren't modifications after hook ran.

We get back to first snippet. $extraInputsDescriptor has empty string after invoking getExtraInputsDesc. There is if condition that checks if $extraInputsDescriptor is array and since it isn't, we end up in elseif branch. That is where $extraInputsDescriptor is checked if it's string, and since it is empty string, we get the deprecation notice, which is wrong, because $input wasn't used with "LogEventsListGetExtraInputs" hook.

This would display same deprecation warning for any other type, different from "pagetranslation".

One more thing. "Use of Using $input in..." doesn't sound right. Remove word "Using".

Event Timeline

Change 450902 had a related patch set uploaded (by Prtksxna; owner: Prtksxna):
[mediawiki/core@master] LogEventsList: Stop showing deprecation warning when $input is empty

Umherirrender assigned this task to Prtksxna.

Change 450902 merged by jenkins-bot:
[mediawiki/core@master] LogEventsList: Stop showing deprecation warning when $input is empty