Commit graph

205 commits

Author SHA1 Message Date
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
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
2017-07-22 18:24:09 -07:00
Baha
036b9c4167 Make API documentation links language aware
Links generated by the API are now aware of the user's preferred
language and will show documents in that language if available.

To test, log in to mediawiki.org and set your language preference to 'es',
then on an MediaWiki installation with this patch view the generated
expanded API help at `api.php?action=help&recursivesubmodules=1&modules=main`.
Each link to documentation on mediawiki.org should take you to its
translated /es subpage, if one exists.

Bug: T104518
Change-Id: I339a1f3ae1bce9d759cf251899d57c32b1def91e
2017-04-05 11:08:25 -04:00
James D. Forrester
50e796e948 includes/api: Replace implicitly-Bugzilla bug numbers with Phab ones
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
2017-02-24 16:41:47 +00:00
jenkins-bot
30f2850124 Merge "API: Expose wfIsBadImage() in prop=imageinfo" 2016-12-14 16:07:53 +00:00
Kunal Mehta
3413839cb8 API: Expose wfIsBadImage() in prop=imageinfo
If iiprop=badfile is set, expose the wfIsBadImage() status as a boolean.
This is mainly intended for use by Parsoid, but could be useful for
other API users too. The context title can be set by using the
badfilecontextitle parameter.

Also be a little more paranoid and make sure wfIsBadImage() always
returns a boolean.

Bug: T148343
Change-Id: I3432ead92b8d2a17de5243285f2760fc39b501ae
2016-12-14 00:29:32 -08:00
Brad Jorsch
4e6810e4a2 API: i18n for warnings and errors
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
2016-12-06 10:20:48 -05:00
Ricordisamoa
e64035522d Fix and standardize Doxygen tags
* Use "@param datatype $paramname description" format

* String → string, Integer → int etc.

* @return $string → @return string

Change-Id: I860d222382cb4c5699d313b0600bd22503c8c385
2016-04-30 12:10:17 +02:00
Derk-Jan Hartman
6e74735369 API: Allow subclassing ApiQueryImageInfo
execute() references the static self::getInfo, which therefor cannot be
overriden by the subclass ApiQueryVideoInfo. Preferably, we'd fix the
implementation to not require this subclassing, but this will make
that transition easier. Use late static binding to make sure the
subclass implementation can be used.

Change-Id: Iab2d01abb9f9b3b799123d8ee344ea139e476576
2016-04-17 22:02:20 +02:00
jenkins-bot
2aff530dfb Merge "Use single quotes in API where possible" 2016-03-08 17:03:24 +00:00
Siebrand Mazeland
bc0ae710e3 Use single quotes in API where possible
Change-Id: I972e296f4820f78f5dfcecc27bc4912ca84a3178
2016-03-08 17:27:00 +01:00
Siebrand Mazeland
5433a5e998 Explicitly declare ApiQueryImageInfo::getInfo() public
Used as such in core and TimedMediaHandler.

Change-Id: I0ec90d2cf9ae4cca31e93522e0f68e4d55a7bcfe
2016-03-08 16:16:13 +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
victorbarbu
df622c4195 Provide short URL to file description page in imageinfo API
Bug: T122439
Change-Id: I0f00b986e6095bdb9b8d6af6fbc5b01995227e02
2016-01-12 15:48:52 +02:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Reedy
32ff1f4c47 Remove various unused variables
Change-Id: I4b1b20b4126735cb32a80e473fe48d523bcb24d1
2015-11-07 21:22:17 +00:00
Reedy
9335469cf3 Fix casing of function calls in API
Change-Id: I44b343568e5713118c41f29a73e112162dd3e635
2015-11-07 21:10:23 +00:00
Siebrand Mazeland
0fdb0ce284 Fix most PHP CodeSniffer warnings in includes/api
Change-Id: I01bb3e4c96d6034a5b6c18728bb0574c710ea9db
2015-09-28 14:24:52 +02:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Kunal Mehta
5a078a7215 APIQueryImageInfo: Set META_BC_BOOLS for 'value' in 'metadata' block
The 'value' property can be a boolean, which was previously output as a
raw boolean.

Bug: T103781
Change-Id: I788f13f33885b7c8f694470e44478907f28cfbfd
2015-07-08 15:52:52 -07:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
RobinHood70
15ecc5a93a Update getHelpUrls() for reworked mw.org API pages
Community members restructured the mediawiki.org API pages, e.g.
the meta allmessages query submodule is no longer in the catch-all
https://www.mediawiki.org/wiki/API:Meta?oldid=1408361#allmessages_.2F_am
but its own https://www.mediawiki.org/wiki/API:Allmessages

The links in the generated API help, e.g.
https://www.mediawiki.org/wiki/Special:ApiHelp/query+allmessages,  are no
correct. They're not 404s but they don't take you directly to the
relevant page.

This patch set fixes the getHelpUrls() URLs (and does nothing else).
I tested them all.

Thanks RobinHood70!

Change-Id: Icea94abdd22d1ad468172642a21641e7c5ce2046
2015-05-04 08:15:54 +00:00
Brad Jorsch
beab6b009e Change API result data structure to be cleaner in new formats
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
2015-04-20 17:49:37 -04:00
Brad Jorsch
1c57794e37 API: Overhaul ApiResult, make format=xml not throw, and add json formatversion
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
2015-04-10 16:57:15 -04:00
Brad Jorsch
d29f4ff2e6 API: Allow for documenting individual values of 'prop' parameters
There are cases where the list of values for a 'prop' parameter may be
manipulated by a subclass or by a hook function of some sort. Rather
than requiring the subclass/hook to completely replace a monolithic i18n
message, let's add the possibility of separate messages for each value
in the list.

Bug: T77930
Change-Id: I0bb061c62ebeef125062460e26306c88390f7b31
2014-12-22 16:46:44 -05:00
Brad Jorsch
f62bc7536e API: Fix access on getExamplesMessages
ApiBase declares it protected, but for some reason I had made it public
in all subclasses.

Change-Id: I8a50d4f47e66c7f09137968d3941dc5cdc1d28e4
2014-10-29 11:15:27 -04:00
Brad Jorsch
ad225f501c API: Internationalize all remaining core API modules
This also adds some new ApiBase::PARAM_* constants to generate more
helpful help, and a method to override the default description message
for the use of ApiDisabled and ApiQueryDisabled.

Bug: 71638
Change-Id: Ic0c3d232e0498d58a043037e2e0c6f0b1c3edad3
2014-10-20 16:56:35 -04:00
Brad Jorsch
07e40d04c6 API: Add ApiPageSet accessors for just good and missing titles
ApiPageSet::getAllTitlesByNamespace is fine when that's what you want.
But in all existing uses in core, it's not what's actually wanted.
* ApiQueryBacklinksprop can generate wrong ORDER BY because it considers
  redirect and invalid titles that it doesn't acutally query.
* ApiQueryCategoryInfo raises a fatal error with category redirects.
* ApiQueryDuplicateFiles and ApiQueryImageInfo will add information for
  redirects, leaving them missing the standard data and missing from
  indexpageids.

What all these need is really something along the lines of
"ApiPageSet::getGoodAndMissingTitlesByNamespace". So let's add that,
plus a few similar methods for good measure.

Bug: 71337
Change-Id: I3a205057edcbc303393718e1c8bfb1f1b1f95323
2014-09-26 11:25:36 -04:00
jenkins-bot
3e0056ef43 Merge "Do not require iiurlwidth when getting thumbnails." 2014-09-18 17:48:00 +00:00
Brian Wolff
84d8b18bd9 Add duration field in query=imageinfo&iiprop=dimensions
If the file has a duration (e.g. an audio or video file), include
it in the list of dimensions returned. Do not include anything
for still media (normal pictures).

This affects both query=imageinfo and TMH's query=videoinfo.

Bug: 55941
Change-Id: If172a1cbaca08bff2eb709f6c829985b28b0200d
2014-09-18 13:38:36 -03:00
Brian Wolff
542cbb8b40 Do not require iiurlwidth when getting thumbnails.
Some file types might not have a specific width/height. As an
example, TimedMediaHandler can specify thumbnails that are
"mid" sized instead of specific width. The requirement for
iiurlwidth was breaking some edge cases with ForeignAPIRepo
and TimedMediaHandler (Specificly with ?embedplayer=yes).

Do not require a width, but also verify that thumbnail parameters
are ok by running through normaliseParams (Formats that require
a width make this function return false if none is specified).

Change-Id: I8bb4c26db56c814ddfbd3e53ca98d05378c2a0bd
2014-09-18 13:29:27 -03:00
Brad Jorsch
f0a6435f3b API: Remove action=paraminfo 'props' and 'errors' result properties
The format for 'props' was never specified and the list for 'errors' is
impossible to keep updated when considering that many errors come from
MediaWiki backend code and extension hook functions. And since there
doesn't seem to be any real use case for either of these, let's just
kill both of them instead of wasting effort on trying to fix them.

Note that neither getResultProperties nor getPossibleErrors are called
from any extensions in gerrit, and none of the other deprecated methods
are called outside of the implementations of those two methods. Removing
the obsolete methods is left to the maintainers of the extensions, as
keeping them hurts nothing and is needed to maintain compatibility with
earlier versions of MediaWiki.

Change-Id: Ie11a401d60c834059fbf1b5625ca8ea093b3337c
2014-08-07 16:51:19 +01:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
Reedy
e48ecbc524 Switch API to use Config classes
Only done where globals are config (so not $wgParser, $wgContLang etc)

Change-Id: Ic39cdd858cfb9096a2bc09618f97e64270d76f13
2014-06-15 23:56:38 +01:00
Thiemo Mättig
23632a4ecd Use precise ApiMain/ApiQuery type hints in all API modules
Which type is used depends on the ApiModuleManager responsible for
the API module. There are two managers, one in ApiMain and one in
ApiQuery. Both contain a list of API modules they instantiate.
Both use $this as the first parameter in the constructors of the
individual modules. There is no other regular way to instantiate the
modules, so we know the type must either be ApiMain or ApiQuery.

The lists don't intersect.

I would have prefered the naming scheme $mainModule for ApiMain
modules and $queryModule for ApiQuery modules but since this
doesn't add much I left the shorter variable names untouched.

Change-Id: Ie6bf19150f1c9b619655a06a8e051412665e54db
2014-05-16 11:07:23 -04:00
umherirrender
e63299d208 Fixed some @params documentation (includes/api)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I758fa4ad80ac95e2ddd3770bcb9b7d2e57ec34ea
2014-04-18 13:55:36 +00:00
addshore
719d7a2f03 Add final period to API module descriptions
Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
2014-03-10 09:04:08 +00:00
Siebrand Mazeland
0cef781886 Fix CodeSniffer errors and warnings
Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28
2014-02-05 11:20:17 +01:00
Brian Wolff
b06d5ed078 Follow-up I49b7d8a - Add api module for common metadata
Change-Id: I0d957891e0778ba0454f6fecb06524211506f6b9
2014-01-23 22:06:19 +00:00
Brad Jorsch
48de797fbd Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
  ApiQueryWatchlist will now return entires where fields have been
  revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
  ApiQueryContributions will now return field values in addition to the
  "hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
  "suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
  if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
  entries where the user or action are revision-deleted if the
  requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
  'hideuser' to determine when to show contributions where the username
  was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
  hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
  the "content" prop along with the "tags" prop or "drtag" parameter
  would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
  ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
  $opts, and now may have an option to indicate the user to use for
  RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
  checking whether wlprop=patrol is allowed, rather than using the
  wlowner's rights.

Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2014-01-17 11:43:22 -05:00
Brad Jorsch
7b9b91ead5 API: Add iiprop=canonicaltitle
With recent changes to the filerepo backends, prop=imageinfo will now
return information for the target file when file redirects are queried.
To make this more transparent to clients, add an iiprop to return the
canonical title for the imageinfo data.

Change-Id: I62e368ffe09512f1af6677994f1ccca776b97651
2013-12-09 11:25:52 -05:00
jenkins-bot
0fe5700a8a Merge "Address errors and warnings in CodeSniffer in api/" 2013-11-18 18:28:22 +00:00
Siebrand Mazeland
4c3bc3f865 Add/update/remove incomplete/incorrect documentation
Change-Id: I3c2c7f61d9a579ad794ce7b564ccc8a7cfb9b6fc
2013-11-17 21:53:34 +00:00
Siebrand Mazeland
d026e1a403 Address errors and warnings in CodeSniffer in api/
Change-Id: I06de371393d50eada33154626874b106d814642b
2013-11-17 16:52:24 +01:00
Siebrand Mazeland
a2dc799364 Fix a few more CodeSniffer errors and warnings on some API classes
Change-Id: I119be629d8c8811d08413751bcffc0ce403cc2bd
2013-11-15 10:33:49 -08:00
Brad Jorsch
8441b57d82 API: Allow filtering keys in iiprop=extmetadata
Requesting iiprop=extmetadata can return a *lot* of meta data, when the
client may only be interested in certain keys. This adds a
"iiextmetadatafilter" parameter to allow the client to indicate which
keys it cares about.

Change-Id: Ie2185ec285e40359fffab4932bff8cab16071a53
2013-11-14 14:27:33 -05:00
Siebrand Mazeland
d45bb99e8c Yet more formatting updates for yet more API classes
Change-Id: Iaa1cfaaffc7c55bb7670dfbff3f063cf22434f09
2013-11-14 18:15:00 +00:00
Alexandre Emsenhuber
2d0e98df31 Change mode of non-executable files back to 0644
Change-Id: Ib9dce1eea8c34986364aabed7f1770101c72c649
2013-11-05 08:13:32 +01:00
tgr
042f1c77a6 Add language handling to imageinfo/extmetadata API
Adds options to return metadata in all available languages, or in
a single selected language.

Change-Id: I78f096318904a08abd317a5ed3f74ee33d3289cb
2013-10-29 17:49:19 +00:00