Page MenuHomePhabricator

Exception: HTMLAutoCompleteSelectField called without any autocompletions
Closed, ResolvedPublic

Description

On single wikis with no CentralAuth, Special:OAuthConsumerRegistration/propose throws an exception.

This has been happening for a while, since I8f2fb3aea1d628fb31464f9245c2f3aa5ad195d2.

Special:OAuthConsumerRegistration sets

'autocomplete' => array_flip( MWOAuthUtils::getAllWikiNames() ),

for the wiki field. But on single wikis, MWOAuthUtils::getAllWikiNames() returns a zero-length array, so when HTMLAutoCompleteSelectField checks if !$this->autocomplete is true, it throws the exception.

Brad, is there a way to have no autocomplete values in HTMLAutoCompleteSelectField?


Version: unspecified
Severity: normal

Details

Reference
bz73163

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:58 AM
bzimport set Reference to bz73163.
bzimport added a subscriber: Unknown Object (MLST).

At a quick glance, just an empty array should work...

		if ( array_key_exists( 'autocomplete-messages', $this->mParams ) ) {
			foreach ( $this->mParams['autocomplete-messages'] as $key => $value ) {
				$key = $this->msg( $key )->plain();
				$this->autocomplete[$key] = strval( $value );
			}
		} elseif ( array_key_exists( 'autocomplete', $this->mParams ) ) {
			foreach ( $this->mParams['autocomplete'] as $key => $value ) {
				$this->autocomplete[$key] = strval( $value );
			}
		}
		if ( !is_array( $this->autocomplete ) || !$this->autocomplete ) {
			throw new MWException( 'HTMLAutoCompleteSelectField called without any autocompletions' );
		}

MWOAuthUtils::getAllWikiNames() always returns an array (even if empty)...

gerritadmin wrote:

Change 172279 had a related patch set uploaded by Anomie:
Don't offer "specific project" on Special:OAuthConsumerRegistration/propose when no other projects are available

https://gerrit.wikimedia.org/r/172279

(In reply to Sam Reed (reedy) from comment #1)

At a quick glance, just an empty array should work...

You missed that an empty array is specifically rejected:

		if ( !is_array( $this->autocomplete ) || !$this->autocomplete ) {
			throw new MWException( 'HTMLAutoCompleteSelectField called without any

autocompletions' );

		}

"!$this->autocomplete" is true if it's an empty array.

Since there's no point in offering an 'other' text field when nothing is valid as input (besides maybe duplicating the value of one of the options in the dropdown), let's just skip it altogether in that situation.

gerritadmin wrote:

Change 172279 merged by jenkins-bot:
Don't offer "specific project" on Special:OAuthConsumerRegistration/propose when no other projects are available

https://gerrit.wikimedia.org/r/172279