Commit graph

218 commits

Author SHA1 Message Date
Alexander Vorwerk
3aa5b6643b Use LanguageNameUtils constants instead of strings
Change-Id: I8521d00675008da0d7c8c768ab75352212653c66
2021-12-05 22:13:34 +01:00
Reedy
2a2bb1e9bd Remove or replace usages of "sane"
Bug: T254646
Change-Id: I096b2cf738a1395a14f1d47bcbed0c2c686c2581
2021-11-22 13:35:17 +00:00
Martin Urbanec
408999928d
HTMLTitleTextField: Remove B&C code
Bug: T288181
Change-Id: Iec9225d0f0fe47dd972f6c302ca803e65b8232a7
2021-09-22 00:48:59 -07:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before

Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
2021-09-07 17:29:03 +02:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
jenkins-bot
1c623e395d Merge "Remove unneeded explicit true/false inside conditions" 2021-08-18 17:40:58 +00:00
Umherirrender
244ea7c0b5 Simplify else-branches after continue/break
When the if branch continues the loop,
than the next branch does not need to be an else branch

Change-Id: Ia158709b7fd2ea811f1049cf8f53ed12c89719e3
2021-08-17 22:51:43 +02:00
Umherirrender
864068d000 Remove unneeded explicit true/false inside conditions
The non-strict conditions in if/while are true/false without the check.

In some situation the true/false is removed, because it is known to be a
bool (by is_bool check or type hint)

Change-Id: I5ca4c4771af25d2e785e82732df204a73653886e
2021-08-17 21:52:34 +02:00
Kunal Mehta
a85f569dd1 Revert "Use CsrfTokenSet as CSRF token source"
This reverts commit 0d75fdb4f7.

Bug: T287542
Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
2021-08-05 15:48:26 -07:00
Gergő Tisza
16f3b8c4c0 Make HTMLTitleTextField interwiki option tri-state
Make the 'interwiki' option temporarily accept null as well as true/false
(and default to null instead of false) so form fields which disallow
interwiki titles can avoid deprecation warnings. This also includes
implementing the new error message.

The idea is that for the duration of the deprecation process, form fields
can be set explicitly to interwiki => false (which will eventually become
the default). It would be super annoying to have to do this for all
title fields, but this way it's only needed for fields where users actually
submit interwiki titles with some frequency.

Also improve the logic for legacy fields (which do not set the option
either way): since these (while emitting a warning) allow an interwiki
title, it does not make sense to apply namespace etc. checks to that
title.

Bug: T288155
Change-Id: Ic00f4a0f27747b5ff0893b4c01f42f68a99771ab
2021-08-04 21:24:16 -07:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Petr Pchelko
0d75fdb4f7 Use CsrfTokenSet as CSRF token source
Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
2021-07-12 14:19:15 -07:00
Bartosz Dziewoński
0feccb0cb1 Rename CSS class 'mw-htmlform-field-autoinfuse' to fit the convention
Rename to 'mw-htmlform-autoinfuse'. This avoids the 'mw-htmlform-field-'
prefix normally only used by HTMLFormField subclasses, and matches the
'mw-htmlform-autoinfuse-lazy' class used in related code.

Bug: T278036
Change-Id: I4a73ec6d5993a7e4f10ef8523eef594a70c9abcc
2021-06-19 15:57:43 +02:00
Gergő Tisza
e1088ba0d5 HTMLTitleTextField: include field name in deprecation warning
Follows up I1bed0aa90dab8c872e915148923a5d78c9dee2f3.

Bug: T279886
Change-Id: I52adea0ce3242e784a8fa1b34a9eb5de913b16b2
2021-06-13 13:58:24 +02:00
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
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
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
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
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
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
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
jenkins-bot
3bbdae14c3 Merge "HTMLTextField: support non-boolean autocomplete values in OOUI" 2020-10-15 15:04:22 +00: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
Thiemo Kreuz
d206da0e1e CSS 'class' names can be an array in Html::…element
Change-Id: I301d23066b19051b9e1cb9363639f6189a8b173c
2020-09-08 19:11:19 +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
jenkins-bot
3ce6199e55 Merge "Avoid undefined index 0 in HTMLMultiSelectField class" 2020-06-29 15:20:35 +00:00
Umherirrender
169300346e Avoid undefined index 0 in HTMLMultiSelectField class
$out has only items, when $optionsOouiSections has items, but when
$options is empty, $out is also empty. In that case $hasSections is
false.

Bug: T232616
Change-Id: Id3959013b7b1db0d4faeecea9148bae97227abcf
2020-06-29 15:07:07 +02:00
DannyS712
94169ee873 Whitespace cleanup: Use tabs for indentation, avoid double spaces
Change-Id: I346073b59d283029bd6666356c62c81e687ea5e6
2020-06-27 07:53:07 +00:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10:00
DannyS712
b31cec3cec Remove more IE6 and IE7 compatibility and notes
Neither is supported

Bug: T232563
Change-Id: Ia7902f0b1df6148d819621dd5e57d2fe91a50973
2020-05-19 00:31:46 +00:00