Commit graph

46 commits

Author SHA1 Message Date
Roan Kattouw
6347d8aa68 HTMLForm: Remove use of jquery.chosen in HTMLMultiSelectField
HTMLMultiSelectField used the jquery.chosen library, but only for the
legacy display format, and only if the 'dropdown' option was passed.
There is only one form that passes the 'dropdown' option
(SpecialActiveUsers), and that form uses the OOUI display format, so
this code is unused.

Also remove the htmlform-chosen-placeholder i18n message, which is now
unused as well.

Bug: T53443
Change-Id: Ie4f9fff322ae26fbdf9eae1b3634d1b04e746179
2024-06-13 17:28:37 +00:00
Ebrahim Byagowi
14b4269d83 Add namespace and deprecation alias to Xml and XmlSelect
This patch introduces a new namespace declaration,
MediaWiki\Xml and adds Xml and XmlSelect to it
and establishes class aliases marked as deprecated
since version 1.43.

Bug: T353458
Change-Id: I45cccd540b6e15f267d3ab588a064fbeb719d921
2024-05-16 15:23:14 +03:30
Taavi Väänänen
ed7e787f32
Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyle
Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.

Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
2024-04-22 18:26:14 +03:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
Bartosz Dziewoński
f1d7e68cd2 Rename dropdown-related methods to avoid random camel-case
It's a dropdown, not a drop down, therefore rename:
* Html::listDropDownOptions     → Html::listDropdownOptions
* Xml::listDropDownOptions      → Xml::listDropdownOptions
* Html::listDropDownOptionsOoui → Html::listDropdownOptionsOoui
* Xml::listDropDownOptionsOoui  → Xml::listDropdownOptionsOoui
* Xml::listDropDown             → Xml::listDropdown

In PHP, method names are case-insensitive, therefore we can do this
without a breaking change or deprecation.

This also matches the naming convention in OOUI.

Change-Id: Ifda13ba9dee316709c424636ec3b285de8d0e9b1
2024-03-09 02:31:33 +01:00
James D. Forrester
59c0aa2134 Namespace HTMLForm and friends
Bug: T353458
Change-Id: I09e66c3223018ec47e0549ee7f6a590b676f4eef
2024-02-14 08:18:33 -05:00
James D. Forrester
102a4f8a35 build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manually
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
  * Fake exceptions triggered to give Monolog a backtrace are for
    some reason "traditionally" RuntimeExceptions, instead, so we
    continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.

Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
2024-02-10 02:22:41 +00:00
jenkins-bot
ee60406617 Merge "Remove uses of $wgUseMediaWikiUIEverywhere" 2024-02-05 13:59:51 +00:00
Bartosz Dziewoński
aa7eeeeef9 Remove uses of $wgUseMediaWikiUIEverywhere
Removing the config variable in a separate change:
Ib9966bc6a4a94f771cb99a5aa52fb6a1dc826ca5
(just in case something depends on its existence).

Bug: T182050
Change-Id: Ic3e038df16fc540ec7f6bcb9a54d73f8d596d305
2024-02-04 19:16:30 +00:00
James D. Forrester
1ed893880c Html: Copy listDropDownOptions() and listDropDownOptionsOoui() from Xml and migrate users
Bug: T356544
Change-Id: Ibcc13c92a48b3fd2a33914418dfbefb0dd890c82
2024-02-03 18:27:23 +00:00
Amir Sarabadani
5bd33d46ef Reorg: Move WebRequest to includes\Request
This has been approved as part of RFC T166010

Bug: T321882
Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
2023-09-11 21:44:34 +01:00
Daimona Eaytoy
8adf1bfb93 Replace some more usages of deprecated MWException
Bug: T328220
Change-Id: I3c36835fbd90acc301731e2b33ae4815cd4b0cc5
2023-06-09 02:07:08 +02:00
Amir Sarabadani
7d8768e931 Reorg: Move HTML-related classes out of includes/ to Html/
Bug: T321882
Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
2023-02-16 20:40:01 +01:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Aryeh Gregor
4a52bf553f Use MainConfigNames instead of string literals, #3
This edition brought to you by:

grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr
"\n" '|' | sed 's/|$/\n/') includes/

I only corrected a fraction of the results provided by that command. I'm
submitting the partial patch now so it doesn't bitrot.

Bug: T305805
Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
2022-04-26 14:31:26 +03:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Func
3722dc30d6 HTMLMultiSelectField: Add forced-on options to the output of filter
Forced-on options (selected as default but disabled) should always in
the loaded data, like what HTMLCheckMatrix do.

Change-Id: I342928eca01ae8a9f34ee7156a515524c3a0d9dd
2022-02-09 07:32:12 +00:00
Func
81351f6eba Allow placeholder to be set for multiselect fields in dropdown mode
Change-Id: I5d9c15c776e7da6ca1832f5981e6423bc501bab6
2021-12-09 03:03:04 +00: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
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
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
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
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
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
Daimona Eaytoy
b5f0d61ee4 Fix new phan errors, part 8
Bug: T231636
Change-Id: I61852ba55362ab9ae8cc8c1ab6b27565ce1d08e7
2019-10-22 10:09:13 +02:00
Daimona Eaytoy
114ee6e412 Fix new phan errors, part 6
Bug: T231636
Change-Id: I1870b6cbeb31e54fde5e675fec51446b330e06c5
2019-10-20 17:53:48 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Alangi Derick
f6fcb74728 htmlform: Fix multiple PHPDoc annotations in htmlform module
- Add @param annotation for $params variable for __construct() method
  in the HTMLExpiryField class.
- Add @throws annotation for getOptionsOOUI() method that throws a
  MWException and remove "@return array" as this method only throw an
  exception now.

Change-Id: I292f6ae04b840f6f6f74b7c92f834f056659fbe2
2018-12-03 12:48:53 +00:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
James D. Forrester
6c6efe54ec HTMLForm: Drop this never-used backwards-compatibility
Change-Id: I6864d3a1207de44d465491baad87cb9c00714255
2018-09-12 13:14:18 -07:00
Bartosz Dziewoński
098fd0dcb3 HTMLMultiSelectField: Improve compat with GET forms with no wpFormIdentifier
Now it behaves more like HTMLCheckField: if there is clearly a value
submitted, it will load it.

Setting wpFormIdentifier is still needed for forms with default-on
checkboxes (without form identifier, it is impossible to distinguish a
page view without form submission, and form submission with default-on
checkbox unchecked).

In particular, this fixes the 'Show additional logs' checkboxes on
Special:Log: they no longer get unchecked after form submission.

Change-Id: Ief74a7e424b37ccd44759133b3cb8665275314a6
2018-07-18 20:10:04 +02:00
Fomafix
125cbd8c01 Use \u{00A0} instead of   or  
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or  .

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Bartosz Dziewoński
f752323054 HTMLMultiSelectField: Allow formatting in section headings in OOUI mode
Follow-up to 5a113417e5.
It is allowed in non-OOUI modes.

Bug: T181698
Change-Id: Ib2ebcd1a92f1b02a528787fe3fd1f5452b9808c4
2017-11-30 17:38:30 +01:00
Bartosz Dziewoński
a81db83d79 HTMLMultiSelectField: Fix OOUI\CheckboxMultiselectInputWidget to be infusable again
Regression from 5a113417e5.

Bug: T180677
Change-Id: Id1b0ebe9d9a56a76d73deb2b4d17213ae5e45a04
2017-11-16 11:51:58 +01:00
Bartosz Dziewoński
5a113417e5 HTMLMultiSelectField: Support sections in OOUI mode
The resulting HTML makes very little sense semantically, but no
worries, because so does the existing one for non-OOUI forms.

Change-Id: I99bf6341c58869f6322b9d9c780d9c66739d00b6
2017-09-28 14:17:05 +02:00
Bartosz Dziewoński
8c1a1a62a1 Avoid duplicate accesskey hints on OOUI widgets
Values returned by `Linker::tooltipAndAccesskeyAttribs()` and
`Linker::titleAttrib( ..., 'withaccess' )` include an accesskey
hint in the title text. This is unnecessary when used for OOjs UI
widgets, since after the changes from T168408 they display an
accesskey hint automatically.

Also fixed some other accesskey bugs in HTMLForm which probably
no one ever ran into.

Bug: T168408
Change-Id: I63285b5bce3341875a6d82eba059623bf105ca62
2017-08-01 20:59:13 +00:00
Huji Lee
c96166173e HTMLMultiSelect parameter to specify which options are disabled
Depends on I32fa20e4adb23960d9db6bf6023f79bf128fb600

Bug: T153751
Change-Id: I3bcf6720c960e0be962e0f3f37a22ec8778db1d1
2017-03-07 22:16:37 +01:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08: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
addshore
63dd31cd31 Add access modifiers to htmlform classes
Change-Id: Id8c0f0676b3200993af3cec493efc99839211bcc
2016-11-04 11:40:42 +01:00
Bartosz Dziewoński
96ef35a58a HTMLForm: Add OOUI support for 'multiselect' with 'dropdown' => true
Using CapsuleMultiselectWidget.

Change-Id: I816739bc3acd40ee9d8b67e19ff3e4296fce66d3
2016-10-04 19:50:44 +02:00
Bartosz Dziewoński
d23ebca2b9 HTMLFormField: Move 'flatlist' handling to fields that use it and document
Change-Id: I5dc6ad71880a741c41757bc64d236971edfbabfa
2016-08-24 15:22:32 +00:00
Bartosz Dziewoński
7191028ade HTMLMultiSelectField: Add 'dropdown' option for 'mw-chosen' behavior and document
Previously, you could pass 'cssclass' => 'mw-chosen' in the form
descriptor for a 'multiselect' field, and it'd be automatically
converted to a text field with a dropdown allowing values to be
selected. This is not very intuitive (unless you know what the Chosen
library is) and was not documented anywhere except for release notes.

The new recommended and documented way to achieve this is by passing
'dropdown' => true. Old way is supported for backwards compatibility.

Also, add the 'jquery.chosen' module to the page server-side.

Change-Id: I3a025e1c3c7571e930a35e020d73d558fdc433d0
2016-08-22 17:58:53 +00: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/HTMLMultiSelectField.php (Browse further)