Commit graph

2420 commits

Author SHA1 Message Date
Aaron Schulz
85f3f3d7b6 Merge "Updated result properties in paraminfo API" 2012-07-21 09:09:02 +00:00
Aaron Schulz
33c3df80a7 Merge "Revert "Do not show empty categories with list=allcategories"" 2012-07-21 09:07:36 +00:00
umherirrender
06166e334a (bug 38190) Add "required" flag to some token params
action=block/action=unblock can not have the token required because when
using the gettoken param, the token param can not set.

Change-Id: I15317f16c06f150d29c1b17de76f41a6cfa84820
2012-07-20 15:45:51 -07:00
Brad Jorsch
5dc1a63f20 (bug 30836) API siteinfo specialpagealiases should not return nonexistent special pages
Some special pages are conditionally registered (e.g.
Special:Popularpages only exists when $wgDisableCounters is false), or
sometimes an alias exists for a special page that does not. The API
should probably not return entries for these from
meta=siteinfo&siprop=specialpagealiases.

This also fixes bug 38464 correctly, rather than blindly reverting.

Change-Id: Ic021a47754ea7a1574e818dad47151ab6698e06f
2012-07-18 23:09:13 -04:00
Aaron Schulz
e6faa2fd76 Merge "escape HTML elements in docblock with double quotes" 2012-07-18 19:17:46 +00:00
Demon
0220b4375c Merge "Api method documentation tweaks" 2012-07-18 18:24:43 +00:00
Reedy
39080a18dd Revert "(bug 30836) API siteinfo specialpagealiases should not return nonexistent special pages"
Caused Bug 38464 - API showing internal error with ?action=query&meta=siteinfo&siprop=specialpagealiases&format=xmlfm

This reverts commit 48523016ef

Change-Id: I470e87d21d98d4436bd5e27d0a3796559f9c41bb
2012-07-18 17:50:09 +01:00
Petr Onderka
0ec20050d0 Revert "Do not show empty categories with list=allcategories"
This reverts commit 4b9bd6a4db.

This change made allcategories less useful,
because it means it's impossible to list empty categories
(previously, acmax=0 did that).

To exclude empty categories, acmin=1 can be used.

Change-Id: I7943507c4cb7d752f82caa69ce3edb0b31ca9463
2012-07-18 12:21:32 +02:00
Catrope
cf4da8140b Merge "API: Cleanup around comment/reason params" 2012-07-18 01:59:34 +00:00
Catrope
2217f124da Merge "prop=imageinfo&iiprop=url|thumbmime needs iiurlwidth=" 2012-07-18 01:42:33 +00:00
Catrope
c1c2fab268 Merge "Avoid mangling fields in API continuation parameters" 2012-07-17 23:18:31 +00:00
Catrope
a9c9b6f556 Merge "Notice: Undefined index: page_is_redirect in \includes\api\ApiPageSet.php on line 111" 2012-07-17 23:18:20 +00:00
Brad Jorsch
2b3f4d821c Avoid mangling fields in API continuation parameters
API continuation parameters encode sufficient state for a subsequent
query to continue where the previous one left off; this may sometimes
include page titles, with or without the namespace. Given that these
page titles are already in the exact format required for the next
request's SQL query, it is not necessary to "normalize" them in any way.
And if normalization does more than just change spaces to underscores or
vice versa (e.g. it canonicalizes namespace aliases or capitalizes the
first letter of the title), it can be actively harmful: see bug 36987
and bug 29290.

Note this patch involves a breaking API change: the values for the
"continue" parameter of various modules have been changed, and some
modules will now return "continue" as the continuation parameter instead
of reusing "from".

Note this patch also corrects a minor logic bug in ApiQueryAllLinks,
changing ">" to ">=". The line is being changed anyway, so I didn't
bother doing a separate changeset.

Change-Id: I459232e919d20f89f6de9d20640fd48c8fd5781c
2012-07-17 16:08:39 -07: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
Aaron Schulz
5d6c49f17a Merge "Retrieve rev_len for sizediff in usercontributions API" 2012-07-15 20:12:16 +00:00
umherirrender
87524b1e75 (bug 38376) call to undefined method ThumbnailImage::getPath()
* Added MediaTransformOutput::getExtension() function and use it instead.
* Also fixed getScriptedTransform() to not pass the page as the path parameter.

Change-Id: I6c530aa155d62a6bfd5727c6f3d104fe91453745
2012-07-15 14:09:43 +02:00
Reedy
1aac87e9f1 Fix for: Fatal error: Call to undefined method ApiDelete::getErrorsArray()
Fatal error:  Call to undefined method ApiDelete::getErrorsArray() in /usr/local/apache/common-local/php-1.20wmf7/includes/api/ApiDelete.php on line 65

Caused by https://gerrit.wikimedia.org/r/#/c/7572/

Change-Id: Ib86fab94667ed50d172eb7ea3e82c99ecb3e52b0
2012-07-14 01:11:54 +01:00
Aaron Schulz
d3075c9875 Merge "Add call to GenderCache in list=allpages" 2012-07-13 18:38:16 +00:00
umherirrender
dbea761c29 prop=imageinfo&iiprop=url|thumbmime needs iiurlwidth=
A thumb is only generated when prop=url and a urlwidth is given. Adding
a hint to param description.
list=allpages does not have a urlwidth param and therefor cannot get the
thumbmime, adding thumbmime to the filter list to remove it from output

Change-Id: Ic1dbdb9b07f6325756058d6a0aa6ea148499fdfb
2012-07-13 17:25:22 +02:00
umherirrender
4b9bd6a4db Do not show empty categories with list=allcategories
Special:Categories is also not showing empty categories.

Change-Id: If23a763c887ed827ed548ff2af6abea04e46dbb9
2012-07-13 16:54:15 +02:00
Reedy
002d871048 Api method documentation tweaks
Change-Id: I43398b6016f64accf86921c72a6dac5e71e11c34
2012-07-12 16:53:00 +01:00
Antoine Musso
4a69fceb79 prettify documentation
Change-Id: Icfd267a94ac981b4c15e51add18c6d8ceb68454e
2012-07-10 17:18:20 +02:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
umherirrender
89bb46e2e4 API: Cleanup around comment/reason params
* Moving setting of empty string to param description.
* Removing word "(optional)" from comment/reason param, because all not
  required params are optional.
* Correct description of action=rollback for default comment.

Change-Id: Ifa5b60a7b55b216c43049cd81cb584b2e0518eed
2012-07-08 23:31:26 +02:00
umherirrender
5342d822a8 Notice: Undefined index: page_is_redirect in
\includes\api\ApiPageSet.php on line 111

This came when using action=query&redirects, because ApiQueryInfo was
requesting page_is_redirect unconditionally, but that field is sorted
out, when using resolve redirects

Change-Id: Ifde9c5d8cbbb8775151829ae8c07e3ed5d76868a
2012-07-08 17:09:04 +02:00
umherirrender
8e5c1bc69f Add call to GenderCache in list=allpages
Without this call, each user page can produce a query to get the gender
state.

Change-Id: I430c9922008cfea57b02da112087a7d52aeb4d23
2012-07-08 14:44:30 +00:00
Petr Onderka
4b70aea869 Updated result properties in paraminfo API
Recent changes I6e388e75 and Ia6415b39 introduced
new result properties, but didn't update getResultProperties().
This patch corrects that.

Change-Id: I18d088d76a48ec0d70408a8ac27a9af716839b61
2012-07-07 15:29:14 +02:00
Petr Onderka
6601c36bf8 Retrieve rev_len for sizediff in usercontributions API
The sizediff parameter introduced in I6e388e75 requires
the rev_len field, but it wasn't added to the condition
for that field.

This means prop=size|sizediff worked, but prop=sizediff
alone didn't. This patch fixes that.

Change-Id: Ib15814d809398ca3d4633149af0ce62489d8adaa
2012-07-07 15:16:56 +02:00
Brad Jorsch
af6a3bc49e (bug 35980) drcontinue should pay attention to drdir in "all" mode
In "all" mode (mode #3 in the module's documentation), the drdir
parameter is treated by the result ordering as if it were always
drdir=newer; drcontinue, on the other hand, always tries to honor drdir
correctly, leading to the drcontinue not actually working unless drdir
is specifically given.

This fixes that.

Change-Id: Icf6982d0ba55490b7a7ae3a1ee6c94c40f1c3c64
2012-07-06 20:54:43 -04:00
Brad Jorsch
48523016ef (bug 30836) API siteinfo specialpagealiases should not return nonexistent special pages
Some special pages are conditionally registered (e.g.
Special:Popularpages only exists when $wgDisableCounters is false), or
sometimes an alias exists for a special page that does not. The API
should probably not return entries for these from
meta=siteinfo&siprop=specialpagealiases.

Change-Id: I59eb82eae45fb47c6a769195cc1bd28711b4fcac
2012-07-07 02:40:35 +04:00
Reedy
c154160ee0 Merge "Reimplement CORS properly, addressing Tim's concerns" 2012-07-05 20:31:39 +00:00
Catrope
29625efc2b Reimplement CORS properly, addressing Tim's concerns
Tim's concerns (listed at
https://bugzilla.wikimedia.org/show_bug.cgi?id=20814#c6) were:
* Lack of Vary: Origin breaks Squid caching
* Vary: Origin on everything would be disastrous, so add an origin param
* Origin header is space-separated list, wasn't treated as such

This commit:
* Remove CORS code from api.php and reimplement it in ApiMain.php
* Add 'origin' parameter to ApiMain
* If 'origin' parameter doesn't match Origin header, send a 403
* If origin is whitelisted, set CORS headers and set Vary: Origin
* Add https?:// to wildcard matching logic, wasn't there but is needed

CORS now works :) you can test it locally as follows:
Set $wgCrossSiteAJAXdomains[] = '*.wikipedia.org';
Log into MediaWiki on localhost
Go to Wikipedia, open a JS console, and run:
$.ajax( {
	'url': 'http://localhost/w/api.php',
	'data': {
		'action': 'query',
		'meta': 'userinfo',
		'format': 'json',
		'origin': 'https://en.wikipedia.org'
		// or whichever domain you're on; must be correct!
	},
	'xhrFields': {
		'withCredentials': true
	},
	'success': function( data ) {
		alert( 'Foreign user ' + data.query.userinfo.name +
			' (ID ' + data.query.userinfo.id + ')' );
	}
} );

Change-Id: I725ce176866d7c81dd9ad6d7bc4a86b7160f2458
2012-07-05 21:31:11 +01:00
Catrope
7da3bb81f7 In ApiMain, gather Vary headers in OutputPage
Using OutputPage for this rather than something like WebResponse
probably isn't optimal, but it's a lot nicer than the mess we had
before.

Change-Id: I9dce06d3eb69dd7952eafc6c94ead2ad5ad88792
2012-07-05 21:29:31 +01:00
Brad Jorsch
68597a1345 Allow API meta=siteinfo to return list of know variable IDs
To know whether something like {{foo}} is a template, variable, or
function, you have to first check if it's a magic word, and then look up
the magic word ID in the list of variables and the list of function
hooks. The API already can return the list of known magic word mappings
(siprop=magicwords) and function hooks (siprop=functionhooks), this
completes the set by allowing siprop=variables.

Change-Id: If13df9c3796ea6815393d847a3c6f70380bba58a
2012-07-05 02:03:50 +01:00
umherirrender
08aee8c709 (bug 32383) Allow descending order for list=langbacklinks
Change-Id: I5ebcb8c3d49f85eba14c1caafb5b5b78ccee4605
2012-07-04 22:52:29 +01:00
umherirrender
4bf413c990 (bug 32381) Allow descending order for list=backlinks, list=embeddedin
and list=imageusage

Also avoid some filesorts when using redirect param of that modules
due to fields in order by, which are constant in where

Change-Id: I4b1c4282ab3be9cb93601c57d660520456cf8617
2012-07-04 22:48:08 +01:00
umherirrender
f191e6320f (bug 32382) Allow descending order for list=iwbacklinks
Change-Id: If9425f3d6dbee3da34e875c1b02088478c3d6d53
2012-07-04 22:45:04 +01:00
umherirrender
a2e40f12f5 (bug 31777) Upload unknown error ``fileexists-forbidden''
adding messages to ApiBase::$messageMap and to message files for client
side localisation

Change-Id: I37e03130c6b90e4614514cd76b73eab6890eb82f
2012-07-01 19:35:31 +02:00
Siebrand
5fb8b96195 Merge "Expose the log_id of the deletion log entry in the action=delete API" 2012-07-01 15:55:29 +00:00
Siebrand
d842a5582f Merge "(bug 32348) Allow descending order for list=alllinks" 2012-07-01 15:03:20 +00:00
Siebrand
0e48e20587 Merge "Bug 36453 - Provide the git info on action=query&meta=siteinfo" 2012-07-01 14:22:59 +00:00
Alexandre Emsenhuber
58852d8827 Deprecated Title::userIsWatching(); use User::isWatched() instead.
* The problem is that Title::userIsWatching() relies on $wgUser,
  which is not suitable on every case. Instead User::isWatched()
  requires both an User and a Title object.
* Replaced all core calls from the former to the latter
* Added a cache in User for the WatchedItem instances so we do not
  need to do a database request every time something want to know
  whether a page is watched or not, which can happen several times
  per request.

Change-Id: Ifa9c55b7ffb487ce6893c74df233eedc7654dc5e
2012-06-29 23:22:35 +02:00
Max Semenik
dd6519709b Bug 36453 - Provide the git info on action=query&meta=siteinfo
Change-Id: I3d6c79d0d2cafd533f39e255940869087778d884
2012-06-30 00:04:42 +04:00
umherirrender
a9a71011ff Change some NS_IMAGE to NS_FILE
Change-Id: Id530c88d24df1a47a2f6565911184008b67fe04d
2012-06-24 21:50:10 +02:00
umherirrender
f1f1c2e794 Use canonical parser option for linkupdate in api purge
This patch makes sure, that the links table updated against the
content language. This also enabled the limit report, which than
is also stored in the parser cache along with the html.

Change-Id: I2a0b09d7250813809f1b2a8cba3e4f53a6686002
2012-06-23 00:25:33 +02:00
Catrope
81c1225bb8 Merge "API: Reset token cache on login, so API tests work" 2012-06-22 21:39:47 +00:00
daniel
bfa1ced1a7 API: Reset token cache on login, so API tests work
Previously, logging in several times during a phpunit run would change the
session token, but keep the edit token, leasing to "bad token" failures for
all but the first login.

Change-Id: Iad49c990c5661d55cd907b8441addb74eb0ef694
2012-06-22 23:34:59 +02:00
daniel
7d3d38748a Fix session handling in API test cases.
* Use the API module's own context to check edit tokens.
* Use the global session if none is provided to doApiRequest.
* Fix ApiFlockTest to not pass an empty session, so the tokens from
  the global request can be used.

Change-Id: I2bff2390f43beb984b1b451bcf4e41271b2f054f
2012-06-21 22:29:19 +02:00
Aaron Schulz
6befd65ccf Merge "(bug 37301) add sizediff to list=usercontribs" 2012-06-19 21:31:19 +00:00
umherirrender
b84ffc114a (bug 32348) Allow descending order for list=alllinks
Change-Id: Ia87f743d2a28594d32fe092bc839051ac7a37729
2012-06-17 09:33:23 +02:00