From 3fe7b6912bf504c20693f15f3e271858b99db167 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 27 Jun 2010 19:22:46 +0000 Subject: [PATCH] * (bug 24136) unknownerror when adding new section without summary, but forceditsummary Handle AS_SUMMARY_NEEDED in ApiEditPage Fixup some braces --- RELEASE-NOTES | 3 ++- includes/api/ApiBase.php | 1 + includes/api/ApiEditPage.php | 21 +++++++++------------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 541834e7cb..4e56a6852f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -245,7 +245,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 24016) API: Handle parameters specified in simple string syntax ( 'paramname' => 'defaultval' ) correctly when outputting help * (bug 24089) Logevents causes PHP Notice if leprop=title isn't supplied -* (bug 23473) - Give description of properties on all modules +* (bug 23473) Give description of properties on all modules +* (bug 24136) unknownerror when adding new section without summary, but forceditsummary === Languages updated in 1.17 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 3656c2c2e7..60231693e6 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -928,6 +928,7 @@ abstract class ApiBase { 'userrights-nodatabase' => array( 'code' => 'nosuchdatabase', 'info' => "Database ``\$1'' does not exist or is not local" ), 'nouserspecified' => array( 'code' => 'invaliduser', 'info' => "Invalid username ``\$1''" ), 'noname' => array( 'code' => 'invaliduser', 'info' => "Invalid username ``\$1''" ), + 'summaryrequired' => array( 'code' => 'summaryrequired', 'info' => 'Summary required'), // API-specific messages 'readrequired' => array( 'code' => 'readapidenied', 'info' => "You need read permission to use this module" ), diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 48759bacc0..7cd576967d 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -117,16 +117,14 @@ class ApiEditPage extends ApiBase { $undoafterRev = Revision::newFromID( $params['undoafter'] ); } $undoRev = Revision::newFromID( $params['undo'] ); - if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) - { + if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) { $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) ); } if ( $params['undoafter'] == 0 ) { $undoafterRev = $undoRev->getPrevious(); } - if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) - { + if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) { $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) ); } @@ -144,8 +142,7 @@ class ApiEditPage extends ApiBase { $params['text'] = $newtext; // If no summary was given and we only undid one rev, // use an autosummary - if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) - { + if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) { $params['summary'] = wfMsgForContent( 'undo-summary', $params['undo'], $undoRev->getUserText() ); } } @@ -170,8 +167,7 @@ class ApiEditPage extends ApiBase { // Watch out for basetimestamp == '' // wfTimestamp() treats it as NOW, almost certainly causing an edit conflict - if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) - { + if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) { $reqArr['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] ); } else { $reqArr['wpEdittime'] = $articleObj->getTimestamp(); @@ -193,8 +189,7 @@ class ApiEditPage extends ApiBase { if ( !is_null( $params['section'] ) ) { $section = intval( $params['section'] ); - if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) - { + if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) { $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" ); } $reqArr['wpSection'] = $params['section']; @@ -229,8 +224,7 @@ class ApiEditPage extends ApiBase { } $r = array(); - if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) - { + if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) { if ( count( $r ) ) { $r['result'] = 'Failure'; $this->getResult()->addValue( null, $this->getModuleName(), $r ); @@ -324,6 +318,9 @@ class ApiEditPage extends ApiBase { $newArticle->getTimestamp() ); } break; + + case EditPage::AS_SUMMARY_NEEDED: + $this->dieUsageMsg( array( 'summaryrequired' ) ); case EditPage::AS_END: // This usually means some kind of race condition -- 2.20.1