WMDE-leszek has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397837 )

Change subject: Return the revision ID after adding form with wblexemeaddform 
API
......................................................................

Return the revision ID after adding form with wblexemeaddform API

Needed to be able to update the base revision of the page
in the front-end code (e.g. to be able to add a statement to
the added form without needed to reload the page).

Bug: T181253
Change-Id: Ic5d5a83f332580e463ee084ea64de7bcb11fba6f
---
M src/Api/AddForm.php
M tests/phpunit/mediawiki/Api/AddFormTest.php
2 files changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme 
refs/changes/37/397837/1

diff --git a/src/Api/AddForm.php b/src/Api/AddForm.php
index 5ecf7a5..0cec37a 100644
--- a/src/Api/AddForm.php
+++ b/src/Api/AddForm.php
@@ -197,11 +197,15 @@
 
                $apiResult = $this->getResult();
 
+               $statusValue = $status->getValue();
+               $revisionId = $statusValue['revision']->getRevisionId();
+
                $serializedForm = $this->formSerializer->serialize( $newForm );
 
                // TODO: Do we really need `success` property in response?
                $apiResult->addValue( null, 'success', 1 );
                $apiResult->addValue( null, 'form', $serializedForm );
+               $apiResult->addValue( null, 'lastrevid', $revisionId );
        }
 
        /**
diff --git a/tests/phpunit/mediawiki/Api/AddFormTest.php 
b/tests/phpunit/mediawiki/Api/AddFormTest.php
index 5533ce8..94f3d11 100644
--- a/tests/phpunit/mediawiki/Api/AddFormTest.php
+++ b/tests/phpunit/mediawiki/Api/AddFormTest.php
@@ -183,6 +183,24 @@
                $this->assertEquals( '/* add-form:1||L1-F1 */ goat', 
$revision->getComment() );
        }
 
+       public function testResponseContainsRevisionId() {
+               $lexeme = NewLexeme::havingId( 'L1' )->build();
+
+               $this->saveLexeme( $lexeme );
+
+               $params = [
+                       'action' => 'wblexemeaddform',
+                       'lexemeId' => 'L1',
+                       'data' => $this->getDataParam()
+               ];
+
+               list( $result, ) = $this->doApiRequestWithToken( $params );
+
+               $lexemeRevision = $this->getCurrentRevisionForLexeme( 'L1' );
+
+               $this->assertEquals( $lexemeRevision->getRevisionId(), 
$result['lastrevid'] );
+       }
+
        private function saveLexeme( Lexeme $lexeme ) {
                $store = WikibaseRepo::getDefaultInstance()->getEntityStore();
 

-- 
To view, visit https://gerrit.wikimedia.org/r/397837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5d5a83f332580e463ee084ea64de7bcb11fba6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to