r62464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62463‎ | r62464 | r62465 >
Date:14:57, 14 February 2010
Author:reedy
Status:ok
Tags:
Comment:
Normalise ApiThreadAction to ApiStyle

Remove dupe from getPossibleErrors

Change missing-param to missingparam, and dieUsageMsg for those (api predefined error)

Remove unneeded return; after dieUsage/dieUsageMsg's
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -48,6 +48,8 @@
4949 return array(
5050 array( 'sessionfailure' ),
5151 array( 'missingparam', 'action' ),
 52+ array( 'missingparam', 'talkpage' ),
 53+ array( 'missingparam', 'subject' ),
5254 array( 'code' => 'too-many-threads', 'info' => 'You may only split one thread at a time' ),
5355 array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to split' ),
5456 array( 'code' => 'already-top-level', 'info' => 'This thread is already a top-level thread.' ),
@@ -55,10 +57,8 @@
5658 array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to merge' ),
5759 array( 'code' => 'no-parent-thread', 'info' => 'You must specify a new parent thread to merge beneath' ),
5860 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' ),
6061 array( 'code' => 'invalid-talkpage', 'info' => 'The talkpage you specified is invalid, or does not have discussion threading enabled.' ),
6162 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' ),
6363 array( 'code' => 'invalid-subject', 'info' => 'The subject you specified is not valid' ),
6464 array( 'code' => 'no-text', 'info' => 'You must include text in your post' ),
6565 array( 'code' => 'too-many-threads', 'info' => 'You may only edit one thread at a time' ),
@@ -67,7 +67,6 @@
6868 array( 'code' => 'perm_result-protected', 'info' => 'You cannot reply to this thread, because the perm_result is protected from replies.' ),
6969 array( 'code' => 'too-many-threads', 'info' => 'You may only change the subject of one thread at a time' ),
7070 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' ),
7271 array( 'code' => 'no-specified-threads', 'info' => 'You must specify a thread to set the sortkey of' ),
7372 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".' ),
7473 );
@@ -207,11 +206,9 @@
208207 if ( count( $threads ) > 1 ) {
209208 $this->dieUsage( 'You may only split one thread at a time',
210209 'too-many-threads' );
211 - return;
212210 } elseif ( count( $threads ) < 1 ) {
213211 $this->dieUsage( 'You must specify a thread to split',
214212 'no-specified-threads' );
215 - return;
216213 }
217214
218215 $thread = array_pop( $threads );
@@ -269,13 +266,11 @@
270267 if ( count( $threads ) < 1 ) {
271268 $this->dieUsage( 'You must specify a thread to merge',
272269 'no-specified-threads' );
273 - return;
274270 }
275271
276272 if ( empty( $params['newparent'] ) ) {
277273 $this->dieUsage( 'You must specify a new parent thread to merge beneath',
278274 'no-parent-thread' );
279 - return;
280275 }
281276
282277 $newParent = $params['newparent'];
@@ -290,7 +285,6 @@
291286 if ( !$newParent ) {
292287 $this->dieUsage( 'The parent thread you specified was neither the title ' .
293288 'of a thread, nor a thread ID.', 'invalid-parent-thread' );
294 - return;
295289 }
296290
297291 // Pull a reason, if applicable.
@@ -324,10 +318,7 @@
325319
326320 // Validate talkpage parameters
327321 if ( empty( $params['talkpage'] ) ) {
328 - $this->dieUsage( 'You must specify a talk-page to post the thread to',
329 - 'missing-param' );
330 -
331 - return;
 322+ $this->dieUsageMsg( array( 'missingparam', 'talkpage' ) );
332323 }
333324
334325 $talkpageTitle = Title::newFromText( $params['talkpage'] );
@@ -335,7 +326,6 @@
336327 if ( !$talkpageTitle || !LqtDispatch::isLqtPage( $talkpageTitle ) ) {
337328 $this->dieUsage( 'The talkpage you specified is invalid, or does not ' .
338329 'have discussion threading enabled.', 'invalid-talkpage' );
339 - return;
340330 }
341331 $talkpage = new Article( $talkpageTitle );
342332
@@ -343,14 +333,11 @@
344334 if ( Thread::canUserPost( $wgUser, $talkpage ) !== true ) {
345335 $this->dieUsage( 'You cannot post to the specified talkpage, ' .
346336 'because it is protected from new posts', 'talkpage-protected' );
347 - return;
348337 }
349338
350339 // Validate subject, generate a title
351340 if ( empty( $params['subject'] ) ) {
352 - $this->dieUsage( 'You must specify a thread subject',
353 - 'missing-param' );
354 - return;
 341+ $this->dieUsageMsg( array( 'missingparam', 'subject' ) );
355342 }
356343
357344 $bump = isset( $params['bump'] ) ? $params['bump'] : null;
@@ -362,15 +349,12 @@
363350 if ( !$subjectOk ) {
364351 $this->dieUsage( 'The subject you specified is not valid',
365352 'invalid-subject' );
366 -
367 - return;
368353 }
369354 $article = new Article( $title );
370355
371356 // Check for text
372357 if ( empty( $params['text'] ) ) {
373358 $this->dieUsage( 'You must include text in your post', 'no-text' );
374 - return;
375359 }
376360 $text = $params['text'];
377361
@@ -452,11 +436,9 @@
453437 if ( count($threads) > 1 ) {
454438 $this->dieUsage( 'You may only edit one thread at a time',
455439 'too-many-threads' );
456 - return;
457440 } elseif ( count($threads) < 1 ) {
458441 $this->dieUsage( 'You must specify a thread to edit',
459442 'no-specified-threads' );
460 - return;
461443 }
462444
463445 $thread = array_pop( $threads );
@@ -478,14 +460,11 @@
479461 if ( !$subjectOk ) {
480462 $this->dieUsage( 'The subject you specified is not valid',
481463 'invalid-subject' );
482 -
483 - return;
484464 }
485465
486466 // Check for text
487467 if ( empty( $params['text'] ) ) {
488468 $this->dieUsage( 'You must include text in your post', 'no-text' );
489 - return;
490469 }
491470 $text = $params['text'];
492471
@@ -567,11 +546,9 @@
568547 if ( count( $threads ) > 1 ) {
569548 $this->dieUsage( 'You may only reply to one thread at a time',
570549 'too-many-threads' );
571 - return;
572550 } elseif ( count( $threads ) < 1 ) {
573551 $this->dieUsage( 'You must specify a thread to reply to',
574552 'no-specified-threads' );
575 - return;
576553 }
577554 $replyTo = array_pop( $threads );
578555
@@ -581,13 +558,11 @@
582559 $this->dieUsage( "You cannot reply to this thread, because the " .
583560 $perm_result . " is protected from replies.",
584561 $perm_result . '-protected' );
585 - return;
586562 }
587563
588564 // Validate text parameter
589565 if ( empty( $params['text'] ) ) {
590566 $this->dieUsage( 'You must include text in your post', 'no-text' );
591 - return;
592567 }
593568
594569 $text = $params['text'];
@@ -710,19 +685,15 @@
711686 if ( count( $threads ) > 1 ) {
712687 $this->dieUsage( 'You may only change the subject of one thread at a time',
713688 'too-many-threads' );
714 - return;
715689 } elseif ( count( $threads ) < 1 ) {
716690 $this->dieUsage( 'You must specify a thread to change the subject of',
717691 'no-specified-threads' );
718 - return;
719692 }
720693 $thread = array_pop( $threads );
721694
722695 // Validate subject
723696 if ( empty( $params['subject'] ) ) {
724 - $this->dieUsage( 'You must specify a thread subject',
725 - 'missing-param' );
726 - return;
 697+ $this->dieUsageMsg( array( 'missingparam', 'subject' ) );
727698 }
728699
729700 $talkpage = $thread->article();
@@ -734,8 +705,6 @@
735706 if ( !$subjectOk ) {
736707 $this->dieUsage( 'The subject you specified is not valid',
737708 'invalid-subject' );
738 -
739 - return;
740709 }
741710
742711 $reason = null;
@@ -765,7 +734,6 @@
766735 if ( !count( $threads ) ) {
767736 $this->dieUsage( 'You must specify a thread to set the sortkey of',
768737 'no-specified-threads' );
769 - return;
770738 }
771739
772740 // Validate timestamp
@@ -773,7 +741,6 @@
774742 $this->dieUsage( 'You must specify a valid timestamp for the sortkey ' .
775743 'parameter. It should be in the form YYYYMMddhhmmss, a ' .
776744 'unix timestamp or "now".', 'invalid-sortkey' );
777 - return;
778745 }
779746
780747 $ts = $params['sortkey'];
@@ -786,7 +753,6 @@
787754 $this->dieUsage( 'You must specify a valid timestamp for the sortkey' .
788755 'parameter. It should be in the form YYYYMMddhhmmss, a ' .
789756 'unix timestamp or "now".', 'invalid-sortkey' );
790 - return;
791757 }
792758
793759 $reason = null;
@@ -815,4 +781,4 @@
816782 public function getVersion() {
817783 return __CLASS__ . ': $Id: $';
818784 }
819 -}
 785+}
\ No newline at end of file

Status & tagging log