Commit graph

9 commits

Author SHA1 Message Date
Thiemo Kreuz
32a429e8c4 tests: Prefer assertSame() when comparing the integer 0
assertSame() is guaranteed to not do any type conversion. This can be
critical when acciden tially comparing, for example, 0 to 0.0.

Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525
2019-09-19 15:35:23 +00:00
Umherirrender
91fd689add Fix use of GenderCache in ApiPageSet::processTitlesArray
Title::getPrefixedText was called before the GenderCache was set up,
which lazy loads the cache for each title,
resulting in one query per user title

Splitted the foreach to fill the cache at a better location

Added a test for ApiPageSet to test that the gender cache is filled

Bug: T200238
Change-Id: I7972dd1bf3731a92328caab20e70d7b9b82c1f7c
2019-09-09 19:54:07 +00:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Kunal Mehta
2c2dc593d2 Add @covers tags API tests without them
Change-Id: Ida0f954cb0a44719af3a3d0c6bda4587c9ca42b6
2017-12-27 17:50:06 +00:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Brad Jorsch
2338fe08c1 ApiPageSet: Follow RedirectSpecialArticle redirects
For example Special:MyPage, Special:MyTalk, and Special:MyLanguage.

Don't follow other redirect special pages like Special:MyContributions,
though, because the following only really makes sense when the redirect
is to an article.

Bug: T145541
Change-Id: I8c8065552ed128017887e48285e359def8bd3cd3
2017-03-08 16:54:01 -05:00
Brad Jorsch
087e25021b API: Warn when input parameters are normalized
If a client submits data that is not NFC-normalized Unicode or that
contains C0 controls other than HT, LF, and CR, it gets normalized before
the API ever sees it. Which can lead to difficult-to-handle bugs when,
for example, a title is subject to normalization so the client can't
find the specific title it submitted anywhere in the response (T139130).

This patch does two things:
* Detects when normalization was applied to an input value (at the
  MediaWiki level, anyway; if PHP or earlier does it we're just out of
  luck) and add a warning to that effect.
* For ApiPageSet's 'titles' parameter, split into the individual titles
  and add them to the 'normalized' list in the response. This requires
  encoding the pre-normalized strings to avoid ApiResult's own
  normalization.

Bug: T29849
Bug: T144071
Change-Id: I215fd3edd7a5e1b45292e60768bf6dd5ad7f34de
2016-08-29 15:00:45 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
Erik Bernhardson
1ded833de1 Implement ApiPageSet::setRedirectMergePolicy()
This allows generator implementations to define how generator data
about a redirect gets merged into the redirect destination.  This
does not change any defaults, only modules that explicitly set a
merge policy will have a change in their results.

This functionality is initially used for the search api modules to
retain search positions within the final result set.

Bug: T92796
Change-Id: If2f49e0fc3176288c95e870240754ee320a6bf91
2015-10-08 11:36:02 -07:00