summaryrefslogtreecommitdiff
path: root/includes/api/ApiEditPage.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/api/ApiEditPage.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/api/ApiEditPage.php')
-rw-r--r--includes/api/ApiEditPage.php39
1 files changed, 28 insertions, 11 deletions
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index d10432f3..bc5dfa87 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -29,8 +29,10 @@ if (!defined('MEDIAWIKI')) {
}
/**
- * A query module to list all external URLs found on a given set of pages.
+ * A module that allows for editing and creating pages.
*
+ * Currently, this wraps around the EditPage class in an ugly way,
+ * EditPage.php should be rewritten to provide a cleaner interface
* @ingroup API
*/
class ApiEditPage extends ApiBase {
@@ -66,7 +68,7 @@ class ApiEditPage extends ApiBase {
$errors = $titleObj->getUserPermissionsErrors('edit', $wgUser);
if(!$titleObj->exists())
$errors = array_merge($errors, $titleObj->getUserPermissionsErrors('create', $wgUser));
- if(!empty($errors))
+ if(count($errors))
$this->dieUsageMsg($errors[0]);
$articleObj = new Article($titleObj);
@@ -98,8 +100,11 @@ class ApiEditPage extends ApiBase {
$reqArr['wpEdittime'] = wfTimestamp(TS_MW, $params['basetimestamp']);
else
$reqArr['wpEdittime'] = $articleObj->getTimestamp();
- # Fake wpStartime
- $reqArr['wpStarttime'] = $reqArr['wpEdittime'];
+ if(!is_null($params['starttimestamp']) && $params['starttimestamp'] != '')
+ $reqArr['wpStarttime'] = wfTimestamp(TS_MW, $params['starttimestamp']);
+ else
+ # Fake wpStartime
+ $reqArr['wpStarttime'] = $reqArr['wpEdittime'];
if($params['minor'] || (!$params['notminor'] && $wgUser->getOption('minordefault')))
$reqArr['wpMinoredit'] = '';
if($params['recreate'])
@@ -111,6 +116,8 @@ class ApiEditPage extends ApiBase {
$this->dieUsage("The section parameter must be set to an integer or 'new'", "invalidsection");
$reqArr['wpSection'] = $params['section'];
}
+ else
+ $reqArr['wpSection'] = '';
if($params['watch'])
$watch = true;
@@ -134,13 +141,13 @@ class ApiEditPage extends ApiBase {
# Handle CAPTCHA parameters
global $wgRequest;
if(isset($params['captchaid']))
- $wgRequest->data['wpCaptchaId'] = $params['captchaid'];
+ $wgRequest->setVal( 'wpCaptchaId', $params['captchaid'] );
if(isset($params['captchaword']))
- $wgRequest->data['wpCaptchaWord'] = $params['captchaword'];
+ $wgRequest->setVal( 'wpCaptchaWord', $params['captchaword'] );
$r = array();
if(!wfRunHooks('APIEditBeforeSave', array(&$ep, $ep->textbox1, &$r)))
{
- if(!empty($r))
+ if(count($r))
{
$r['result'] = "Failure";
$this->getResult()->addValue(null, $this->getModuleName(), $r);
@@ -200,18 +207,24 @@ class ApiEditPage extends ApiBase {
case EditPage::AS_CONFLICT_DETECTED:
$this->dieUsageMsg(array('editconflict'));
#case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
- #case EditPage::AS_TEXTBOX_EMPTY: Can't happen since we don't do sections
+ case EditPage::AS_TEXTBOX_EMPTY:
+ $this->dieUsageMsg(array('emptynewsection'));
case EditPage::AS_END:
# This usually means some kind of race condition
# or DB weirdness occurred. Throw an unknown error here.
- $this->dieUsageMsg(array('unknownerror', 'AS_END'));
+ $this->dieUsageMsg(array('unknownerror'));
case EditPage::AS_SUCCESS_NEW_ARTICLE:
$r['new'] = '';
case EditPage::AS_SUCCESS_UPDATE:
$r['result'] = "Success";
$r['pageid'] = $titleObj->getArticleID();
$r['title'] = $titleObj->getPrefixedText();
- $newRevId = $titleObj->getLatestRevId();
+ # HACK: We create a new Article object here because getRevIdFetched()
+ # refuses to be run twice, and because Title::getLatestRevId()
+ # won't fetch from the master unless we select for update, which we
+ # don't want to do.
+ $newArticle = new Article($titleObj);
+ $newRevId = $newArticle->getRevIdFetched();
if($newRevId == $oldRevId)
$r['nochange'] = '';
else
@@ -245,6 +258,7 @@ class ApiEditPage extends ApiBase {
'notminor' => false,
'bot' => false,
'basetimestamp' => null,
+ 'starttimestamp' => null,
'recreate' => false,
'createonly' => false,
'nocreate' => false,
@@ -271,6 +285,9 @@ class ApiEditPage extends ApiBase {
'basetimestamp' => array('Timestamp of the base revision (gotten through prop=revisions&rvprop=timestamp).',
'Used to detect edit conflicts; leave unset to ignore conflicts.'
),
+ 'starttimestamp' => array('Timestamp when you obtained the edit token.',
+ 'Used to detect edit conflicts; leave unset to ignore conflicts.'
+ ),
'recreate' => 'Override any errors about the article having been deleted in the meantime',
'createonly' => 'Don\'t edit the page if it exists already',
'nocreate' => 'Throw an error if the page doesn\'t exist',
@@ -294,6 +311,6 @@ class ApiEditPage extends ApiBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiEditPage.php 36309 2008-06-15 20:37:28Z catrope $';
+ return __CLASS__ . ': $Id: ApiEditPage.php 44394 2008-12-10 14:12:54Z catrope $';
}
}