http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94640
Revision: 94640 Author: ialex Date: 2011-08-16 14:45:37 +0000 (Tue, 16 Aug 2011) Log Message: ----------- Removed usage of internal API call in Special:AddComment that was broken by r83080; using WikiPage::doEdit() (or Article::doEdit() in earlier MW versions) instead. Modified Paths: -------------- trunk/extensions/Commentbox/SpecialAddComment_body.php Modified: trunk/extensions/Commentbox/SpecialAddComment_body.php =================================================================== --- trunk/extensions/Commentbox/SpecialAddComment_body.php 2011-08-16 14:18:19 UTC (rev 94639) +++ trunk/extensions/Commentbox/SpecialAddComment_body.php 2011-08-16 14:45:37 UTC (rev 94640) @@ -75,37 +75,15 @@ // Append <br /> after each newline, except if the user started a new paragraph $Comment = preg_replace( '/(?<!\n)\n(?!\n)/', "<br />\n", $Comment ); $text .= "\n\n" . $subject . $Comment . "\n<br />" . $sig; - try { - $req = new FauxRequest( array( - 'action' => 'edit', - 'title' => $title->getPrefixedText(), - 'text' => $text, - 'summary' => wfMsgForContent( 'commentbox-log' ), - 'token' => $wgUser->editToken(), - ), true ); - $api = new ApiMain( $req, true ); - $api->execute(); - wfDebug( "Completed API-Save\n" ); - // we only reach this point if Api doesn't throw an exception - $data = $api->getResultData(); - if ( $data['edit']['result'] == 'Failure' ) { - $spamurl = $data['edit']['spamblacklist']; - if ( $spamurl != '' ) - throw new Exception( "Die Seite enthaelt die Spam-Url ``{$spamurl}''" ); - else - throw new Exception( "Unbekannter Fehler" ); - } - } catch ( Exception $e ) { - global $wgOut; + $status = $article->doEdit( $text, wfMsgForContent( 'commentbox-log' ) ); + + if ( $status->isOK() ) { + $wgOut->redirect( $title->getFullURL() ); + } else { $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) ); - $wgOut->addHTML( "<div class='errorbox'>" . htmlspecialchars( $e->getMessage() ) . "</div><br clear='both' />" ); - if ( $title != null ) - $wgOut->returnToMain( false, $title ); - return; + $wgOut->addWikiText( $status->getWikiText() ); + $wgOut->returnToMain( false, $title ); } - - $wgOut->redirect( $title->getFullURL() ); - return; } function fail( $str, $title = null ) { _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs