From: Bartosz Dziewoński Date: Tue, 17 Jul 2018 23:35:45 +0000 (+0200) Subject: HTMLTitleTextField: Remove incorrect check for unsubmitted GET forms X-Git-Tag: 1.34.0-rc.0~131^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/%7B%24admin_url%7Dmembres/cotisations/%22%20.%20generer_url_ecrire%28%29%20.%20%22?a=commitdiff_plain;h=06c49e69dc0331f28dce61df2fc8d8fd59fb8e3c;p=lhc%2Fweb%2Fwiklou.git HTMLTitleTextField: Remove incorrect check for unsubmitted GET forms This check was added in I605f32048fe97eebd7e04b6ffd799759aeb7f31e, to fix an issue on Special:ChangeContentModel that was pointed out in code review of I766da59e6cbf7ed8f887d1a684ea9e284e9cf67e. This code actually does nothing in most cases, because `$value` for unsubmitted forms comes from the getDefault() method, and it is `null` and not `''`, unless specifically overridden. As it happens, Special:ChangeContentModel overrides the default to `''`, so this worked there. However, this was a brittle hack, and another change recently broke Special:ChangeContentModel in the exact way this was supposed to avoid: T196514. There is a pending patch there to fix it properly. The proper way to avoid validation errors on initial view of a GET form is to call setFormIdentifier( … ) on the form, which allows HTMLForm code to detect whether the form was really submitted. Change-Id: Id6a449bfa313d470ae4c39455e58b36252dc6b43 --- diff --git a/includes/htmlform/fields/HTMLTitleTextField.php b/includes/htmlform/fields/HTMLTitleTextField.php index 0ad41d43bd..b76684dfe5 100644 --- a/includes/htmlform/fields/HTMLTitleTextField.php +++ b/includes/htmlform/fields/HTMLTitleTextField.php @@ -7,9 +7,6 @@ use MediaWiki\Widget\TitleInputWidget; * Automatically does validation that the title is valid, * as well as autocompletion if using the OOUI display format. * - * Note: Forms using GET requests will need to make sure the title value is not - * an empty string. - * * Optional parameters: * 'namespace' - Namespace the page must be in * 'relative' - If true and 'namespace' given, strip/add the namespace from/to the title as needed @@ -33,14 +30,6 @@ class HTMLTitleTextField extends HTMLTextField { } public function validate( $value, $alldata ) { - if ( $this->mParent->getMethod() === 'get' && $value === '' ) { - // If the form is a GET form and has no value, assume it hasn't been - // submitted yet, and skip validation - // TODO This doesn't look right, we should be able to tell the difference - // between "not submitted" (null) and "submitted but empty" (empty string). - return parent::validate( $value, $alldata ); - } - // Default value (from getDefault()) is null, which breaks Title::newFromTextThrow() below if ( $value === null ) { $value = ''; diff --git a/includes/htmlform/fields/HTMLUserTextField.php b/includes/htmlform/fields/HTMLUserTextField.php index d6723144f5..ccf0d12df7 100644 --- a/includes/htmlform/fields/HTMLUserTextField.php +++ b/includes/htmlform/fields/HTMLUserTextField.php @@ -6,8 +6,6 @@ use MediaWiki\Widget\UserInputWidget; * Implements a text input field for user names. * Automatically auto-completes if using the OOUI display format. * - * FIXME: Does not work for forms that support GET requests. - * * Optional parameters: * 'exists' - Whether to validate that the user already exists * 'ipallowed' - Whether an IP adress is interpreted as "valid"