| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
developer's intention
array_fill_keys() was introduced in PHP 5.2.0 and works like
array_flip() except that it does only one thing (copying keys) instead
of two things (copying keys and values). That makes it faster and more
obvious.
When array_flip() calls were paired, I left them as is, because that
pattern is too cute. I couldn't kill something so cute.
Sometimes it was hard to figure out whether the values in array_flip()
result were used. That's the point of this change. If you use
array_fill_keys(), the intention is obvious.
Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
|
|
|
|
|
|
|
|
|
|
| |
This code was querying the service locator for each value, which
showed up on xhgui: according to
https://performance.wikimedia.org/xhgui/run/view?id=601eefa1beb2155092df5c24,
there are 6945 calls to MediaWikiServices::getContentLanguage for a
request, of which roughly 500 outside of this method.
Change-Id: Ibabdd236d6945a1c742a724c8357a0b7015e9071
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This does not change what this code does in any way. All it
does is re-arranging the code paths from most likely to least
likely. For example:
* It's much more likely that an element in an API result is a
string, and much less likely it's an array. This change
increases the chance that the long if-elseif ends after the
first check, and rarely executes the other checks.
* There are not many arrays in an API result, but many, many
more scalar values. Doing the is_array() check first avoids
many, many calls of the hot isMetadataKey() function.
This makes quite a difference in my benchmarks.
Change-Id: I47c1525bdedbc8ca26e10ea7480715a7ecd7d5b2
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since this is a very hot method, it must be really quick. ord() is
useful here, because it discards everything after the first character
and it works with integers.
A quick benchmark on 3v4l reveals that it's consistently faster than
the previoust code on all PHP versions, taking something between
38% and 71% of the current runtime, with an average of 50%.
Follow-up: I368cd3b526edeb247a6ebda7420897a51357407d
Change-Id: I0b471dafd645aeb11ecdc68915c28aff93f809d9
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is an extremely hot function, appearing at the top or second in a
few XHGUI profiles I ran when sorted by self wall time.
We can micro-optimize by switching the substr() function call to check
the 0th character of the string.
In my benchmarking of 1,000,000 loops (see P14054), this went from a
total time of 784.20ms to 651.67ms.
A further optimization could remove checking whether the string is empty
but that would be a behavior change and while I'm pretty sure all API
keys are non-zero length, I'm not 100% sure.
Change-Id: I368cd3b526edeb247a6ebda7420897a51357407d
|
|/
|
|
|
|
|
|
|
|
|
| |
Huge `if` clause is almost always bad. It impacts code readability and
requires a lot of scrolling (both mental and physical) to see the `else`
block and make sense of everything together.
Use early return to improve the code readability. The functionality of
the logic remains the same.
Change-Id: Ibdb706cd35a5fbd219c042a882326c5b21cd18ba
|
|
|
|
|
|
|
|
|
|
| |
There’s no need for setValue() to raise an error if the old and new
value are identical.
Bug: T160504
Bug: T202725
Bug: T271105
Change-Id: Icfa6c181666b2293494c67875777d3de8816587a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PHPStorm can use custom folding regions defined in either the
VisualStudio style or the NetBeans style. The VisualStudio style is more
pleasing to the eye and also works as a vim foldmarker. So get rid of
the previous vim foldmarkers, and use region/endregion.
region/endregion need to be in a single-line comment which is not a doc
comment, and the rest of the comment is used as a region heading (by
both PHPStorm and vim). So to retain Doxygen @name tags, it is
necessary to repeat the section heading, once in a @name and once in a
region. Establish a standard style for this, with a divider and three
spaces before the heading, to better set off the heading name in plain
text.
Besides being the previous vim foldmarker, @{ is also a Doxygen
grouping command. However, almost all prior usages of @{ ... @} in this
sense were broken for one reason or another. It's necessary for the @{
to be in a doc comment, and DISTRIBUTE_GROUP_DOC doesn't work if any of
the individual members in the group are separately documented.
@name alone is sufficient to create a Doxygen section when the sections
are adjacent, but if there is ungrouped content after the section, it
is necessary to use @{ ... @} to avoid having the Doxygen group run on.
So I retained, fixed or added @{ ... @} in certain cases.
I wasn't able to test the changes to the trait documentation in Doxygen
since trait syntax is not recognised and the output is badly broken.
Change-Id: I7d819fdb376c861f40bfc01aed74cd3706141b20
|
|
|
|
| |
Change-Id: I78338d48530f098fa5d36fe84cfd45c0d160f444
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.
Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.
Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
|
|
|
|
| |
Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
|
|
|
|
|
|
|
| |
This was deprecated in 1.25, no code doing that:
https://codesearch.wmflabs.org/search/?q=new%20%5C%5C%3FApiResult%5C(%5Cs*(new%7C%5C%24)&i=nope&files=&repos=
Change-Id: I21fff4fa66478d2eada13e2ff801bcd6a58b865a
|
|
|
|
|
|
| |
Align the doc stars and normalize start and end tokens
Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
|
|
|
|
|
|
| |
Spotted by phan.
Change-Id: Ifca5e15a1360008b5d91e1b6f483da8e0367819a
|
|
|
|
|
|
|
| |
Brought to you by vim macros.
Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
|
|
|
|
|
|
| |
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff
Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
I searched the entire codebase for 'const' and looked for things
that looked suspiciously like manually calculated bitfield unions.
As of PHP 5.6, we can have them calculated automatically when
defining constants.
Change-Id: I7d971d1a63f8916db2f8f6c053c7dd0a13add92d
|
|
|
|
|
|
|
|
|
| |
And auto-fix all errors.
The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.
Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
|
|
|
|
|
|
|
| |
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.
Change-Id: I49e2a10350a328a8572fcedd44012751a29e1068
|
|
|
|
|
|
|
|
| |
This allows for removing $wgContLang from many API modules where it was
only used to call $wgContLang->formatExpiry() in a way in which the
results don't actually depend on the language.
Change-Id: Ib0f25f288b9b87d2e4131297c552e5971696db87
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
API warnings and error messages are currently hard-coded English
strings. This patch changes that.
With a few exceptions, this patch should be compatible with non-updated
extensions:
* The change to ApiBase::$messageMap will blow up anything trying to
mess with it.
* The changes to the 'ApiCheckCanExecute' hook will cause a wrong
(probably unparsed) error message to be emitted for extensions not
already using an ApiMessage. Unless they're currently broken like
Wikibase.
Bug: T37074
Bug: T47843
Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898
Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec
Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6
Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed
Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c
Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b
Depends-On: I535344c29d51521147c2a26c341dae38cec3e931
Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All deprecated ApiResult methods are removed. These have been deprecated
since 1.24 or 1.25, and the only users remaining in Gerrit are wrapped
in backwards-compatibility checks and so should not be being called.
ApiBase, ApiFormatBase, ApiMain, and ApiQuery methods for generating the
pre-Ib14c00df help text are removed. Nothing has called these for a long
time, and only Flow implemented them in any way. Deprecated methods for
providing the text for such help, such as getDescription(), haven't been
removed yet, though, since some extensions still call some of them.
Change-Id: I3ca7c98174b4a3f6f67f2b023e0f4446637e7a84
|
|
|
|
| |
Change-Id: I5888d617ab9aebe5ae1fe4da6873639a81f60fc3
|
|
|
|
| |
Change-Id: I226ce6bcb5bbf6ed3802042dd2790f85617833e1
|
|
|
|
| |
Change-Id: Ia6bb3944c05b056677979035cb38385554ee8a4f
|
|
|
|
|
|
| |
Just like commit f86a5590aae7fbe6d9b8a3d129c7a04a11a27579
Change-Id: Ic9d08bca6524d6bb4baf5170c081ad0f3d738e28
|
|
|
|
|
|
| |
All of core uses implode() consistently now.
Change-Id: Iba50898c64c43f356d1caf8869f484e90d9ff651
|
|
|
|
| |
Change-Id: I972e296f4820f78f5dfcecc27bc4912ca84a3178
|
|
|
|
|
|
|
|
|
|
| |
Per wikitech-l consensus:
https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html
Notes:
* Disabled CallTimePassByReference due to false positives (T127163)
Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
|
|
|
|
|
|
|
|
|
| |
Sigh, PHP. You allow for an array to have string "1" as a key (e.g. when
casting from object to array), but then you do everything wrong when
trying to deal with it.
Bug: T123663
Change-Id: I49f09901a69aab39ca1519bbe9e41267bf9a1216
|
|
|
|
|
|
| |
Added a unit test to highlight the problem
Change-Id: I5d4bcb755bd3686a92e7b111946a49892699729f
|
|
|
|
| |
Change-Id: I9cb6f041a0242c3257a24aac6538f7fbbca60cb0
|
|
|
|
| |
Change-Id: I4b1b20b4126735cb32a80e473fe48d523bcb24d1
|
|
|
|
|
|
|
|
| |
It was kept around in the ApiResult rewrite because Wikibase was
(mis)using it as an "XML mode" flag.
Bug: T96596
Change-Id: Ic8259649c8cb0cce0444c907607c36d96fb2eb7e
|
|
|
|
| |
Change-Id: I095ba37ceb150fcb7bee9df80201437c78426938
|
|
|
|
|
|
|
|
|
|
|
| |
Two bugs here:
* Setting NO_SIZE_CHECK also bypassed validation
* ApiResult::valueSize() didn't handle ApiSerializable, which is fixed
by defining that the value needs to be passed through
ApiResult::validateValue() first.
Bug: T111796
Change-Id: I7c00d8ee53364a26f8f63f82a4d83b92baf5383e
|
|
|
|
| |
Change-Id: I52e36f1ecbef8e8c18066d3dde84bda086ef9808
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows for merging the KVP key into the value for the alternative
output format. Specifically,
{ "key": { "foo": "bar" } }
can now be turned into
[{ "name": "key", "foo": "bar" }]
instead of
[{ "name": "key", "value": { "foo": "bar" } }]
Change-Id: Ie1f9235893dbbcd2948c46e0356360b5635a3ddd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds the 'modules', 'jsconfigvars', and 'encodedjsconfigvars' props
to action=expandtemplates, that output the modules and Javascript
configuration variables added to ResourceLoader by extensions and
parser functions, in the same way action=parse does.
This is needed by Parsoid to correctly include all modules used by
parser functions.
Based on I5c3ccb25385e57633639bb0c7e6f562eb58b05a2 by @Jackmcbarn.
Bug: T69540
Change-Id: Iaf58c66c987a318c0dd1ee2b81774106c40e7561
|
|
|
|
|
|
|
| |
Shouldn't happen, but if it does let's not log a bunch of warnings.
Bug: T98185
Change-Id: I7e626ab2c829633a84f3db0358080011baf5d9f2
|
|
|
|
|
| |
Bug: T97490
Change-Id: I5301a615a992b090000a59f86e13b9f78dcd5aec
|
|\ |
|
| |
| |
| |
| |
| | |
Bug: T96596
Change-Id: Ib0068b4cd3cc9c1765d82a8ade7b3d435c57f1d5
|
|/
|
|
|
|
|
|
|
|
|
| |
Nothing in this patch should result in changed output for format=json or
format=php except as noted in RELEASE-NOTES-1.25, and changed output for
format=xml should be similar or cosmetic. However, other code accessing
the result data directly may need to be updated.
Bug: T87053
Bug: T12887
Change-Id: I3500708965cb8869b5aed1543381aad208dadd13
|
|\ |
|
| |
| |
| |
| |
| |
| | |
Because 'nobool' is what's actually used in the code.
Change-Id: Ia846e6abbf973d3b060a509e0216023a8278d7f6
|
|/
|
|
|
| |
Bug: T96422
Change-Id: Ib797af8d86cf33c56b023e53240dc1cd0bad2fb0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
|