Commit graph

320 commits

Author SHA1 Message Date
Krinkle
2d03eedf8a WatchAction requires token (BREAKING CHANGE)
* (bug 27655) Require token for watching/unwatching pages
* Previously done for API (bug 29070) in r88522
* As with markpatrolled, the tokens are not compatible and made that way on purpose. The API requires the POST method and uses a universal token per-session. Since the front-end is all GET based (also per convention like in markpatrolled and rollback) they are stronger salted (title / action specific)
* ajax.watch used the API already and was switched in r88554.
* The actual watching/unwatching code was moved from WatchAction->onView to WatchAction::doWatch. This was done to allow the API to do the action without needing to generate a token like the front-end needs (or having to duplicate code). It is now similar to RecentChange::markPatrolled (in that it  also a "central" function that does not care about tokens, it's called after the token-handling)
* JavaScript / Gadgets that utilize action=watch in their scripts:
** Effects should be minimal as they should be using the API (see r88522 and wikitech-l)
** If they use index.php and scrap the link from the page, they can continue to do so.

* There are links to the watch action all over the place. I've tried to catch most of them, but there may be some I miss. Migration in most cases is just a matter of adding an array item to the $query for:
 'token' => WatchAction::getWatchToken( $title, $user [, $action] )
or changing:
 Action::factory( 'watch', $article )->execute();
to:
 WatchAction::doWatch( $title, $user );

While replacing the usages in some cases an instance of Article() no longer had to be created, in others $wgUser had to be retrieved from global (which was implied before but needs to be given directly now)

Other notes:
* Article->unwatch() and Article->watch(), which were deprecated as of 1.18 and are no longer used in core, may be broken in scenarios where the Request does not have a 'token' but is making a call to $article->watch()
* Some extensions need to be fixed, I'm currently running a grep search and will fix them a.s.a.p 


[1] http://www.mediawiki.org/wiki/ResourceLoader/Default_modules?mw.user#tokens
2011-06-06 00:09:03 +00:00
Sam Reed
587f480923 * (bug 28392) mark action=undelete&timestamps as type "timestamp"
Allow multiple timestamps
2011-06-05 23:18:22 +00:00
Sam Reed
58ccb663e1 Followup r89515, fix double spacing in API Error message
Add both customcssprotected and customjsprotected to the possible errors output for editpage
2011-06-05 18:34:26 +00:00
Sam Reed
5749cfa480 * (bug 21107) Split error "customcssjsprotected" into separate messages for JS and CSS 2011-06-05 18:29:43 +00:00
Sam Reed
2b676156ba And even more documentation 2011-05-28 18:58:51 +00:00
Sam Reed
e22c5cb3e7 While looking at bug 26990 on TW api, it was noticed with a load of NS's they don't word wrap
So make them wordwrap like the rest of the text
2011-05-20 17:38:05 +00:00
Antoine Musso
391284b75c ApiBase::dieUsageMsg() now also accept being given a single element as a string.
So the old: 
  $api->dieUsageMsg( array( 'nologging' ) );

Can now be written:
  $api->dieUsageMsg( 'nologging' );

Saves up a few keystrokes.
2011-05-14 11:19:59 +00:00
Sam Reed
3441def388 Documentation
Remove long deprecated isBot()/isSysop() in ApiMain
2011-05-08 16:48:30 +00:00
Happy-melon
3f4e0e2e74 (bug 28797) Fix ApiBase::parseMsg() to properly handle nested error arrays. 2011-05-07 13:05:22 +00:00
Sam Reed
f985524076 More versions added to @deprecated tags
Couple of inbound calls fixed up

Some ancient code removed as it's been marked deprecated
2011-05-06 21:50:18 +00:00
Jeroen De Dauw
f266b1ca15 small doc fix 2011-04-29 22:05:36 +00:00
Jeroen De Dauw
22cd74d272 fix return type descriptions 2011-04-29 15:41:57 +00:00
Jeroen De Dauw
f8dc68bd98 fix typo 2011-04-29 15:37:01 +00:00
Sam Reed
40f33eb663 Add some more spacing due to long parameter names
Use str_repeat for ease rather than "     " etc

Fix MiserMode to MiserMode
2011-04-23 13:29:11 +00:00
Alexandre Emsenhuber
21e53d3590 * Added Profiler::isStub() to check if we are using a stub profiler, instead of checking whether $wgProfiler is set
* Replaced wfProfileClose() and wfGetProfilingOutput() by direct calls to the Profiler instance and removed them, no uses in extensions
* Also removed useless params from Profiler::getOutput() call in wfLogProfilingData()
* Only generate profiling output if it'll be used; introduced Profiler::logData() that saves profiling data (database, udp, ...) to separate it from output generation
* Removed unused Profiler::getCaller(), not used at all, and we have wfGetCaller() that does the same thing
2011-04-21 16:31:02 +00:00
Happy-melon
8779f4b55f r86001, now with less scariness :P I took out the delete action and did purge instead, which is a much more self-contained action-with-a-form. Also implement a few changes suggested by Brion on IRC last night. 2011-04-14 10:38:29 +00:00
Happy-melon
bc4a096805 Revert r86001: Brion says it's too scary :D will recommit in pieces 2011-04-13 23:36:27 +00:00
Happy-melon
6dc8136d12 New infrastructure for actions, as discussed on wikitech-l. Fairly huge commit.
* Actions come in two flavours: the show-a-form-then-do-something-with-the-result (delete, protect, edit, etc) and the just-do-something (watch, rollback, patrol, etc).  Create abstract base classes Action and FormlessAction to support these two cases.  HTMLForm is an integral part of the form-based structure.
* Look mum, no globals!  :D  Fully context-based.
* Implement watch/unwatch, credits and delete actions in the new system as proof-of-concept.  This also gives the delete frontend a much-needed overhaul.
* Stub out the newly-deprecated functions from Article.php.  This already reduces its linecount by about 15%, and there are plenty more actions still to do.
* Centralising actions like this is going to render a lot of hooks type-incompatible.  There's simply nowhere you can put the ArticleConfirmDelete hook, for instance, where it can be passed an OutputPage as the second parameter.  On the other hand, we can implement new hooks like ActionModifyFormFields and ActionBeforeFormDisplay, which can do much prettier stuff to the forms, like adding extra fields the 'right' way.  Update LiquidThreads to use these new hooks where appropriate.
2011-04-13 23:04:07 +00:00
Bryan Tong Minh
8bd336981c API upload errors may now return the parameter that needs to be changed and a sessionkey to fix the error. This is for now only done for uploads that can be fixed by changing the filename, but may be extended later to comment and pagetext. 2011-03-25 21:22:02 +00:00
Sam Reed
01caf960f2 Followup r82060
Calling intval() on an array of integers isn't going to get people very far

simplify logic, and then only do validation if $min or $max are not null
2011-03-03 23:22:39 +00:00
Sam Reed
27ca6b2fa8 Tweak comments, remove some unused stuff.
Explicit definitions, move a few minor bits around
2011-02-27 21:10:11 +00:00
Sam Reed
41e7860130 Implement getRequireOnlyOneParameterErrorMessages, to make the error messages requireOnlyOneParameter can throw.
Use in 4 modules for more dynamicness
2011-02-25 19:09:39 +00:00
Sam Reed
28f7bf1f2b Followup r82727, improve comments, cast return value to bool 2011-02-24 16:00:06 +00:00
Sam Reed
ab408b911d Seems the api edit watch/unwatch wasn't too well tested (after it got poked a lot)
EditPage::commitWatch() unconditionally  does a watch/unwatch...

And multiple watches of a watched page end up with an INSERT IGNORE, so not a big deal
2011-02-24 15:51:51 +00:00
Sam Reed
3721e827ac * (bug 27376) when using ApiBase::PARAM_TYPE => 'integer' without a min or max value, api doesn't validate the input is actually an integer
Fixup some space indention
2011-02-13 17:00:47 +00:00
Sam Reed
bfd67cf818 Remove some blank lines
Spaces to tabs in ApiBase
2011-01-07 02:53:00 +00:00
Sam Reed
1f05665cf3 Styleli[zs]e the API up to date (Been a while since) 2010-12-30 17:06:09 +00:00
Roan Kattouw
ea310d143f Followup r78824: add missing message 2010-12-29 20:20:55 +00:00
Sam Reed
f63b5040e3 More minor bits of documentation
Object type hint on mPrinter
2010-12-23 19:53:28 +00:00
Sam Reed
55ebd95afd * (bug 24287) Wrap/similar on api help output 2010-12-22 21:40:33 +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
492ac9b4bf Followup r77666, bug 26219
Only add the message about multi value, if the type is not an array, or if it is an array, if it has over 50 (LIMIT_SML1) items
2010-12-04 00:36:33 +00:00
Sam Reed
612c934210 * (bug 26219) Show API limits for multi values in description
Also move bug 9675/r77612 RELEASE-NOTES to the correct section
2010-12-03 16:24:05 +00:00
Sam Reed
056b646308 Followup r74988, brion wins again ;D 2010-10-19 18:40:43 +00:00
Sam Reed
c85bf31cf3 Swap usage of create_function for defined function as a callback 2010-10-19 00:44:28 +00:00
Roan Kattouw
9c0b26028f Revert r74810 (vary API help cache on $wgUser->isAnon()) and move the POST check into the purge module. Also fix the permissions check in action=purge, which was totally broken and based on a misunderstanding of what the 'purge' right means. 2010-10-18 09:19:20 +00:00
Sam Reed
519173c0e4 Followup r74234 flip parameters 2010-10-04 21:18:38 +00:00
Sam Reed
9cda0105a9 Minor tweaks to r74232, add a value for $botMax on calls for integer validation (otherwise the bool gets pushed into it!)
Documentation in ApiDelete
2010-10-03 20:29:44 +00:00
Sam Reed
69107791db Followup r74230, if we make things array, we should make them not an array afterwards
Well, the more sane way, is just treat them seperately, than having to do $value = $value[0];, based on whether it was an array already

Cheers to Siebrand (was already poking it myself :))
2010-10-03 20:07:23 +00:00
Sam Reed
7ad52b7bdd First part of "*(bug 25303) API: integer parameter validation does not actually validate, only warn"
Actually make the validation of the range occur

Fix typo in ApiBase.php
2010-10-03 19:07:11 +00:00
Sam Reed
42b5c265c0 * (bug 25248) API: paraminfo errors with certain modules
Added a needsToken() function, rather than calling getTokenSalt, which can throw silly errors due to dependencies on parameters
2010-10-01 20:12:50 +00:00
Sam Reed
9d1e45bf42 Tweak/add some documentation as hints for some code analysis 2010-09-28 01:33:11 +00:00
Sam Reed
6c1273bc7d Fill in missing params from a dieUsage
Braces

Fixup parameter documentation
2010-09-25 16:45:41 +00:00
Sam Reed
f07567201f Remove some unused variables
Tweak php doc, "One" is not a type, so insert string in there
2010-09-25 16:37:39 +00:00
Sam Reed
ee04d754ed Only display Examples section if it's got anything in the array 2010-09-03 22:58:09 +00:00
Sam Reed
fc38716f49 ApiBase.php:
"Don't show No more than 500 ( for bots) allowed" when MAX2 isn't set

Trim trailing whitespace from Database.php
2010-08-31 21:06:01 +00:00
Sam Reed
5d383466e1 Minor followup to r70480
Only throw missingparam for string === '' when it is required

RELEASE-NOTES for breaking change
2010-08-19 14:54:09 +00:00
Platonides
50e2405a03 Refactor to avoid defining globals inside switches. 2010-08-12 14:25:07 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
Sam Reed
7128c455cc Followup r69091 Where did those spaces come from? :/ 2010-08-05 07:08:06 +00:00
Sam Reed
ddc7efbedf stylize api up to date 2010-08-05 07:02:09 +00:00
Sam Reed
c85b04919e Revert r70489 2010-08-05 06:58:11 +00:00
Sam Reed
0345d5e08f Move if ( is_array( $value ) && !$dupes ) { up to else block after the first !is_array. If it's not not an array, it's an array, and therefore, we can just filter dupes if requested 2010-08-05 06:08:23 +00:00
Sam Reed
c95f4a05ad Followup r70480, per Nikerabbits comment, there '''is''' something to do 2010-08-05 06:02:57 +00:00
Sam Reed
0ccf248381 -rakkaus/#mediawiki-i18n- [04-Aug-2010 22:02:04] PHP Notice: Undefined variable: required in /www/w/includes/api/ApiBase.php on line 749 2010-08-04 22:02:57 +00:00
Sam Reed
edf926dfe2 Followup r70479
If string is required, but it's value === '', that's missing!
2010-08-04 21:21:35 +00:00
Sam Reed
b70c52dd8e Further followup to r70460/r70461 and r70477
Move code into getParameterFromSettings, most of the flesh is there anyway (it checks isset( $value ) ), so we can use the else to check if it's required

A followup could be to whinge if '' is returned for a string
2010-08-04 21:19:53 +00:00
Sam Reed
dd889d04c4 Followup r70460/r70461
use self consistently

Fold in duplicate loop

missingparam can be done during attempt to set ParamCache, we might aswell give up and not finish populating the param cache if we're gonna die from a missing param
2010-08-04 20:27:56 +00:00
Sam Reed
f77fff0ffb Followup r70461 if PARAM_REQUIRED is set, use for missing param in getPossibleErrors in ApiBase
All but ApiQueryBacklinks
2010-08-04 19:20:15 +00:00
X!
8b466d3d0d Followup to r70460: Committed wrong version of ApiBase.php, convert all core API modules to PARAM_REQUIRED syntax 2010-08-04 14:15:33 +00:00
X!
20d042a99e * PARAM_REQUIRED parameter flag added. If this flag is set, and the end user does not set
the parameter, the API will automatically throw an error.
2010-08-04 13:35:08 +00:00
Bryan Tong Minh
0e61296f98 (bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or one of the backlinks generators with limit=max. 2010-07-28 11:30:14 +00:00
Tim Starling
6afbc6762c Reintroduced the extractRequestParams() memoization as in r69782, but respecting $parseLimit. Fixes bug 24564 (fatal error due to duplicate calls to addValue()). 2010-07-28 04:12:36 +00:00
Tim Starling
287c9ea4f5 Partial revert of r69782: reverted the cache feature, it does not correctly respect $parseLimit. 2010-07-26 06:20:29 +00:00
Platonides
5833c105d0 Move getValidNamespaces() to Namespace.php 2010-07-25 22:29:05 +00:00
Roan Kattouw
075c8d1624 Followup to r69776: cache result of extractRequestParams() because it gets called 2 or 3 times per module per request now. Also touch up documentation here and there 2010-07-23 10:15:29 +00:00
Sam Reed
5387b8a806 Stylize API up to date
Fix spaces from r69755

Minor update to RELEASE-NOTES per r69753
2010-07-23 07:33:40 +00:00
Tim Starling
b2dc451c82 Rewrote r69339 etc. to clean up API cache header handling.
* Introduced a "cache mode" concept to simplify the header generation code, and to avoid odd results when conflicting cache header requests are received from submodules, or at least to formalise the handling of such cases.
* Made the cache mode private by default, so that code written in ignorance of caching tends to be safe. If different query modules are used in a single request, private caching is preferred over public caching.
* Removed the "must-revalidate" option from all CC headers, this is really specific to page views with a hacked squid in front, I don't think it's applicable here.
* Made the watchlist module private. This is really the definition of private data. There's nothing in the HTTP spec that says the URL for a CC:public request is private and can't be leaked. CC:private provides protection against unknown proxy behaviour.
* In ApiQueryAllmessages: avoid calling $wgLang->getCode() to check if it's necessary to make a new $wgLang when lang= is specified, since this is the only thing that unstubs $wgUser.
* Removed "FIXME: should this check $user instead of $wgUser?" Answer is no.
2010-07-23 07:17:56 +00:00
Sam Reed
8f1d2cb199 Big blitz on unused variables (a lot of $db = $this->getDb() ) 2010-07-22 22:13:21 +00:00
Sam Reed
fd2744694a Add braces 2010-07-22 06:44:23 +00:00
Roan Kattouw
70824ccccc API: Make output containing private or user-specific data uncacheable for logged-in users by setting Vary: Cookie or Cache-Control: private, whichever is appropriate. Fixes instances in core and WMF-deployed extensions only. Without this change, the output of requests like ?action=query&list=recentchanges&rcprop=patrolled&smaxage=3600 would be cached in Squid and viewable for anyone using the same URL, even if they don't have patrol rights. Other, more serious exploits are also possible. Also avoid using $wgUser in one place, kill some unused global $wgUser; instances and tweak a comment. 2010-07-14 19:00:54 +00:00
Sam Reed
f5c639fd10 Stylize API
Add a few braces
2010-07-06 13:15:59 +00:00
Sam Reed
3fe7b6912b * (bug 24136) unknownerror when adding new section without summary, but forceditsummary
Handle AS_SUMMARY_NEEDED in ApiEditPage

Fixup some braces
2010-06-27 19:22:46 +00:00
Sam Reed
928ff2b273 Resolve fixme of r66539
Move getWatchlistUser to ApiBase
2010-06-22 12:10:26 +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
Roan Kattouw
fe66ef26cd (bug 24016) API: Handle parameters specified in simple string syntax ( 'paramname' => 'defaultval' ) correctly when outputting help. Patch by Brad Jorsch. 2010-06-18 09:30:38 +00:00
Sam Reed
6b5a27c0e8 Followup to r66232 do same for limit text, and module rights 2010-05-11 22:34:41 +00:00
Sam Reed
0769301e87 Stylize Api upto date 2010-04-17 20:58:04 +00:00
Mark A. Hershberger
9c7a7e57f0 * New UploadFromUrlJob class to handle Upload-by-Copy
* Define variable for ApiUserrights.php that wasn't defined before.
* Add convertVerifyErrorToStatus and getVerificationErrorCode to
  UploadBase to translate error consts since UploadFromUrl will
  need a message to display to end-users.
* refactor mime-checking out of UploadBase::verifyFile into
  UploadBase::verifyMimeType
* Make UploadBase::verifyFile always return arrays for errors
* Use HttpFunctions instead of custom curl handler for async downloading
* TODO: Need a way to feed errors back to the requestor
* TODO: Need to add watchlist param handling and warnings checks.
2010-04-17 02:43:13 +00:00
Bryan Tong Minh
6c6c2f698c Followup to r64962: Fixed watchlist parameter in API. User options watchdeletions and watchmoves can now by overridden. Unwatching while editting is now possible. 2010-04-14 12:17:39 +00:00
Mark A. Hershberger
e90d1ecd97 * EOL ws clean on ApiBase.php
* Use an actual value for ApiUpload.php
* Commit some code I must've missed for r64852
2010-04-14 04:57:27 +00:00
Sam Reed
d840fbbc95 Revert r64955
Again partial fix to bug 23167

Bugfix watch on creation (edit and upload), in current form, setting unwatch, or nochange would follow watchcreation, which wasn't requested
2010-04-12 10:44:45 +00:00
Alexandre Emsenhuber
15dd2a1c40 Fix param names mismatch in code/doc from r64852 and r64397 2010-04-11 19:10:15 +00:00
Mark A. Hershberger
6c267f1434 * Clean up some duplicated code in r64291
Would've like to refactor the $wgUser->*Watch — but I'm not sure if the hooks that come along with $articleObj->*Watch are ok.
2010-04-10 06:11:02 +00:00
Sam Reed
2a557115f0 Fixup to r64197 per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/64197#c6451
Pass $fromTitle rather than $titleObj (which is undefined)
2010-04-07 08:56:43 +00:00
Mark A. Hershberger
c1e369912f followup r64465 — make happy-melon happy 2010-04-01 11:25:56 +00:00
Mark A. Hershberger
c1afe8e84e follow up r64454 — change comment style 2010-04-01 00:35:14 +00:00
Mark A. Hershberger
9c26ed06af Get rid of E_STRICT message 2010-03-31 19:50:46 +00:00
Mark A. Hershberger
234f54a88e * Set $titleObj to null by default on getWatchlistValue since it often isn't needed & check that it is set when it is needed. (follow up r64197).
* Refactoring ApiUpload & UploadBase to make it easier to extend & read.
* Use a class constant for the upload session key instead of a hard-coded-across-several-files value.
* Add UploadBase::appendToUploadFile() method to enable protocols that do incremental upload.
2010-03-30 19:10:10 +00:00
Sam Reed
ba575d7a9e Switch if ordering as per Roans comment for r64291 2010-03-28 19:23:17 +00:00
Sam Reed
789cc18185 Followup r64197
Return null in getWatchlistValue if no change

Fixup unneccessary watch/unwatch calls

Remove useless unwatch from ApiUpload
2010-03-28 15:08:45 +00:00
Roan Kattouw
7ef2b44907 Fix coding style, whitespace in r64267 2010-03-27 21:34:07 +00:00
Sam Reed
346554a2f3 Followup to r64197
Remove the mutually exclusive else checks

Fix undefined on getWatchlistValue in ApiBase
2010-03-27 17:51:56 +00:00
Happy-melon
d6fe6de7a8 Followup to r64228 - apply restrictions in API. 2010-03-26 23:02:10 +00:00
Sam Reed
88df448d36 Fix bug 22944 in a much better fashion (using watchlist parameter)
Deprecate old watch/unwatch parameters

Move generic watchlist stuff to ApiBase/getWatchlistValue (maybe needs renaming better?)

Tweak some braces in ApiEditPage
2010-03-25 22:15:08 +00:00
Bryan Tong Minh
dd349d7b3a Merge r63621 and r63636 from REL1_16:
* Rollback chunked uploading support for 1.16
* 	Pass $sessionKey as parameter to UploadFromStash::initialize.
2010-03-12 18:26:12 +00:00
Roan Kattouw
d0045bcd78 API: Don't unstub $wgContLang in ApiBase::getValidNamespaces() 2010-02-26 18:24:58 +00:00
X!
0543d7bdce Whoops, committed wrong version 2010-02-24 17:06:19 +00:00
X!
fe72f84205 PARAM_TYPE 'user' now works for multi-values 2010-02-24 17:04:21 +00:00
Mark A. Hershberger
c871b75a3e follow up r62231, r61779, r62175
* Fix up messages
* For new FileRepo::append(), use flags to determine whether to delete or not
* Add more error checking for appending
* Fix a couple of places in Revision.php and LogPage.php where DB errors were produced when comment was null
* Remove bogus checking for !$comment, etc on the DONE phase of chunked uploading
* Don't pretend to return a value when raising an exception
* Add more tests for chunked uploads
* Verify that Status::getErrorsArray() (at least where it is used in ApiUpload::execute()) returns an array that we can pass to dieUsageMessage()
* Ensure that checkWarnings(), etc work only on the complete file
2010-02-22 02:15:30 +00:00