Commit graph

578 commits

Author SHA1 Message Date
Vlad.shapik
9763c48d17 Reapply "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName""
This reverts commit ecf826a2ee.

Reason for revert: need to edit the patch and then it will be GTG in order to finish hard deprecating of User ::getCanonicalName, ::isUsableName, ::isCreatableName

Change-Id: I2f57f56728fcbeada96dc2228f07dc8bcaa5d4f6
2021-05-31 16:01:36 +03:00
Umherirrender
1121757ed7 Allow html form field option 'options-messages' to get parsed
The message keys by 'options-messages' are evaluated with
Message::plain(), but some situation needs Message::parse() to support
templates and HTML formatting in this values.

Bug: T58633
Change-Id: I8f52f21ae2641ddcad1aa85ce6bf14de1a09ab4b
2021-05-28 21:55:09 +02:00
wikitrent
04c94272d6 Make CollapsibleFieldsetLayout more reusable
Refactor CollapsibleFieldsetLayout to work when not wrapped in
mw-htmlform-ooui-wrapper.

Bug: T278935
Change-Id: I89c17671de1c1c8b5897a75ad292c576a1e1bbb1
2021-05-27 09:12:13 -05:00
Martin Urbanec
10c539ce32 HTMLTitleTextField: Support interwiki titles
Some forms (namely Special:EditGrowthConfig) need to make sure
title exists if possible, but also need to support interwiki
titles.

Bug: T279886
Change-Id: I1bed0aa90dab8c872e915148923a5d78c9dee2f3
2021-05-24 19:05:41 +00:00
daniel
39a6e11310 HTMLForm: accept PageReference instead of Title.
Note that this changes the effective type of the protected mCancelTarget
field. This fields has no declared type, and does not seem to be used in
any subclass. The type of mTitle is not changed at this time, but
nothing seems to rely on that either.

Bug: T278459
Change-Id: I4bf0d46c74b53ffc9cb3e6e497c789ef6b3bab6a
2021-05-07 23:36:49 +02:00
Ppchelko
ecf826a2ee Revert "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName"
This reverts commit b491279268.

Reason for revert: caused CentralAuth tests to fail.

Change-Id: Icb3ed094578df427622e0da2a7462645adcc3d6f
2021-05-05 02:14:47 +00:00
vladshapik
b491279268 Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName
Bug: T275030
Change-Id: I60689ee6519c2dbd6d000afa8ac05c3e6b7895d2
2021-05-04 21:20:50 +03:00
Martin Urbanec
cad5a10681 [docs] Note that namespace ID is to be used in HTMLTitleTextField's namespace param
Change-Id: Ic529180307389e894de10909803e470bb452b6bb
2021-05-03 17:23:01 +02:00
Umherirrender
cf541752e0 Add comment to fall-through cases in switch
Fix new coming sniff
PSR2.ControlStructures.SwitchDeclaration.TerminatingComment

Bug: T182546
Change-Id: I3f8d43c730981d8faaa72910d7f3b58a14a8372f
2021-04-15 17:31:12 +00:00
Umherirrender
78cc6d77ff build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I09a6175917090593e6e0055203a890c32bea03a5
2021-04-04 21:18:22 +02:00
jenkins-bot
ad9661c4b8 Merge "Add HTMLTagMultiselectField" 2021-03-26 16:37:37 +00:00
STran
ee93d068d2 Add HTMLTagMultiselectField
Implements HTMLTagMultiselectField, a form field that instantiates
TagMultiselectWidget, the PHP representation of the OOUI's js-based
widget of the same name with the implemented parameters:
* allowArbitrary
* allowedValues

Bug: T278317
Change-Id: I3a6a30506d493be4185f917c577b3837fffd8ae1
2021-03-26 08:15:38 -07:00
tsepothoabala
4646731af6 De-duplicate equivalent IP ranges in HTMLUsersMultiselectField
Bug: T278338
Change-Id: I6143aecec51777e46ab9a8e80fd794c6433abe7c
2021-03-26 11:08:28 +02:00
jenkins-bot
aa3da2101c Merge "HTMLFormField: Use non namespaced class name rather than static::class" 2021-03-23 21:36:43 +00:00
Reedy
5bb8d031c0 HTMLFormField: Use non namespaced class name rather than static::class
Bug: T277414
Change-Id: I9ba76522932147df098abef48b2a076c2aa81aac
2021-03-19 18:19:20 +00:00
tsepothoabala
e29a8f150d Normalise IP addresses in HTMLUsersMultiselectField
Normalise IP addresses in HTMLUsersMultiselectField, to avoid adding multiple equivalent IP addresses

Bug: T275394
Change-Id: I3cbc26cb7c98ddc94bc3effc6bd2ab7108e970f8
2021-03-17 15:37:27 +02:00
Volker E
38ec1cb0de OOUIHTMLForm: Remove IE8 fallback code
Bug: T258766
Change-Id: I86ff63ebd2412fdfaa7e85d91dc1eb4eb8033e67
2021-02-24 15:33:11 -08:00
Thalia
505433c502 HTMLUsersMultiselectField: Keep IP addresses while normalizing
Fixes a bug introduced in c12af6e168
where invalid usernames are normalized out.

Nonexistent usernames will still fail the validation step, including
IP addresses if the field has been set up not to accept them.

Bug: T274568
Change-Id: I229afdfff2144fd4db8d49825262010f58f1fe54
2021-02-22 14:00:06 +00:00
Bartosz Dziewoński
58087fb737 HTMLMultiSelectField: Reject nested arrays early
Users can pass multidimensional arrays in query parameters to PHP
(e.g. ?foo[a][b]=bar). While filterDataForSubmit() ensured that anyone
using HTMLMultiSelectField in their form did not see them, internal
code here did not handle them correctly when validating the values and
generating the inputs, resulting in warnings deep in other code.

Use is_scalar instead of is_string in case default values somewhere
are integers or other non-string types.

Bug: T274955
Change-Id: I072a722ed025d687bfe755261a9896457f68f2ef
2021-02-19 00:24:38 +01:00
STran
c12af6e168 Normalize and de-dupe usernames in HTMLUsersMultiselectField
In no-js, there is no on the fly normalization of usernames in
HTMLUsersMultiselectField so both "User A" and "User_A" are
valid representations of "User A" (the canonical representation).

It's also possible to add the same user multiple times with no-js
and this will be considered valid and count toward the max limit.

These are not problems with js enabled since there will be an api
call for every new entry and that call both filters for selected users
and only returns canonical names.

This patchset reproduces that functionality in the PHP layer so that
no-js functions like the infused widget.

Bug: T274568
Change-Id: Ie78c8f37fa8a38b67eeaa6de098e41df2dac3e3e
2021-02-16 14:37:23 -08:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Thiemo Kreuz
947a8cfc00 Use ?? instead of isset/array_key_exists where possible
This patch touches all uncontroversial (I hope) places where a chain
of isset(), array_key_exist() and the ternary ?: operator can be
replaced with the much shorter ?? feature from PHP 7.

?? does the same. It checks if the element before the ?? is set and
not null. When this check fails, the element after the ?? is used.

Change-Id: Id612e2782ae928164b26b6f0de676c6c7d8302f3
2021-02-10 20:32:25 +01:00
STran
55ef87aa9c Pass along the disabled/readonly attributes to HTMLDateTimeField
Bug: T273335
Change-Id: I57fca9666cc013fd8fa2b64f09218da8e7e950c6
2021-02-02 07:24:01 -08:00
STran
a7d20495e9 Pass along the disabled parameter to HTMLFormFieldCloner
If the disabled parameter is set, the create/delete buttons
should be disabled by default. If a delete button is passed
along, then it overwrites the default delete button and therefore
needs to manage its own disabled/enabled state

Bug: T273431
Change-Id: Ia424466d26b6f65f01b912c2d556d329eb93f29a
2021-02-01 03:44:46 -08:00
Thalia
420001adce HTMLForm: Fix documentation for tryAuthorizedSubmit
This can return any value returned by trySubmit.

Change-Id: Iaf6a69e44984585337c76f329ac491b2e69fe744
2021-01-22 21:41:22 +00:00
Thalia
d8356d741c HTMLFileField: Make 'accept' parameter optional
Change-Id: I55321f90fad832d22661628334d2d254780e07da
2021-01-22 16:24:53 +00:00
Ed Sanders
744569f8b6 Follow-up: I21d17de56: HtmlFileField fixes
* Make 'accept' an array like it is in OOUI
* Treat $this->mMultiple like the boolean it is
* Don't bother setting 'placeholder' on native inputs

Change-Id: I4c1341181757791c2e1ac2a14c4b3e7c8461ca54
2021-01-22 16:03:21 +00:00
jenkins-bot
524a992458 Merge "Create HtmlFileField" 2021-01-21 23:52:27 +00:00
Ed Sanders
b28809cb16 Create HtmlFileField
Bug: T243476
Change-Id: I21d17de56f753c4f62c17c0baf988e1ca890bfda
2021-01-21 22:55:00 +00:00
Thalia
10e043b9c7 HTMLForm: Add documentation for sections and subsections
Change-Id: I6cc496476e980f0ee0dfd5d6c15e59ef9eb14aa0
2021-01-04 18:15:32 +00:00
Umherirrender
a30fe542ae build: Enable SecurityCheck-DoubleEscaped and suppress issues
This issue type was globally suppressed in
I849ac4f120fd15b483e8939d4db45c98dc351259 to make reviewer easier.

This adds inline suppressions or @suppress directives on function
docs for false positives, mostly restoring those removed in
I849ac4f120fd15b483e8939d4db45c98dc351259

Bug: T231311
Change-Id: I1b1d814bd907e9d49fcc39f777982936574fc7c6
2020-12-30 23:34:20 +00:00
Umherirrender
e9e784a09e build: Enable phan-taint-check-plugin and suppress issues
Taint check checks for possible security issues by tracking html
escaping and more by using phan.
This slows done the phan-job a bit and requires more ram

Keep the DoubleEscaped issues out to make reviewer easier

Adds suppression for false positives
Adds taint-annotation to help taint-check
Removes suppression for code phan now understand better by the tracking
of keys in taint-check
Fix some small issues by adding int cast or htmlspecialchars calls

Bug: T216348
Bug: T268920
Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
2020-12-30 19:02:22 +01:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
Umherirrender
cf8c94b163 Do not assume string is message key in OOUIHtmlForm::getErrorsOrWarnings
single string is raw html,
not a message key as documented on HTMLForm::trySubmit

Also remove is_string, any truthy value would be implicit string casted
in HtmlForm::getErrorsOrWarnings

Reorder the if in HtmlForm to look similar to OOUI

Change-Id: I5b78b0df2cca695f8f5c6b08aa4d6c015d1fa1fe
2020-11-20 14:26:15 +00:00
Thiemo Kreuz
20b2c5000d Make use of array deconstruction directly in foreach, if possible
Deconstructing non-sparse, numerically indexed arrays directly in
foreach (a.k.a. using the list() syntax in foreach) is possible since
PHP 5.5.

The possibility to use string array keys as well as non-sequential
numeric keys in array deconstruction was added in PHP 7.1.

Change-Id: I56a48552a45f61cedc291b306cad8548fc70d485
2020-11-12 18:38:06 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
jenkins-bot
c3d80f59e0 Merge "mediawiki.htmlform: Ensure collapsible forms are enabled" 2020-10-15 18:43:10 +00:00
jenkins-bot
3bbdae14c3 Merge "HTMLTextField: support non-boolean autocomplete values in OOUI" 2020-10-15 15:04:22 +00:00
Bartosz Dziewoński
d8c93b163a mediawiki.htmlform: Ensure collapsible forms are enabled
The code that enables collapsible elements in 'mediawiki.page.ready'
may not run on special pages.

Bug: T260642
Change-Id: I4c5250f5b2575ec6699b99bf979c02e5ac16722d
2020-10-13 22:37:15 +02:00
Umherirrender
d790580fda Fix typos related to repeated words
Change-Id: Ibc187d95b003017255bc87adf56afae7a59bd3db
2020-09-27 10:25:36 +00:00
Gergő Tisza
d4eefa2acf
HTMLTextField: support non-boolean autocomplete values in OOUI
Bug: T150983
Depends-On: I37c9900277cd6125434383b5bbcfa95fc17c7314
Change-Id: I8a6b6cb8c6e031938767c5a56b64817a921b8fc5
2020-09-26 21:52:00 -07:00
jdlrobson
741f0800ca Collapsible HTMLForms need to add JS module
Not working on Special:AbuseFilter for example
Skins can disable this module so special pages must
add it explicitly.

Bug: T260642
Change-Id: I51deedf9c60279b0917ab085fd7498edf55e93da
2020-09-15 17:01:46 +00:00
Thiemo Kreuz
d206da0e1e CSS 'class' names can be an array in Html::…element
Change-Id: I301d23066b19051b9e1cb9363639f6189a8b173c
2020-09-08 19:11:19 +00:00
DannyS712
78b8a56114 Remove mentions of mw.htmlform.Checker
mw.htmlform.Checker was removed in 743edb1
and no longer exists

Change-Id: Id269f63fd3ca64a719745868d6df907548c15fad
2020-08-18 06:26:07 +00:00
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
daniel
102c9573b3 Mark exceptions as @newable
Exceptions classes are nearly always value objects, and should in most
cases by newable.

Bug: T247862
Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
2020-07-08 17:51:38 +00:00
jenkins-bot
3ce6199e55 Merge "Avoid undefined index 0 in HTMLMultiSelectField class" 2020-06-29 15:20:35 +00:00