Commit graph

294 commits

Author SHA1 Message Date
Sam Reed
6c80c5ff87 Prep work for * (bug 33147) API examples should explain what they do
Now formatted in the autogenerated documentation

Format for paraminfo adds a description attribute to output


query allimages descriptions are tranformed, need to do/add to other ones
2011-12-16 15:28:35 +00:00
Jeroen De Dauw
49cdca93be add missing deprecation notices and added deprecation version to existing ones 2011-12-13 05:19:05 +00:00
Sam Reed
7ea2f68c3a Followup r105823, make it protected 2011-12-11 20:41:23 +00:00
Sam Reed
b8d83ec568 Adding a getDB function to ApiBase...
Not all subclasses will need/want it. It does however make it easier to pretend non ApiQuery derivatives actually are...
2011-12-11 20:32:37 +00:00
Sam Reed
7f3f1f7caf Followup r104441
Fix capitalisation mismatch
2011-11-28 19:17:06 +00:00
Sam Reed
53000baecf Oh noes, moar http:// -> https:// 2011-11-28 15:43:11 +00:00
Sam Reed
f3839fe71f Added "ApiGetDescription" hook 2011-11-28 15:33:28 +00:00
Roan Kattouw
792c38f424 (bug 26854) Invalid user names go unchecked. Applied most of the patch submitted by Søren Løvborg, checking for null return values from User::newFromName() 2011-11-20 10:55:58 +00:00
Alexandre Emsenhuber
2c4d6b6992 Follow-up r103332: fix "invalidoldimage" error message to say "oldimage" instead of "oldid" 2011-11-19 08:29:49 +00:00
Alexandre Emsenhuber
2bb8c2ea4d * Use WikiPage instead of Article
* Create the WikiPage object directly in execute() and pass it to both delete() and deleteFile()
* Reordered parameters of delete() and deleteFile() to be consistent and take both on the WikiPage and User objects (instead of relying on $wgUser); no callers outside of this class
* Fixed deleteFile() to match the behaviour of FileDeleteForm with oldimage parameter
* Pass the User object to getPermissionsError()
* Factorised duplicated code
* Added missing error code to ApiBase (and also a new one)
* Added missing possible error codes (with a new one too)
2011-11-16 15:57:56 +00:00
Roan Kattouw
71461de9de Followup r99224: add message to ApiBase::$messageMap too 2011-11-14 14:40:55 +00:00
Alexandre Emsenhuber
681523d5ad Fix for r100905:
* Make tests work again
* Added ApiTestCase::doApiRequest() and related to pass it to the context and removed override of $wgUser where possible
* Fix ApiLogin to get the correct User object (i.e. the logged in one)
* Fix ApiBase to feed a RequestContext to setContext() so that ApiLogin can call setUser()
2011-10-27 18:46:40 +00:00
Sam Reed
fa65fa3243 Documentation
Deprecated code updates
2011-10-27 00:46:17 +00:00
John Du Hart
24427ca1d8 Followup 100905, fixing usages of getContext() 2011-10-26 23:34:31 +00:00
John Du Hart
40f19e6def Adding context to the API
This will probably break something somewhere so when it does please yell at me on IRC and I'll fix it.
2011-10-26 23:27:01 +00:00
Sam Reed
469cc76775 Return documentation 2011-09-21 16:36:43 +00:00
Jeroen De Dauw
328765afbc doc fix 2011-09-06 20:31:51 +00:00
Roan Kattouw
5090af900c (bug 29246) Edit API occasionally throws "unknown error 231". Per comment #1 on the bug and a comment in ApiEditPage, I refactored internalAttemptSave() to return a status object. However, there are so many idiosyncracies wrt how EditPage handles various errors that I decided to put the AS_* error code in $status->value (thanks Chad for that tip) and use that to decide what to do (not part of Chad's tip). The resulting code is still a mess but at least Status objects from doEdit() are propagated now, and it'll be a little bit easier to migrate internalAttemptSave() to a proper Status-based architecture in the future. Or maybe we should just throw away EditPage and start with a blank screen, that sounds appealing to me :) 2011-08-26 16:26:17 +00:00
Sam Reed
ac0ff8fb37 Followup r92396 rename method, fix boolean comparison that was supposed to be inverted when de-indenting 2011-07-17 16:23:29 +00:00
Sam Reed
d18c0dc315 * (bug 28817) Add reference help page link to API Modules
Start of this bug, fleshed out base code implemented, plus a few key modules (will finish rest up soon)

Tweaked/improved/updated some documentation as I went through also
2011-07-17 16:18:09 +00:00
Alexandre Emsenhuber
ffd52683c8 Create a new RequestContext to use its OutputPage and Skin members instead of messing with global ones 2011-07-08 16:18:31 +00:00
Sam Reed
8edf4a2d92 Fix trailing whitespace
Swap methods that call $this->getResult() to use temporary variable
2011-06-29 23:46:39 +00:00
Sam Reed
bdf84cb20e Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits, so hopefully reviewable in CR...
2011-06-17 16:03:52 +00:00
Sam Reed
67df4ef4c0 * (bug 27716) Make a method to do checking of 0 or 1 of the parameters existence (like requireOnlyOneParameter), but without needing one of the parameters 2011-06-06 16:45:40 +00:00
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