r26238 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26237‎ | r26238 | r26239 >
Date:05:55, 29 September 2007
Author:yurik
Status:old
Tags:
Comment:
bug fixes and reorg for api edit.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/EditPage.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/SpecialUpload.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/api/ApiEditPage.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/api/ApiTalk.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/EditPage.php
@@ -1,4 +1,3 @@
2 -
32 <?php
43 /**
54 * Contains the EditPage class
@@ -437,8 +436,7 @@
438437 # in the back door with a hand-edited submission URL.
439438
440439 if ( 'save' == $this->formtype ) {
441 - $res = $this->processAttemptSave($this->attemptSave());
442 - if ( !$res ) {
 440+ if ( !$this->attemptSave() ) {
443441 wfProfileOut( "$fname-business-end" );
444442 wfProfileOut( $fname );
445443 return;
@@ -647,10 +645,10 @@
648646 }
649647
650648 /**
651 - * Attempt submission
652 - * @return bool false if output is done, true if the rest of the form should be displayed
 649+ * Attempt submission (no UI)
 650+ * @return one of the constants describing the result
653651 */
654 - function attemptSave() {
 652+ function internalAttemptSave( &$result ) {
655653 global $wgSpamRegex, $wgFilterCallback, $wgUser, $wgOut, $wgParser;
656654 global $wgMaxArticleSize;
657655
@@ -671,6 +669,7 @@
672670 # Check for spam
673671 $matches = array();
674672 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
 673+ $resultDetails['spam'] = $matches[0];
675674 wfProfileOut( "$fname-checks" );
676675 wfProfileOut( $fname );
677676 return self::AS_SPAM_ERROR;
@@ -701,6 +700,7 @@
702701 $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
703702 if ( $this->kblength > $wgMaxArticleSize ) {
704703 // Error will be displayed by showEditForm()
 704+ $this->tooBig = true;
705705 wfProfileOut( "$fname-checks" );
706706 wfProfileOut( $fname );
707707 return self::AS_CONTENT_TOO_BIG;
@@ -2106,9 +2106,15 @@
21072107 }
21082108 }
21092109
2110 - function processAttemptSave($value) {
 2110+ /**
 2111+ * Attempt submission
 2112+ * @return bool false if output is done, true if the rest of the form should be displayed
 2113+ */
 2114+ function attemptSave() {
21112115 global $wgUser, $wgOut;
21122116
 2117+ $resultDetails = false;
 2118+ $value = $this->internalAttemptSave( &$resultDetails );
21132119 switch ($value)
21142120 {
21152121 case self::AS_END:
@@ -2173,7 +2179,7 @@
21742180 return true;
21752181
21762182 case self::AS_SPAM_ERROR:
2177 - $this->spamPage ( $matches[0] );
 2183+ $this->spamPage ( $resultDetails['spam'] );
21782184 return false;
21792185
21802186 case self::AS_FILTERING:
Index: branches/ApiEdit_Vodafone/includes/SpecialUpload.php
@@ -346,8 +346,8 @@
347347 *
348348 * @access private
349349 */
350 - function internalProcessUpload( &$resultDetails="" ) {
351 - global $wgUser, $wgOut;
 350+ function internalProcessUpload( &$resultDetails ) {
 351+ global $wgUser;
352352
353353 if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) )
354354 {
Index: branches/ApiEdit_Vodafone/includes/api/ApiTalk.php
@@ -181,7 +181,8 @@
182182 $editForm = new EditPage($myDiscussion);
183183 $editForm->mTitle = $object_discussion_title;
184184 $editForm->importFormData($params);
185 - $value=$editForm->attemptSave();
 185+ $resultDetails = false;
 186+ $value=$editForm->internalAttemptSave( &$resultDetails );
186187 }
187188 }
188189 }
Index: branches/ApiEdit_Vodafone/includes/api/ApiEditPage.php
@@ -125,7 +125,8 @@
126126 $editForm->mTitle = $object_title;
127127 $editForm->importFormData($params);
128128
129 - $value=$editForm->attemptSave();
 129+ $resultDetails = false;
 130+ $value=$editForm->internalAttemptSave( &$resultDetails );
130131 }
131132 }
132133 }

Status & tagging log