This patch introduces HTMLTimezoneField, an HTMLForm field type that
allows the user to select a timezone, either from a geographic zone, by
manually entering an offset, or using the wiki/browser default. This
logic is extracted from DefaultPreferencesFactory so that it can be
reused elsewhere.
The widget itself is really just an HTMLSelectOrOtherField, it's just
the list of options and the JS logic that is special.
Bug: T309629
Change-Id: I99a00dff7e3319ce45883191daee16bec1ed68ba
Callbacks for validation-callback definitions are given the submitted
field value, which was documented as being string or array, but
actually can include int, null, etc.
This fixes the docblock, and also updates
DefaultPreferencesFactory::validateSignature() which was assuming
a string and not expecting null. (This didn't matter before PHP 8.1.)
Bug: T318307
Change-Id: Ia9096d610bf377334bbeab9021a8ade9be62edd5
The variables are set conditional later, but all condition branches set
it or the variable is not used outside that scope
Change-Id: Ic9612915db507028ad4733a061d3ce9be3babfb6
Various variables are left from ealier refactor are now unused
and can be removed to make the code easier to read
Change-Id: Id51770af1f08e85c7e7a02234a2cd2ab5b47ee7a
This patch simplifies and fixes a few issues in code related to the
'timecorrection' user setting:
- Always re-apply UserTimeCorrection normalization to the preference
value, although it should be already normalized
- Avoid duplicating code from UserTimeCorrection, both for the
pipe-splitting and the offset computation/fallback
- Use better variable names
- Inject an ITextFormatter for generating the dropdown options, instead
of a ContextSource (ew) or a Language, removing calls to wfMessage as
well. Note that the ITextFormatter is not injected into the
preferences factory because the eventual goal is to move the code to a
new HTMLFormField class.
- In TimezoneFilter, remove a redundant check: the value comes from the
form, and the option for using the system time is always "System|XXX",
never just "System". This seems to have been introduced in
I2cadac00e46dff2bc7d81ac2f294ea2ae4e72f47; the previous code was only
comparing $data[0], and not $tz. Change the test accordingly and add a
test case.
- Add missing star to docblocks in UserTimeCorrection, as well as a
missing int cast.
- Fix typo and other style issues in UserTimeCorrectionTest
- Bonus: add missing docblock star in HTMLApiField
Bug: T309629
Change-Id: Iab35eb17259826429e4b6bc1ba7385ab57884e98
Callbacks are documented to return Status, but we use the two
interchangeably almost everywhere, so this eliminates an easy
mistake possibility.
(The more ideal solution would be to allow returning StatusValue
from trySubmit and associated methods, but that's way more effort.)
Change-Id: I6c54b4aceb0430530d22423f8e80ab20a88548b3
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
Seen in
MediaWiki\Skins\Vector\Tests\Integration\HTMLLegacySkinVersionFieldTest::testGetInput with data set #0 ('1', true)
Error: Call to a member function getConfig() on null
when run with
php tests/phpunit/phpunit.php '-c' 'tests/phpunit/suite.xml' '--testsuite' 'skins' \
'--exclude-group' 'Broken,ParserFuzz,Stub,Database,Standalone'
Change-Id: I0f5d67c122adb922e3212e597a0ce27c7785009c
Ensure that the ID is included in the generated label field for
the 'info' type (which is defined in HTMLInfoField.php).
This is needed for a OOUI conversion in the CheckUser extension,
as a JS script relies on an ID being present for a element that
only the 'info' type suits.
Change-Id: If4724e6699aa3ec076817a7c4727cbff184b94e7
There were several inconsistencies in how ID vs cssclass vs own classes
were applied, both within the same widget + mode, between different
modes for the same widget, and different widgets. So uniform all of them
according to the plan detailed on phabricator. Include
HTMLSelectAndOtherField as well (that wasn't mentioned on phab) for
consistency. Also remove the select-or-other class from
HTMLAutoCompleteSelectField (which was only applied in HTML mode), since
the widget is not technically a SelectOrOther.
Adjust the logic in selectorother.js so that it works fine in HTML mode,
and disable it for OOUI mode since SelectWithInputWidget does that
already (and the field is autoinfused).
Also, in HTMLAutoCompleteSelectField, don't assign an array to
$this->mClass. This happens to be working right now, but it violates the
type definition of the property.
Luckily, according to codesearch this change seems to be
backwards-compatible because these fields are not commonly used, and
nobody seems to be passing cssclass to them.
Bug: T309883
Change-Id: If950f131d1c4bc1645de6021781045dccfc61966
In a default installation of Mediawiki, the article URLs use the URL GET
parameter "title" to construct the page title (index.php?title=Foo).
When a form is submitted, that parameter is added to the form as a
hidden field. Before this patch, it's added as last element of the form,
which makes the URL confusing. For example, when running a search on the
Lint errors, the URL becomes
index.php?pagename=Test&title=Special%3ALintErrors instead of starting
with title=Special:LintErrors as one would expect.
Note that this is not an issue on wikis that set their article path to
look like /wiki/Foo: in that case, the title of the page is not set as
a hidden field.
Change-Id: Id7c0617166754010cec987158e14ac54ddc94444
Using the constructor without the $context parameter was deprecated
in MediaWiki 1.38 in 97056794fc.
Bug: T308407
Change-Id: Id92adde978e70ffd6fa5d4a048d5d45c7ede4bf3
In the HTMLTextField parent class, both getInputHTML() and
getInputOOUI() support adding a placeholder in the input, but for the
combobox field, this was lost in the OOUI method. (In the HTML method,
the parent call takes care of it.)
Bug: T307443
Change-Id: Ic5f86bcc22867619d184f08293c6bc03f3df082d
* Move the reset preferences link from the bottom of the preferences
form to the "basic information" section.
* Change the link from "destructive" red to default styling, since the
action requires confirmation so there is no reason to make the user be
afraid of clicking it by accident.
* Add a checkbox to the /reset form, for triple confirmation.
* Add a cancel button to the /reset form, to take the user back to
safety.
* Allow checkboxes to be "required" by fixing a detail in
HTMLFormField::validate(). The UI is not pretty, but it works.
Bug: T226325
Change-Id: I116d5275ba1a5beaaa44b32b8eff5824e94b437a
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
Make phan stricter about array keys
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together
Bug: T304887
Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1
Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385
Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
Some use cases like HistoryAction prefer the `index.php` form to keep
consistency, so they use setAction( wfScript() ) or something similar.
But the title is missing, so they hack it with manual addHiddenField()
or add a 'title' field in the descriptor. This is not good and prevents
us to warn the use of internal fields (title, wfEditToken).
Bug: T285464
Change-Id: Iaec81a2fb49162f2fc764f143f88e887572a3a0b
Conventionally, public constants are accessed via their declaring
class, except for self:: which is an acceptable shortcut.
Change-Id: If05eab72140267e6ef54736710d751d7f24a7860
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
Make phan stricter about scalar types by setting scalar_implicit_cast to
false (the default in mediawiki-phan-config)
Bug: T242536
Bug: T301991
Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
There is no reason to use loadData() only, and would unexpectedly skip
some necessary checks in prepareForm().
Some use cases are too old and didn't make use of the show() method
where should be available, which may be addressed in follow-up(s).
Bug: T256805
Change-Id: Ibbdc2c2c2b056342bb2c583a63546ac789b651d8
It gets wrapped into a Widget in ::getOOUI
Found by phan strict checks (used by tagfilter and cloner)
Change-Id: Ie1fd15fc2a66fcb39fa2e2f63761d9683029e395
php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts
Found by phan strict checks
Change-Id: I92daeb0f7be8a0566fd9258f66ed3aced9a7b792