r62425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62424‎ | r62425 | r62426 >
Date:13:50, 13 February 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
getPossibleErrors for ApiThreadAction
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -43,6 +43,35 @@
4444 'NULL to specify the default signature',
4545 );
4646 }
 47+
 48+ public function getPossibleErrors() {
 49+ return array(
 50+ array( 'code' => 'sessionfailure', 'info' => '' ),
 51+ array( 'code' => 'action', 'info' => 'missing-param' ),
 52+ array( 'code' => 'too-many-threads', 'info' => 'You may only split one thread at a time' ),
 53+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to split' ),
 54+ array( 'code' => 'already-top-level', 'info' => 'This thread is already a top-level thread.' ),
 55+ array( 'code' => 'no-valid-subject', 'info' => 'No subject, or an invalid subject, was specified' ),
 56+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to merge' ),
 57+ array( 'code' => 'no-parent-thread', 'info' => 'You must specify a new parent thread to merge beneath' ),
 58+ array( 'code' => 'invalid-parent-thread', 'info' => 'The parent thread you specified was neither the title of a thread, nor a thread ID.' ),
 59+ array( 'code' => 'missing-param', 'info' => 'You must specify a talk-page to post the thread to' ),
 60+ array( 'code' => 'invalid-talkpage', 'info' => 'The talkpage you specified is invalid, or does not have discussion threading enabled.' ),
 61+ array( 'code' => 'talkpage-protected', 'info' => 'You cannot post to the specified talkpage, because it is protected from new posts' ),
 62+ array( 'code' => 'missing-param', 'info' => 'You must specify a thread subject' ),
 63+ array( 'code' => 'invalid-subject', 'info' => 'The subject you specified is not valid' ),
 64+ array( 'code' => 'no-text', 'info' => 'You must include text in your post' ),
 65+ array( 'code' => 'too-many-threads', 'info' => 'You may only edit one thread at a time' ),
 66+ array( 'code' => 'invalid-subject', 'info' => 'You must specify a thread to edit' ),
 67+ array( 'code' => 'no-specified-threads', 'info' => '' ), 'You must specify a thread to reply to'
 68+ array( 'code' => 'perm_result-protected', 'info' => 'You cannot reply to this thread, because the perm_result is protected from replies.' ),
 69+ array( 'code' => 'too-many-threads', 'info' => 'You may only change the subject of one thread at a time' ),
 70+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to change the subject of' ),
 71+ array( 'code' => 'missing-param', 'info' => 'You must specify a thread subject' ),
 72+ array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to set the sortkey of' ),
 73+ array( 'code' => 'invalid-sortkey', 'info' => 'You must specify a valid timestamp for the sortkey parameter. It should be in the form YYYYMMddhhmmss, a unix timestamp or "now".' ),
 74+ );
 75+ }
4776
4877 public function getExamples() {
4978 return array(
@@ -743,7 +772,7 @@
744773
745774 // Validate timestamp
746775 if ( empty( $params['sortkey'] ) ) {
747 - $this->dieUsage( 'You must specify a valid timestamp for the sortkey' .
 776+ $this->dieUsage( 'You must specify a valid timestamp for the sortkey ' .
748777 'parameter. It should be in the form YYYYMMddhhmmss, a ' .
749778 'unix timestamp or "now".', 'invalid-sortkey' );
750779 return;

Follow-up revisions

RevisionCommit summaryAuthorDate
r62462Followup to r62425...reedy14:40, 14 February 2010
r62463Another followup to r62425...reedy14:43, 14 February 2010

Comments

#Comment by Catrope (talk | contribs)   14:11, 14 February 2010
+			array( 'code' => 'sessionfailure', 'info' => '' ),
+			array( 'code' => 'action', 'info' => 'missing-param' ),

These look bad; is the documentation wrong or is the API module using dieUsage() in the wrong way?

#Comment by Reedy (talk | contribs)   14:33, 14 February 2010

For the 'sessionfailure', that is all that the module uses...

And for the missing param, thats how it is...

if ( empty( $params['token'] ) || !$wgUser->matchEditToken( $params['token'] ) ) { $this->dieUsage( 'sessionfailure' ); return; }

if ( empty( $params['threadaction'] ) ) { $this->dieUsage( 'missing-param', 'action' ); return; }


I think we can fix those up...

#Comment by Reedy (talk | contribs)   14:35, 14 February 2010

ApiEditPage uses

if ( !$wgUser->matchEditToken( $params['token'] ) ) $this->dieUsageMsg( array( 'sessionfailure' ) );

Not the same... Presumably the return is probably useless too?

Status & tagging log