Commit graph

16 commits

Author SHA1 Message Date
Bartosz Dziewoński
6f95c290c0 HTMLUserTextField: Fix validation
When 'exists' was false (the default), other validation was skipped.

Change the default 'iprangelimits' to allow any range, to avoid issues
with code that relied on the previous broken behavior.

Bug: T177329
Bug: T311948
Change-Id: I55cad7a5395da70105e20ce33e3a8e3834a4f4ad
2022-07-14 02:41:03 +02:00
Umherirrender
49ad716948 Use User::isRegistered for readability instead of ::getId falsy check
Change-Id: I42aab149559e3e899cde6c77af76c66936ed0ef0
2022-04-29 21:15:57 +02:00
Siddharth VP
061ee25f7e Fix typos in comments (E-H)
Change-Id: I0748e0d5962fa909fdd6b7fcae4ab259bde4cdf1
2021-12-30 18:14:43 +05:30
Thiemo Kreuz
fd7363a1e1 Fix broken PHPDoc comments that don't start with /**
Change-Id: I8db56ff0f73873864dde260e51adcd729aa74e94
2020-07-23 16:09:41 +00:00
Nikki Nikkhoui
6b0e9eafe1 HTML Classes stability annotations
Add stability annotations for HTML classes.

Bug: T247862
Change-Id: I4dad7b98213ceceb8c04b24e5d52e6fecadb3538
2020-07-13 14:54:28 +02:00
David Barratt
f0e3f9f84b
Fix HTMLUsersMultiselectField validation when exists is true
The HTMLUsersMultiselectField and HTMLUserTextField fail validation when an
empty string is passed to a non-required form field. To prevent this, the
widget should pass the validation to the parent when the value is an empty
string.

Bug: T246958
Change-Id: I39df2b575b90a4648188ed3ef4cc0c38ac553636
2020-03-20 13:15:53 -04:00
Kunal Mehta
99007e96c7 Use namespaced IPUtils class
Change-Id: I047e099a93203a59093946d336a143d899d0271f
2020-01-01 02:36:49 -08:00
jenkins-bot
31f66267ae Merge "HTMLTitleTextField: Remove incorrect check for unsubmitted GET forms" 2019-09-20 22:45:24 +00:00
Derick Alangi
f97a7a93d4 htmlform: Use ::isValidRange() instead of deprecated ::isValidBlock()
Only 1 usage of this call in everywhere, see usage below. Once this is merged,
the method can be hard deprecated and later killed.

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbisValidBlock%5Cb&i=nope&files=&repos=

Change-Id: Ic00f760a0a214faba7a71dd088da1dc25ecb796c
2019-05-09 16:36:05 +00:00
Bartosz Dziewoński
06c49e69dc 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
2018-07-18 01:35:45 +02:00
Prateek Saxena
500f7a5bad HTMLTitleTextField, HTMLUserTextField: Check for null before using the value
Otherwise HTMLTitleTextField sends null to Title::newFromTextThrow(),
which causes an exception when trying to look it up in a cache.

Similar issue is present in HTMLUserTextField, although that one
hasn't caused problems in practice yet.

Follows-up on I93ad51ffe7bee597d2d127f4c5d6b2929ffc8f7e and
I0de4194a37b6ef260d35feb1e6730985775d5351.

Bug: T199763
Change-Id: I29ecd94cdf9e3064e6e9e7f4e65a50f267b5282d
2018-07-18 00:42:52 +02:00
Florian
b73c0c4d3f Enable IP ranges in HTMLUserTextField
Like an existing user and a single IP, allow to use an IP range, too.

Bug: T107039
Change-Id: I9137f71f6119c68d787f508a3f57b476404315d8
2017-09-29 19:55:19 +02:00
Brad Jorsch
7fdbe15fb6 HTMLForm: Allow returning Message objects from HTMLFormField::validate()
It mostly already worked. HTMLForm::trySubmit() needed a little
adjustment to handle things properly.

Change-Id: Ibb17bb61ac0b2d41953249980bc2f23b8a3ae5b6
2016-11-14 13:25:14 -05:00
Bartosz Dziewoński
6a366c3300 HTMLForm: Refactor loading of modules required to infuse fields
Rather than have a master list in autoinfuse.js (duplicated in
hide-if.js), we put this information in each field class and put it
in the generated HTML as a separate 'data-' attribute. This also
allows new fields defined by extensions to be correctly autoinfused.

Change-Id: I3da75706209cbc16b19cc3f02b355e58ca75fec9
2016-08-22 17:35:35 +00:00
Bartosz Dziewoński
f50cee1375 Do not automatically infuse any OOjs UI widgets
This is not really what we had in mind when developing the infusion
feature and I think it's not helpful. Most of the time there is just
no benefit; a ButtonWidget generated in PHP and in JS behaves and
looks pretty much the same, and rebuilding it through infusion is a
small performance hit. If you're not adding any event handlers, it only
makes sense for various dropdowns, which have themed styling.

For the primary use case of adding JS behaviors to PHP widgets you
need to call OO.ui.infuse() anyway to get a reference to the JS
widget, and not infusing automatically should make it easier to reason
about your code. Infusion tries to be very transparent, but it can't
hide the fact that the DOM is re-built, making your references to DOM
nodes from before infusion useless and losing anything from PHP that
wasn't included in the config (e.g. custom attributes).

This commit removes automated infusion from mediawiki.page.ready
and adds some custom code in mediawiki.special.movePage and
mediawiki.htmlform. I see only two extensions using infusable OOjs UI
widgets in Gerrit (ArticlePlaceholder and ExtensionDistributor) and
neither should be affected by this change.

Change-Id: I56608c537fc57c5c54960b0603694f2612f45618
2016-08-19 03:29:31 +02:00
Bartosz Dziewoński
15692fa6d4 Move HTMLFormField subclasses to a separate directory
It's getting more difficult to navigate the files in includes/htmlform/
with every new field and every new helper class that is being added.

Change-Id: I92ce2356baf6151f17b2440970d5abdf86503820
2016-08-01 07:58:56 +00:00
Renamed from includes/htmlform/HTMLUserTextField.php (Browse further)