r55435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55434‎ | r55435 | r55436 >
Date:21:06, 21 August 2009
Author:simetrical
Status:ok
Tags:
Comment:
Only require necessary fields in Special:ResetPass

This fixes r54567. That made the password fields on Special:ResetPass
always required, but in fact the current password should never be
required (existing users always might have empty passwords), and the new
password is only required if $wgMinimalPasswordLength > 0.

This commit also permits passing array( 'required' ) to
Html::(rawE|e)lement() instead of array( 'required' => 'meaningless' ),
for boolean attribs only. This syntax is used in SpecialResetpass.
Modified paths:
  • /trunk/phase3/includes/Html.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialResetpass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Html.php
@@ -195,6 +195,17 @@
196196
197197 $ret = '';
198198 foreach ( $attribs as $key => $value ) {
 199+ # For boolean attributes, support array( 'foo' ) instead of
 200+ # requiring array( 'foo' => 'meaningless' ).
 201+ if ( is_int( $key )
 202+ && in_array( strtolower( $value ), self::$boolAttribs ) ) {
 203+ $key = $value;
 204+ }
 205+
 206+ # Not technically required in HTML 5, but required in XHTML 1.0,
 207+ # and we'd like consistency and better compression anyway.
 208+ $key = strtolower( $key );
 209+
199210 # See the "Attributes" section in the HTML syntax part of HTML 5,
200211 # 9.1.2.3 as of 2009-08-10. Most attributes can have quotation
201212 # marks omitted, but not all. (Although a literal " is not
Index: trunk/phase3/includes/specials/SpecialResetpass.php
@@ -128,6 +128,8 @@
129129 }
130130
131131 function pretty( $fields ) {
 132+ global $wgMinimalPasswordLength;
 133+
132134 $out = '';
133135 foreach ( $fields as $list ) {
134136 list( $name, $label, $type, $value ) = $list;
@@ -135,11 +137,17 @@
136138 $field = htmlspecialchars( $value );
137139 } else {
138140 $attribs = array( 'id' => $name );
139 - # All three fields are required, and we should focus the first
140 - # (wpPassword)
141 - $attribs['required'] = '';
 141+ # The current password field is never required; it's possible
 142+ # that existing users might have empty passwords on any wiki.
 143+ # The two other password fields are required if
 144+ # $wgMinimalPasswordLength > 0 (not allowed to set an empty
 145+ # password).
 146+ if ( ( $name == 'wpNewPassword' || $name == 'wpRetype' )
 147+ && $wgMinimalPasswordLength > 0 ) {
 148+ $attribs[] = 'required';
 149+ }
142150 if ( $name == 'wpPassword' ) {
143 - $attribs['autofocus'] = '';
 151+ $attribs[] = 'autofocus';
144152 }
145153 $field = Html::input( $name, $value, $type, $attribs );
146154 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54567Start using some HTML 5 form features...simetrical03:32, 7 August 2009

Status & tagging log