Preferences: Add autocomplete="off" to preferences form
This change adds a new method setAutocomplete to the class HTMLForm. This method allows to set the HTML attribute autocomplete for the form. This change uses this method to set autocomplete="off" for the preferences form. Without autocomplete="off" the selections in the preferences get cached in the browser. This can lead to wrong selected options when the settings get changed on an other way, for example via API. Bug: T131047 Change-Id: I2920383b5b8cfca3f1d546315f202985edf417d8
This commit is contained in:
parent
00878f6f73
commit
7489a3e8f1
2 changed files with 27 additions and 0 deletions
|
|
@ -1301,6 +1301,7 @@ class Preferences {
|
||||||
|
|
||||||
$htmlForm->setModifiedUser( $user );
|
$htmlForm->setModifiedUser( $user );
|
||||||
$htmlForm->setId( 'mw-prefs-form' );
|
$htmlForm->setId( 'mw-prefs-form' );
|
||||||
|
$htmlForm->setAutocomplete( 'off' );
|
||||||
$htmlForm->setSubmitText( $context->msg( 'saveprefs' )->text() );
|
$htmlForm->setSubmitText( $context->msg( 'saveprefs' )->text() );
|
||||||
# Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
|
# Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
|
||||||
$htmlForm->setSubmitTooltip( 'preferences-save' );
|
$htmlForm->setSubmitTooltip( 'preferences-save' );
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,13 @@ class HTMLForm extends ContextSource {
|
||||||
*/
|
*/
|
||||||
protected $mAction = false;
|
protected $mAction = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form attribute autocomplete. false does not set the attribute
|
||||||
|
* @since 1.27
|
||||||
|
* @var bool|string
|
||||||
|
*/
|
||||||
|
protected $mAutocomplete = false;
|
||||||
|
|
||||||
protected $mUseMultipart = false;
|
protected $mUseMultipart = false;
|
||||||
protected $mHiddenFields = [];
|
protected $mHiddenFields = [];
|
||||||
protected $mButtons = [];
|
protected $mButtons = [];
|
||||||
|
|
@ -996,6 +1003,9 @@ class HTMLForm extends ContextSource {
|
||||||
if ( !empty( $this->mId ) ) {
|
if ( !empty( $this->mId ) ) {
|
||||||
$attribs['id'] = $this->mId;
|
$attribs['id'] = $this->mId;
|
||||||
}
|
}
|
||||||
|
if ( !empty( $this->mAutocomplete ) ) {
|
||||||
|
$attribs['autocomplete'] = $this->mAutocomplete;
|
||||||
|
}
|
||||||
return $attribs;
|
return $attribs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1677,4 +1687,20 @@ class HTMLForm extends ContextSource {
|
||||||
|
|
||||||
return $this->getTitle()->getLocalURL();
|
return $this->getTitle()->getLocalURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value for the autocomplete attribute of the form.
|
||||||
|
* When set to false (which is the default state), the attribute get not set.
|
||||||
|
*
|
||||||
|
* @since 1.27
|
||||||
|
*
|
||||||
|
* @param string|bool $autocomplete
|
||||||
|
*
|
||||||
|
* @return HTMLForm $this for chaining calls
|
||||||
|
*/
|
||||||
|
public function setAutocomplete( $autocomplete ) {
|
||||||
|
$this->mAutocomplete = $autocomplete;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue