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
This reverts commit a745a87216.
Reason for revert: logspam on use cases out side the scope of HTMLForm
Bug: T302512
Change-Id: Idcf1c7db89b4456308d57915ffd0dcc41ee577ad
After its logic is refactored, we have more faith to use isDisabled() in these cases, which matches the original semantics of isHidden().
Change-Id: I1aece7c691307ac8bb3770e6dc4b8e2877e4d65c
Forced-on options (selected as default but disabled) should always in
the loaded data, like what HTMLCheckMatrix do.
Change-Id: I342928eca01ae8a9f34ee7156a515524c3a0d9dd
* Re-use the methods that generate the dropdown for the input in fancy
recent changes / watchlist filters interface.
* Use ComboBoxInputWidget for the OOUI version, and `<datalist>` for
the plain HTML version, to add a dropdown menu while still using a
text field, in case the dropdown is missing items (it's cached) or
for easy copy-paste.
Bug: T27909
Change-Id: Iad60fb8d9a14e2c67fe9ba365e2ec0768bf5c2da
Don't catch and discard exceptions from the RequestTimeout library,
except when the exception is properly handled and the code seems to be
trying to wrap things up.
In most cases the exception is rethrown. Ideally it should instead be
done by narrowing the catch, and this was feasible in a few cases. But
sometimes the exception being caught is an instance of the base class
(notably DateTime::__construct()). Often Exception is the root of the
hierarchy of exceptions being thrown and so is the obvious catch-all.
Notes on specific callers:
* In the case of ResourceLoader::respond(), exceptions were caught for API
correctness, but processing continued. I added an outer try block for
timeout handling so that termination would be more prompt.
* In LCStoreCDB the Exception being caught was Cdb\Exception not
\Exception. I added an alias to avoid confusion.
* In ImageGallery I added a special exception class.
* In Message::__toString() the rationale for catching disappears
in PHP 7.4.0+, so I added a PHP version check.
* In PoolCounterRedis, let the shutdown function do its thing, but
rethrow the exception for logging.
Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
There is only one use case of cond-state classes passed to the client-side, and it can be done more natively.
Change-Id: Ib6835bb334bd65c6176f0a5c3881b20265901af9
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
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
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
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
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
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
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
Normalise IP addresses in HTMLUsersMultiselectField, to avoid adding multiple equivalent IP addresses
Bug: T275394
Change-Id: I3cbc26cb7c98ddc94bc3effc6bd2ab7108e970f8
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
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
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
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
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