From d2631d1740687e48a28f7b52476d960562a7f25e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 20 Apr 2015 15:57:42 -0400 Subject: [PATCH] API: Set HTMLForm when validating field in ApiOptions Bug: T96583 Change-Id: I09507990827581b587c14b0f7283cdf0dc21436a --- includes/api/ApiOptions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index 8ef0629928..436f22aee5 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -75,11 +75,17 @@ class ApiOptions extends ApiBase { $prefs = Preferences::getPreferences( $user, $this->getContext() ); $prefsKinds = $user->getOptionKinds( $this->getContext(), $changes ); + $htmlForm = null; foreach ( $changes as $key => $value ) { switch ( $prefsKinds[$key] ) { case 'registered': // Regular option. + if ( $htmlForm === null ) { + // We need a dummy HTMLForm for the validate callback... + $htmlForm = new HTMLForm( array(), $this ); + } $field = HTMLForm::loadInputFromParameters( $key, $prefs[$key] ); + $field->mParent = $htmlForm; $validation = $field->validate( $value, $user->getOptions() ); break; case 'registered-multiselect': -- 2.20.1