Commit graph

21 commits

Author SHA1 Message Date
Brad Jorsch
f389d14b38 API: Deprecate diff and parse parameters in ApiQueryRevisionsBase
The 'rvdifftotext', 'rvdifftotextpst', 'rvdiffto', 'rvexpandtemplates',
'rvgeneratexml', 'rvparse', and 'rvprop=parsetree' parameters to
prop=revisions are deprecated, as are the similarly named parameters to
prop=deletedrevisions, list=allrevisions, and list=alldeletedrevisions.

Use action=compare, action=parse, or action=expandtemplates instead.

Bug: T164106
Change-Id: I6deaf550a4b96f0d35488bea7bfd6637d6d1c36a
2017-06-16 12:01:44 -04: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
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
33ba3bea02 Use Elvis operator where possible in API
Change-Id: I0a26c04cf2ded2c1bd74d8dabd131ae8e20117f3
2016-03-08 16:10:23 +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
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Reedy
9335469cf3 Fix casing of function calls in API
Change-Id: I44b343568e5713118c41f29a73e112162dd3e635
2015-11-07 21:10:23 +00:00
Brad Jorsch
05ff357a42 API: Log all deprecated parameter uses to api-feature-usage.log
Some were being logged, and some weren't. Let's log them all
automatically when PARAM_DEPRECATED is processed, instead of requiring
each module to manually log them.

Bug: T117569
Change-Id: Ia38aeeccd0b9857b12b28914f509284483fbcca8
2015-11-03 12:23:00 -05:00
jenkins-bot
376879ee06 Merge "ApiBase::PARAM_DFLT => null is the default anyway" 2015-10-26 19:02:33 +00:00
Matt Russell
a6a6d55c53 Add pst option to API difftotext
Adds the option difftotextpst to ApiQueryRevisionsBase.php, which will perform a
pre-save transform on the supplied text, before diffing it against the
requested revision.

Bug: T53155
Change-Id: Ia480e8cd4ceeeb0b2812dc8ec96650adb83c03af
2015-10-21 14:24:57 +00:00
Thiemo Mättig
3ecd418501 ApiBase::PARAM_DFLT => null is the default anyway
Change-Id: Ic3deeb6b3d7cacbdb85da9ba3cb19051c1182b8f
2015-10-05 10:56:32 +02:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
umherirrender
446b83bd18 API: Use message-per-value for apihelp-query+revisions+base-param-prop
Use message-per-value for message
apihelp-query+revisions+base-param-prop to allow smaller strings
for translation and to add a parameter for the contentmodel for
prop=parsetree, as already done for action=parse&prop=parsetree.
Each prop in a message also will show up a new parameter on the help
page without the adjust of the translation (but than in english instead
of fully skip it).

Change-Id: I8aaa061cb59ec788f8f8e09e8088ba1064e3aa1e
2015-07-03 05:53:06 +00:00
umherirrender
7b52c1cb4f API: Deprecate generatexml of modules revisions/deletedrevisions/parse
Deprecate 'generatexml=' by adding 'prop=parsetree' to revisions,
deletedrevisions and action=parse.
'generatexml' of action=expandtemplates is already deprecated and
replaced by 'prop=parsetree'.

Reason: Api parameter to control the output of a module usually gets
added as type to prop=, not added as new parameter. New parameter
usually used as input parameter for the module.

For revisions and deletedrevisions this allows to get the parsetree
without getting the whole content (makes the result smaller, when just
one is needed)

Change-Id: I7403110d7bd07e9eb2a10e1b398d97f0f40298be
2015-06-30 20:48:30 +02: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
Ricordisamoa
4ece7f53aa Revision: mark getRaw*() methods as deprecated
Revision->getRawUser()
=> Revision->getUser( Revision::RAW )

   Revision->getRawUserText()
=> Revision->getUserText( Revision::RAW )

   Revision->getRawComment()
=> Revision->getComment( Revision::RAW )

The body of Revision->getRawUserText() has been moved
into Revision->getUserText().
Every usage has been replaced.

Change-Id: Ic6fbfbc0507dcf88072fcb2a2e2364ae1436dce7
2015-01-18 06:57:56 +01:00
umherirrender
c0151eec5f Fix case of various newFromID/newFromId functions
User::newFromID -> User::newFromId
Revision::newFromID -> Revision::newFromId
RecentChange::newFromID -> RecentChange::newFromId

WikiPage::newFromId -> WikiPage::newFromID
Title::newFromId -> Title::newFromID

Change-Id: I310f26653613951e9b21ce915a92d205a87937f1
2014-12-10 19:40:27 +00:00
umherirrender
4b99ac91bc Refactor content fetch condition in ApiQueryRevisionsBase
Use a member variable to make the ifs easier to maintain.

Change-Id: I535740094708c563298a8b8d34027519d3900758
2014-11-10 18:50:36 +01:00
Brad Jorsch
991de897e4 API: Split list=deletedrevs into prop=deletedrevisions and list=alldeletedrevisions
list=deletedrevs has always been an odd one: it pretends to be a prop
module sometimes in taking titles from ApiPageSet, but when the pageset
supplies no titles it acts like a list module. This causes problems
such as bug 71389, and makes the whole thing unnecessarily confusing.

The solution is to split the "prop" and "list" aspects into separate
modules: prop=deletedrevisions when input should come from ApiPageSet
and list=alldeletedrevisions when not.

At the same time, let's take advantage of the situation to clear up some
other bugs. And let's share the revision-formatting code with
ApiQueryRevisions instead of partially reimplementing it.

Bug: 23489
Bug: 27193
Bug: 44190
Bug: 71396
Bug: 71389
Change-Id: I3e960d5c655bc57885d6d4ee227e67104808add7
2014-11-04 15:02:03 -05:00