Page MenuHomePhabricator

Impossible to create owner-only consumer
Closed, ResolvedPublic

Description

It's impossible to create owner-only consumer at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose right now. Any attempt results in an error: Missing value for "callbackUrl" field. The "callbackUrl" field is hidden when the owner-only checkbox is checked, and should therefore not be required.

This might be my fault from the HTMLForm hide-if tweaks I've been doing recently :(

Event Timeline

The error comes from MWOAuthSubmitControl::validateFields():

	protected function validateFields( array $required ) {
		foreach ( $required as $field => $validator ) {
			if ( !isset( $this->vals[$field] ) ) {
				// @TODO: check for field-specific message first
				return $this->failure( "missing_field_$field", 'mwoauth-missing-field', $field );
		
	}

	public function submit() {
		
		$required = $this->getRequiredFields();
		
		$status = $this->validateFields( $required[$action] );
		if ( !$status->isOK() ) {
			return $status;
		}
		
	}

HTMLForm will currently not submit fields which were hidden with hide-if (and therefore are supposed to be ignored), as they get disabled='disabled' set by the JavaScript code.

I'm not sure if this check is necessary at all? The presence of required fields should be checked by HTMLForm code later, and that accounts for hide-if rules.

Change 332133 had a related patch set uploaded (by Bartosz Dziewoński):
Unbreak creation of owner-only consumers

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

I am not sure if this is the right fix. It seems to work fine, and I think it makes sense, but I'm not familiar with this code. And there might be other fields affected in a similar way; this only fixes this particular instance. But I'm about to board a plane and I can't look into this further right now.

Change 332133 merged by jenkins-bot:
Unbreak creation of owner-only consumers

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

Tgr assigned this task to matmarex.

This change will be deployed to Meta-Wiki this Wednesday, 18 January, per https://www.mediawiki.org/wiki/MediaWiki_1.29/Roadmap.