diff options
-rw-r--r-- | includes/EditPage.php | 4 | ||||
-rw-r--r-- | tests/phpunit/includes/EditPageTest.php | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/includes/EditPage.php b/includes/EditPage.php index 73dc4d8b3657..e9adf4dc831e 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -272,7 +272,7 @@ class EditPage implements IEditObject { */ private $nosummary = false; - /** @var string + /** @var string|null * Timestamp of the latest revision of the page when editing was initiated * on the client. */ @@ -2594,7 +2594,7 @@ class EditPage implements IEditObject { $this->editRevId, RevisionStore::READ_LATEST ); - } else { + } elseif ( $this->edittime ) { $revRecord = $this->revisionStore->getRevisionByTimestamp( $this->getTitle(), $this->edittime, diff --git a/tests/phpunit/includes/EditPageTest.php b/tests/phpunit/includes/EditPageTest.php index e94a77533f76..e4735004fab0 100644 --- a/tests/phpunit/includes/EditPageTest.php +++ b/tests/phpunit/includes/EditPageTest.php @@ -939,4 +939,27 @@ hello ]; } + /** + * T277204 + * @covers EditPage + */ + public function testFalseyEditRevId() { + $elmosEdit['wpTextbox1'] = 'Elmo\'s text'; + $bertasEdit['wpTextbox1'] = 'Berta\'s text'; + + $elmosEdit['wpSummary'] = 'Elmo\'s edit'; + $bertasEdit['wpSummary'] = 'Bertas\'s edit'; + + $bertasEdit['editRevId'] = 0; + + $this->assertEdit( __METHOD__, + null, 'Elmo', $elmosEdit, + EditPage::AS_SUCCESS_NEW_ARTICLE, null, 'expected successful creation' ); + + // A successful update would probably be OK too. The important thing is + // that it doesn't throw an exception. + $this->assertEdit( __METHOD__, null, 'Berta', $bertasEdit, + EditPage::AS_CONFLICT_DETECTED, null, 'expected successful update' ); + } + } |