diff options
author | daniel <dkinzler@wikimedia.org> | 2020-03-05 22:23:07 +0100 |
---|---|---|
committer | daniel <dkinzler@wikimedia.org> | 2020-03-11 13:29:09 +0100 |
commit | 3ebd55ed471f119744e955d7ee14fae701ab7995 (patch) | |
tree | b8e843f2c203c6bba78bab5149e9435de85cb803 /includes/api/ApiEditPage.php | |
parent | 5f1362ccb56bc95d76f6337ca3ef706cd74a9e10 (diff) | |
download | mediawikicore-3ebd55ed471f119744e955d7ee14fae701ab7995.tar.gz mediawikicore-3ebd55ed471f119744e955d7ee14fae701ab7995.zip |
ApiEditPage: add baserevid parameter
This adds a baserevid parameter for detecting edit conflicts, as an
alternative to the less precise basetimestamp parameter. This is
introduced for parity with and use by the new REST api.
Bug: T230843
Bug: T34037
Change-Id: Id7565018f66860b5c2ba688777508db1b88700ae
Diffstat (limited to 'includes/api/ApiEditPage.php')
-rw-r--r-- | includes/api/ApiEditPage.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index c9487857108f..0307768d2f2e 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -301,11 +301,18 @@ class ApiEditPage extends ApiBase { $requestArray['wpUndidRevision'] = $params['undo']; } + // Skip for baserevid == null or '' or '0' or 0 + if ( !empty( $params['baserevid'] ) ) { + $requestArray['editRevId'] = $params['baserevid']; + } + // Watch out for basetimestamp == '' or '0' // It gets treated as NOW, almost certainly causing an edit conflict if ( $params['basetimestamp'] !== null && (bool)$this->getMain()->getVal( 'basetimestamp' ) ) { $requestArray['wpEdittime'] = $params['basetimestamp']; - } else { + } elseif ( empty( $params['baserevid'] ) ) { + // Only set if baserevid is not set. Otherwise, conflicts would be ignored, + // due to the way userWasLastToEdit() works. $requestArray['wpEdittime'] = $pageObj->getTimestamp(); } @@ -545,6 +552,9 @@ class ApiEditPage extends ApiBase { 'minor' => false, 'notminor' => false, 'bot' => false, + 'baserevid' => [ + ApiBase::PARAM_TYPE => 'integer', + ], 'basetimestamp' => [ ApiBase::PARAM_TYPE => 'timestamp', ], @@ -612,7 +622,7 @@ class ApiEditPage extends ApiBase { protected function getExamplesMessages() { return [ 'action=edit&title=Test&summary=test%20summary&' . - 'text=article%20content&basetimestamp=2007-08-24T12:34:54Z&token=123ABC' + 'text=article%20content&baserevid=1234567&token=123ABC' => 'apihelp-edit-example-edit', 'action=edit&title=Test&summary=NOTOC&minor=&' . 'prependtext=__NOTOC__%0A&basetimestamp=2007-08-24T12:34:54Z&token=123ABC' |