Commit graph

75 commits

Author SHA1 Message Date
Siebrand Mazeland
7489b1e8df Explicitly declare ApiFormatXml::addXslt() protected
Only used in private/protected context.

Change-Id: Ic44d6e70e89c3d229d79aa08d2a0092609e7d62e
2016-03-08 16:12:26 +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
Brad Jorsch
f0207e8ca6 Add Special:ApiSandbox
Like Extension:ApiSandbox, but rewritten to use OOJS-UI and to add many
long-requested features.

Bug: T89386
Bug: T92893
Bug: T98457
Bug: T98083
Bug: T89229
Bug: T66008
Bug: T50607
Bug: T47811
Bug: T38875
Bug: T36962
Bug: T34740
Change-Id: Ic42a6c5ef54b811cd63cfef2132942b27a626fe5
Depends-On: I85c0eedcd31a0e419d8055eca0d9cb1ba872ae62
Depends-On: Ic85ff4abbbcd2076ebf5cdfaa0e95e98878e2308
2016-02-03 11:13:59 -05:00
Brad Jorsch
f9c1bfa594 API: Finish killing "raw mode"
It was kept around in the ApiResult rewrite because Wikibase was
(mis)using it as an "XML mode" flag.

Bug: T96596
Change-Id: Ic8259649c8cb0cce0444c907607c36d96fb2eb7e
2015-09-17 13:51:45 +00:00
addshore
5cb3b0467d Remove use of deprecated utf8ToCodepoint in ApiFormatXml.
This usage, in ApiFormatXml, is the final usage
in core.

Change-Id: Ibd926863d323e6d6d1b2cc5fd5f5f0e1aef8529d
2015-06-29 18:37:33 +00:00
umherirrender
d8821f2b0b Fixed spacing
- Removed space after casts
- Removed spaces in array index
- Added spaces around string concat
- Added space after words: switch, foreach
- else if -> elseif
- Removed parentheses around require_once, because it is not a function
- Added newline at end of file
- Removed double spaces
- Added spaces around operations
- Removed repeated newlines

Bug: T102609
Change-Id: Ib860222b24f8ad8e9062cd4dc42ec88dc63fb49e
2015-06-17 20:22:32 +00:00
Brad Jorsch
4bbd86a859 API: Also mangle indexed tag names in format=xml
I had thought no one would be silly enough to set invalid tag names for
ApiResult::setIndexedTagName(), since it's specifically *for* XML tag
names. Apparently I was wrong.

Bug: T97599
Change-Id: I62ad832b1d8c23a275e5c67160f0b1febe5f3454
2015-04-30 09:02:17 -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
Petr Kadlec
51fea41c70 Fix copy/pasto in API help and a typo in message name
* The help for [[Special:ApiHelp/xml]] used the same copypasted
apihelp-json-param-callback message for both parameters instead of the
correct ones for those parameters.
* The message name in en.json and qqq.json was truncated, so that it did
not correspond to the parameter name. I presume this was unintentional
and not some strange limitation.

Change-Id: I666b2fd6511f08bccc9f05739bab68d7675ef5c6
2014-10-15 22:52:40 +02:00
Brad Jorsch
d25cb99202 API: Clean up and internationalize pretty-printed output
The syntax highlighting applied to the XML format is not all that great,
and applying it to other formats is just wrong. Instead of doing it
ourselves, let's just add a hook and let Extension:SyntaxHighlight_GeSHi
do it for us.

But for that to work, we have to add RL support to the pretty-printed
output, which means OutputPage. At the same time, lets internationalize
the header.

Bug: 65403
Change-Id: I04b1a3842abdf1fb360c54aa7164fc7cd2e50f4b
2014-10-13 16:17:37 -07:00
Jackmcbarn
e684a21782 Restructure output of ApiExpandTemplates
Create a new output format of ApiExpandTemplates and deprecate the old
one.

Change-Id: Id12cbe4aeaa39bea382cf3b78810589bb1c9368f
2014-06-03 16:25:08 -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
umherirrender
e965a1459d treat true as empty string, skip false in xml format
The xml format gives a empty attribute to indicate a true, for example
top="" or anon="". The new meta=filerepoinfo module gives natural
booleans to the xml formatter, which than will converted to strings,
that gives a empty attribute for false and a attribute with the value
"1" for true attributes. Change this behaviour in xml formatter to allow
the natural booleans on the other formats like json, which support that
better than xml.

Bug: 59953
Change-Id: Iedf43aae2e624e8e15c9cf102d24b8365110164a
2014-01-19 10:42:47 +01: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
a60643422b Update formatting on more API classes
Change-Id: I1e6325b628359a557ceaa1e1ae30043aa5fc1402
2013-11-14 18:11:13 +00:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
Kevin Israel
9d10834864 ApiFormatXml: remove broken xmldoublequote param
r55641 was a refactoring of ApiFormatXml::recXmlPrint() that added
a $doublequote parameter, yet the parameter was not actually passed
along in recursive calls, rendering the formatter's xmldoublequote
parameter useless.

XPath support was the sole reason this parameter was added. It was
argued that because in the XPath 1.0 grammar, a Literal is:

    '"' [^"]* '"' | "'" [^']* "'"

it is not possible to match attribute values that contain both an
apostrophe and a double quote.

However, conforming XPath implementations include a concat() function
that can be used to work around this limitation. Furthermore, XPath 2.0
allows escaping a double-quoted " as "" (and a single-quoted ' as '').

Because there was no Bugzilla report (other than mine) filed in the
last 3-1/2 years, and working around the XPath flaw is possible, I
think it's safe to remove the parameter. The worst that could happen
is that a not-very-robust API client chokes on the "Unrecognized
parameter" warning.

Bug: 46626
Change-Id: I9a4d8c13b78ffd2634d03c8c8b4bbeff69f4bc08
2013-04-10 00:32:43 +00:00
umherirrender
3dd97bf651 Use gettype only for debugging text
Changed some gettype == 'array', 'object' and similar to is_array,
is_object or similar

Output of gettype must not stable across versions and it is slow

Change-Id: I07bfc063b03be1200989dd6facee66b35ab51d77
2013-03-15 22:50:42 +01:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
Antoine Musso
b2fba3f27f api: remove duplicate __contruct calls
For historical reasons, all our API class had a dummy __construct which
simply calls their parent constructor.  This patch removes all such
occurences to save out some bytes.

Change-Id: I667955d7821f780fc5ce23823d74dedb1729b9fa
2013-01-29 09:38:17 +01:00
Petr Onderka
deaffd8262 Don't return invalid XML from paraminfo when one of parameter values is null
The module setglobalaccountstatus currently has null
as one of the values for one of its parameters,
which causes paraminfo to return invalid XML (unclosed tag).

I believe values shouldn't be null, but paraminfo
shouldn't return invalid XML even when they are.

This problem occured only with values that go into element content,
those that are rendered as attributes were already fine.

This change modifies ApiFormatXml, so it affects all modules.

Change-Id: Ibf5c329e7bfa375b06f0976ebb9e449f2cb1c927
2013-01-24 11:39:05 +01:00
Yuri Astrakhan
503cd2f4ae (bug 35885) remove api version string and parameter
API was using SVN's version keyword which GIT does not support.
All related methods were either removed, or for those that
could have been used from extensions, emptied out.
api.php?version now shows unrecognized param warning.

Change-Id: I910ca1448ed2ed697ac19b17c486d130aa1d7e03
2013-01-18 12:41:18 -05:00
Antoine Musso
4f5d2386f3 escape HTML elements in docblock with double quotes
Doxygen choke on text enclosed by '<' and '>' since it tries to
interpret them as HTML or XML elements. This patch adds double quotes
in includes/api/*.php files around the two following strings:

 <Firstname>.<Lastname>@gmail.com
 <Firstname><Lastname>@gmail.com

Which becomes:

 "<Firstname>.<Lastname>@gmail.com"
 "<Firstname><Lastname>@gmail.com"

Tested locally, it prevents doxygen 1.8.0 related warnings.

Change-Id: I36d82eb3fd4989ee3ffc65b0b527b83711d1ba69
2012-07-15 22:15:45 +02:00
Antoine Musso
4a69fceb79 prettify documentation
Change-Id: Icfd267a94ac981b4c15e51add18c6d8ceb68454e
2012-07-10 17:18:20 +02:00
Liangent
69ebd8d7ce Add some more detailed info about the xslt param of format=xml
Change-Id: I77e1dcbdf3ff1d201a2346c5a397469b4fc21d74
2012-05-25 08:56:02 -07:00
Jeroen De Dauw
4544a78316 rem use of escapeLocalURL 2011-12-13 04:58:48 +00:00
Sam Reed
124f6229ac Followup r104445, swap the xmlnamespace url back to http:// 2011-11-28 20:04:40 +00:00
Sam Reed
53000baecf Oh noes, moar http:// -> https:// 2011-11-28 15:43:11 +00:00
John Du Hart
2e7d867478 Removed the 'eclipse helper' bit on top of every API module
It's a parctice that dates back to 2006 when the API was first written, and frankly isn't covered by the coding conventions. Same thing with the docblocks, they're all copypasted with some bits changed and don't even make sense if you look at them in the genereated code docs.
I don't feel that any of us depend on this anymore (get a better IDE), so in the inerest of consistancy it's time we said goodbye to it.
2011-11-16 00:17:26 +00:00
Brion Vibber
c9873a9230 Partial revert of r101912 -- restores r99315 'includexmlnamespace' parameter for API, but keeps the logic to keep that from clobbering alternate XML output formats with their own namespaces. 2011-11-04 01:31:15 +00:00
Brion Vibber
abb23bb7b9 * (bug 31878, bug 31542) Fix XML namespace output in API; removed now-unneeded includexmlnamespace parameter.
Any existing uses of includexmlnamespace should be ignored and harmless.

If output data already includes a specific default namespace as an xmlns attribute, it is now retained -- so for example the RSD API discovery module outputs the appropriate namespace instead of the generic API one.

Partial revert of r99135 which added the includexmlnamespace parameter as a temporary requirement to get the xmlns attribute included.

Followup to r88007 which added the xmlns originally, but in the wrong order so it overrode existing output data.
2011-11-03 23:14:58 +00:00
Mark A. Hershberger
03e69126c5 eol w/s 2011-11-03 21:22:34 +00:00
Bryan Tong Minh
504d37d6fc (bug 24781) The API will include an XML namespace if the includexmlnamespace parameter is set.
Partial revert of r88007, which adds the namespace unconditionally, since it breaks stuff as per the bug discussion.
2011-10-06 20:11:44 +00:00
Sam Reed
4065e65d03 Even more documentation in various files 2011-05-29 14:24:27 +00:00
Roan Kattouw
abaa9ae3f3 (bug 24781) Define XML namespace for API output. Also created the referenced URL on the cluster. 2011-05-13 16:34:36 +00:00
Sam Reed
6309c920dd Delete all the "API for MediaWiki 1.8+" comments
Add since to ApiQueryQueryPage
2010-12-22 20:52:06 +00:00
Sam Reed
ee40f73227 Remove some unused keys from foreach
Documentation tweaks
2010-09-25 16:56:03 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
Derk-Jan Hartman
921619b119 Correct the address of the FSF in some of the GPL headers
59 Temple Place -> 51 Franklin Street
2010-06-21 13:13:32 +00:00
Sam Reed
e55ed729c4 Mixture of things.
Couple of class comments

Normalisation of "." usage at end of lines (removed)

Normalisation of {prefix}parameter as per bug 23461
2010-05-11 22:30:18 +00:00
Jack Phoenix
c286869e38 API: fix copyright symbol, coding style cleanup, more braces 2010-02-23 18:05:46 +00:00
Sam Reed
d2d950d256 Start of blanket coverage of dieUsageMsg in getPossibleErrors
Only basic ones done.

Couple of other modules done manually
2010-02-13 00:09:05 +00:00
Bryan Tong Minh
843acd3aab (bug 19528) Revert 55749: "according to the XSLT 1.0 spec, the MIME type should be text/xml or application/xml. In XSLT 2.0, it is application/xslt+xml. Either way, text/xsl is wrong." The mime type text/xsl is the only one supported by all modern browsers. 2010-01-23 15:27:53 +00:00
Aryeh Gregor
3758769f0d stylize.php on API code
"I wouldn't object to stylizing the API code to bring it in line with
the rest of MW on principle, but I'm not gonna bother myself." --Roan
<http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60657#c5108>

If you're seeing this commit in blames, tell your blame tool to ignore
whitespace, e.g., git blame -w or svn blame -x -w.
2010-01-11 15:55:52 +00:00
Brion Vibber
ecf95fd877 Cleanup for r55641: call static function statically 2009-09-08 23:54:03 +00:00
Tim Starling
f4d32ce48b Fix for r53194: according to the XSLT 1.0 spec, the MIME type should be text/xml or application/xml. In XSLT 2.0, it is application/xslt+xml. Either way, text/xsl is wrong. 2009-09-02 08:05:47 +00:00
Roan Kattouw
3ac3ccaaf0 API: Refactor the XML formatter a bit so that ApiFormatXml::recXmlPrint() is now actually usable as a generic XML formatter 2009-08-27 21:15:20 +00:00
Bryan Tong Minh
e94bc9516d (bug 19528) Added XSLT parameter to API queries in format=xml 2009-07-13 21:37:49 +00:00
Roan Kattouw
a4d055587e API: (bug 18617) Add xml:space="preserve" attribute to relevant tags in XML output so overzealous XML parsers will leave whitespace in e.g. revision content alone 2009-04-29 13:12:27 +00:00
Roan Kattouw
bb81750f27 * API: (bug 17326) BREAKING CHANGE: Changing output format for prop=imageinfo&iiprop=metadata to something based on name/value pairs. This means we don't use parts of the metadata in attributes anymore, something that caused invalid XML to be output. For more info on the exact format, see the mediawiki-api mailing list
* Removed the spaces-to-underscores hack in the XML formatter
2009-02-03 16:25:50 +00:00