Commit graph

175 commits

Author SHA1 Message Date
jenkins-bot
49fdec9c51 Merge "Use splat operator in signature, not func_get_args" 2019-10-03 18:56:50 +00:00
Gergő Tisza
f301dd5ce9
Fix HTMLForm::addButton label-message type annotation
Change-Id: I5dad560df0705976e104eec4d4159993e5bd0b66
2019-10-02 19:53:57 +02:00
Michael Große
a89f0997a3 Use splat operator in signature, not func_get_args
Most of the original scope of this patch was implemented in 8665536045

What remains is to use the splat operator in the method signature as
well which is more readable than using func_get_args and doesn't annoy
phan. This is now possible, because we are no longer testing on HHVM and
these mocking in HHVM tests was the only place where this was broken.

Change-Id: I52912d1810b955b05cd17fab424f80c201883411
2019-09-28 18:02:21 +00:00
Volker E
441e12f2d9 Messages collected above the form are meant to live as boxed messages
Also removing HTMLForm/VForm `.error` and `.warning` classes from
'forms.less'.

Bug: T233362
Change-Id: I4f8d8f228ab07253a7df24470791c26e39bc311a
2019-09-19 15:10:45 -07:00
Daimona Eaytoy
e2e543f7c2 Unsuppress more phan issues (part 5)
Bug: T231636
Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84
Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
2019-09-01 09:48:31 +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
Thalia
ce965f9826 Fix punctuation in HTMLForm documentation
Change-Id: I22c4ed248fddc93afd486b9bee5a80bdbba1c685
2019-07-30 14:43:39 +01:00
jenkins-bot
5b202d729d Merge "Adjust type hints in htmlform related classes" 2019-07-05 21:32:55 +00:00
Umherirrender
11c9075767 Adjust type hints in htmlform related classes
The return type of HTMLFormField::loadDataFromRequest to mixed
Some sub classes returning arrays or bools, not everytime strings

HTMLCheckField is working with arrays, so also allow array on getTableRow

Change-Id: I076feea76d8e296f27c8a9fb4cbd9368584ba187
2019-07-05 18:11:53 +00:00
Dayllan Maza
f74b19134d Add new public method addFields() to HTMLForm
Once you instantiate an HTMLForm there was no clear way of adding
new fields except for hidden fields. This is particularly problematic
when the form is passed by reference in Hooks.

NOTE: this is just moving what was previously part of the constructor
into its own method + very small tweaks

Change-Id: I23f983417510841ce76cdefcb076e5ab97b43f10
2019-06-26 16:29:41 -04:00
Kunal Mehta
8665536045 HTMLForm: Use PHP 5.6 splat operator directly instead of ObjectFactory
Change-Id: I3fddf30f1b0fc2cce79f652cb71efba119439a9f
2019-06-04 23:49:20 -04:00
Derick Alangi
e849ffb430 HTMLForm: Remove deprecated unused getErrors() method
Was deprecated in 1.28 and no longer used, see usage below;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbgetErrors%5C(%20(.*%3F)%20%5C)&i=nope&files=&repos=

Bug: T220656
Change-Id: I542df4f1f7f4180d42282eaf2e069ab0bc9e8614
2019-06-03 15:20:54 +01:00
Timo Tijhof
012aa045e9 HTMLForm: Improve method documentation for setCollapsibleOptions()
Follows-up 36d33daa03.

Previously the method was described as "Set whether the form can be collapsed"
taking a single boolean.

Yet, the boolean did not influence whether the form can be collapsed, as one
might expect.

Rather, this method always enable collapsible mode. The thing that is set
based on the passed value is the default state of that (unconditionally)
enabled collapsible mode.

Change-Id: I2e73d5481c44ed43769553b2bc25543a702c19b8
2019-05-22 23:40:52 +01:00
Derick Alangi
fefedf568b HTMLForm: Add known MediaWiki version to wfDeprecated() call
In 3706dcb, this method was soft deprecated and hard deprecated at
the same time (1.28) but during the call to wfDeprecated for hard
deprecation, the version number was missed, though this will default
to false, it's good to use the version number which is known in this
case (1.28).

Change-Id: I535ad07e79d14bac8ec42beaeb4b3762a494b28b
2019-05-18 09:15:33 +00:00
Derick Alangi
1981823755 Remove several methods, deprecated in 1.32
I've checked and doubled checked that these methods are no longer used
anywhere in core or extensions, hence removed them. They were hard deprecated
in MediaWiki 1.32.

* OutputPage:
  ** `::showFileCopyError()`
  ** `::showFileRenameError()`
  ** `::showFileDeleteError()`
  ** `::showFileNotFoundError()`

* ApiBase:
  ** `::truncateArray()`

* IcuCollation:
  ** `::getICUVersion()`

* HTMLForm:
  ** `::setSubmitProgressive()`

* ResourceLoaderStartUpModules:
  ** `::getStartupModules()`
  ** `::getLegacyModules()`

* BaseTemplate:
  ** `::msgHtml()`

* QuickTemplate:
  ** `::msgHtml()`

* WatchAction:
  ** `::getUnwatchToken()`

Bug: T220656
Change-Id: Ic1a723a991f4ff63fcb5f045ddcda18d1f8c3c68
2019-05-09 11:36:44 -07:00
Bartosz Dziewoński
36d33daa03 HTMLForm: Improve method interface for collapsible forms
Also minor tweaks:
* Fix @since tags, this did not make it into 1.33
* Fix usage of FieldsetLayout 'group' in OOUIHTMLForm
* Documentation changes

Follow-up to 2896e87a10,
per my post-merge review on that commit.

Change-Id: Ib93375cde19730a46e4929878d6e472d3ac8f631
2019-05-02 14:33:20 -07:00
jdlrobson
2896e87a10 History form can be collapsed
A generic way for collapsing forms is added and used
on history.

Bug: T220555
Change-Id: I3073359210bcc25625c9ec07629100130effaed1
2019-04-09 22:57:39 +00:00
Max Semenik
e6818e6c64 Fix unused vars/pointless assignments
Change-Id: If475c738b4af7208024c866594d4c0048af053dd
2019-03-29 16:52:48 -07:00
jdlrobson
dc180ca64f Restore #mw-history-search id on history action fieldset
Change-Id: I3551667b1f64a3cd9227b07df2a215ccb701ea5d
2019-03-29 15:28:36 +00:00
Lucas Werkmeister
5d46ab1453 Fix invalid HTMLForm::setValidationErrorMessage doc
The method has not actually supported scalar or single-level array
arguments for a while now; according to Michael Große, this ability was
lost in Ibb17bb61ac. No one seems to have noticed (indeed, MediaWiki
code search finds no callers at all [1]), so instead of trying to fix
it, let’s just update the documentation.

We can also remove a cast to array in trySubmit(), because if the value
wasn’t already an array, then converting it to a single-element array
and then trying to spread its only element into $hoistedErrors->fatal()
arguments still fails (“only arrays and Traversables can be unpacked”).

[1]: https://codesearch.wmflabs.org/search/?q=setValidationErrorMessage

Change-Id: I8c292ec62ef4aec89217e86a75d7f2e88111f43f
2019-03-19 15:19:30 +01:00
Thalia
ccbe9f3590 Introduce multiselect widgets for namespaces
Bug: T204986
Change-Id: Ie3916e2322d8b1a7effe9ba4604b596b568004e6
2019-01-22 12:48:42 +00:00
Sethakill
d0c31ac988 Convert Special:AllMessages to use OOUI
Moved form from pager and
added new HTMLSelectLanguageField.

Bug: T117749
Bug: T134425
Change-Id: I46dc6cc8f7ddf8552a726202df136cbbff66588c
2019-01-02 15:18:19 -08:00
Thiemo Kreuz
fa7e5bd901 Avoid expensive array_shift where possible
array_shift manipulates the original array. This is surprisingly
expensive, because it iterates *all* elements in the array and
decrements numeric keys. The code touched in this patch does not need
this restructured new array, but only the individual elements.

Change-Id: Iee28377b2c9930f6de821e041381a1d7564f7633
2018-12-17 11:58:55 +01:00
C. Scott Ananian
d8e612ffaa Replace deprecated call to OutputPage::parse() in HTMLForm
Use OutputPage::parseAsInterface() to tidy the output and make the
selection of user interface language explicit.

Follow-up to Ifeb1ca6eb8b5c743421b8f9e329f1e3658050e47.

Bug: T198214
Change-Id: Ia4b63715380d97ccb3133bf39a260834c20b4f5a
2018-11-01 17:26:10 -04:00
jenkins-bot
e044600d9d Merge "HTMLForm: Remove parameters 'notice', 'notice-messages', 'notice-message'" 2018-10-24 17:14:34 +00:00
Moriel Schottlender
07a5c71646 TitlesMultiselectWidget: Add a widget that allows selection of multiple titles
Add the widget in both PHP and JS for OOUI, and into HTMLForm
definitions.

In JS, the widget uses the engine from mw.widgets.TitleWidget
with the async support from OO.ui.mixin.RequestManager.

The PHP version provides a textarea, like UsersMultiselectWidget.php
which is then infused if JS is available.

Also, add highlightSearchQuery option for TitleWidget to allow for
not highlighting the partial search query the user typed in, if the
UI requires it. This option (highlighting partial result) is already
optional in the TitleOptionWidget, so this config exposes that
optionality in the TitleWidget widget for its menu children.

Notes:

HTMLTitlesMultiselectField is a duplication of HTMLUsersMultiselectField
except for:
- The configuration variable changed to 'titles' (from 'users')
- OOUI modules were adjusted for the TitlesMultiselectWidget
- The PHP version instantiates a MediaWiki\Widget\TitlesMultiselectWidget

TitlesMultiselectWidget is a duplication of UsersMultiselectWidget
except for:
- $usersArray was renamed to $titlesArray
- getJavascriptClassName returns the correct js class for
  mw.widgets.TitlesMultiselectWidget for infusion.

Bug: T197109
Depends-On: I675316dddf272fd0d6172ecad3882160752bf780
Change-Id: Ie96947a35f70b76731e16ae5b85de815dfa4a8ce
2018-10-24 00:46:48 +00:00
Bartosz Dziewoński
54d9b373cd HTMLForm: Remove parameters 'notice', 'notice-messages', 'notice-message'
Bug: T197179
Change-Id: I911cabc1e1e1c2abb8e91a55c05eaa1c76134087
2018-10-22 12:19:58 -07:00
Bartosz Dziewoński
45ced4dfef EditWatchlistNormalHTMLForm: Fix double-escaping of section legends
Parent getLegend() returns a plain string, and this method should
do the same.

Form section legends are escaped by the wrapFieldSetSection() method.

Change-Id: I2059b9182fba7362f3d6226252bdc3e032a06c57
2018-09-03 22:09:13 +02:00
Brian Wolff
2db0dc2438 Add taint annotation to HtmlForm::getHTML()
This is to help AbuseFilter pass phan-taint-check.

Change-Id: I73a6a626337037f6b0cee04b0afb5a59907d3be6
2018-08-31 19:32:46 +00:00
Bartosz Dziewoński
76e7016993 HTMLForm: Deprecate parameters 'notice', 'notice-messages', 'notice-message'
Bug: T197179
Change-Id: I603436e0720fdc0f08f35f3c0630b79865a9c82a
2018-08-29 22:02:52 +02:00
jenkins-bot
33afb7440a Merge "Expand documentation about options in HTMLForm" 2018-08-25 06:51:43 +00:00
Ed Sanders
e5911a826c Pass through 'helpInline' to OOUI FieldLayout and make true by default
This change is meant to improve the layout of Special:Preferences in
particular, but it will affect any OOUI form using help messages. It
should be a harmless or beneficial change for most of them.

Previous behavior can be restored by passing `'help-inline' => false`
to the HTMLForm factory after 'help-message'/'help-messages'/'help'.

For example:

* Special:Preferences?ooui=1#mw-prefsection-watchlist
  * Before: https://phabricator.wikimedia.org/F25025213
  * After:  https://phabricator.wikimedia.org/F25025181

* Special:ChangeEmail
  * Before: https://phabricator.wikimedia.org/F25073327
  * After:  https://phabricator.wikimedia.org/F25073328

* Special:BotPasswords/foo
  * Before: https://phabricator.wikimedia.org/F25073324
  * After:  https://phabricator.wikimedia.org/F25073326

Bug: T181854
Change-Id: Ica67fe4081dfaa8eb9e8f56fdb93530750e47012
2018-08-17 22:34:33 +02:00
Umherirrender
7b01567b00 Expand documentation about options in HTMLForm
Change-Id: Ia170f07f994680dca105981a14ad5a0d98b57a26
2018-08-13 09:16:11 +02:00
David Barratt
d609da624b
Add a method to HTMLForm that allows the preText to be accessed externally.
Currently there is no way to access the preText outside of an HTMLForm. Adding
a getPreText method to HTMLForm so the preText is accessible.

Bug: T199115
Change-Id: I937028e7025b4a7b5d333e9bf5a25920f6a88316
2018-07-09 10:42:19 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Fomafix
f02eed24ac Allow overloading of getLabel() with return ' '
This is a follow-up to 125cbd8c01.

Bug: T198338
Change-Id: I21626326dde368d70fcc33052e43ff90db5ea9c0
2018-06-28 11:25:39 +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
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
jenkins-bot
399d9c24a8 Merge "Document nodata for HTMLFormFields" 2018-05-19 14:17:57 +00:00
Florian Schmidt
d99c3a4e6d Document nodata for HTMLFormFields
This could be a useful feature for users of HTMLForm, so they should be
able to know about it.

Bug: T156056
Change-Id: Ib444051e38292c06ebe370465b7c751e136d42b2
2018-05-19 13:48:49 +00:00
Ed Sanders
fc65ff17d9 Special:Preferences: Construct fake tabs to avoid FOUC
Bug: T192769
Bug: T189366
Change-Id: I4aabda97d14d97dce3e35abda2ce82925d721c9b
2018-05-18 18:10:45 +00:00
jenkins-bot
7583ead426 Merge "Make setSubmitProgressive() Deprecate" 2018-04-25 21:45:50 +00:00
Jayprakash12345
e7cd669bc5 Make setSubmitProgressive() Deprecate
Bug: T191586
Change-Id: Ie310ea9c3ca7c9e4b8755ba500e2ccafd0b64463
2018-04-20 23:12:51 +00:00
David Barratt
3481e3b2e0
Create Expiry Widget with Date Time Selector
Special:Block needs a date time selector for easier selection of expiry. To
accommodate this cleanly, a new Expiry Widget is created that handles this
logic.

Bug: T132220
Change-Id: I2853a2ca0ae6ccead3978f4bb50a77c2baa3a150
2018-04-19 20:24:08 -04:00
James D. Forrester
ae7237ea98 Drop HTMLForm & VFormHTMLForm::isVForm(), deprecated in 1.25
Change-Id: If5f4e146071c17a9adabd36453ef68ff38405ed4
2018-03-26 10:55:41 -07:00
Max Semenik
369b3fa977 Normalize PHPDoc attributes
Change-Id: I83e686d099de0ff0aacda7e332972e1c7ee49f04
2018-03-16 22:59:15 -07:00
Kunal Mehta
79de8fd02f Use wikimedia/object-factory 1.0.0
Deprecate the unnamespaced version and move it to includes/compat.

Bug: T147167
Depends-On: I39c805bfb98b32f32f3d0dc1eee9e823afe1c21a
Change-Id: I3780c7adf51683f3f7adb35a88f9a25a0a2e2530
2018-02-04 12:52:44 -08: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
Fomafix
04ff65fc69 Simplify autocomplete attribute in HTMLForm
Follows-up 7489a3e8

Change-Id: Ifb17c88e39df7031054b3bee83772172c64d0a6b
2017-12-28 16:41:39 +01:00