jenkins-bot has submitted this change and it was merged.
Change subject: Return '' from getTokenSalt to enable token check
..
Return '' from getTokenSalt to enable token check
If getTokenSalt is not overwritten, it returns false,
disabling the token check in ApiMain. We forget about
this, but I don't think this was a big issue, since we
do our own token check in EditEntity (not the API module)
anyway.
Change-Id: I9395b65473167a205fb1970f5232b36a9a26bdd6
---
M repo/includes/api/ApiWikibase.php
M repo/tests/phpunit/includes/api/LinkTitlesTest.php
M repo/tests/phpunit/includes/api/ModifyTermTestCase.php
M repo/tests/phpunit/includes/api/SetAliasesTest.php
M repo/tests/phpunit/includes/api/SetSiteLinkTest.php
M repo/tests/phpunit/includes/api/WikibaseApiTestCase.php
6 files changed, 53 insertions(+), 32 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
WikidataJenkins: Verified
jenkins-bot: Verified
diff --git a/repo/includes/api/ApiWikibase.php
b/repo/includes/api/ApiWikibase.php
index a8ddaab..ea23b53 100644
--- a/repo/includes/api/ApiWikibase.php
+++ b/repo/includes/api/ApiWikibase.php
@@ -215,6 +215,13 @@
}
/**
+* @see ApiBase::getTokenSalt()
+*/
+ public function getTokenSalt() {
+ return $this-needsToken() ? '' : false;
+ }
+
+ /**
* @see ApiBase::mustBePosted()
*/
public function mustBePosted() {
diff --git a/repo/tests/phpunit/includes/api/LinkTitlesTest.php
b/repo/tests/phpunit/includes/api/LinkTitlesTest.php
index 7ee0d6e..4a126fc 100644
--- a/repo/tests/phpunit/includes/api/LinkTitlesTest.php
+++ b/repo/tests/phpunit/includes/api/LinkTitlesTest.php
@@ -87,28 +87,31 @@
public static function provideLinkTitleExceptions(){
return array(
- array( //0 badtoken
+ array( //0 notoken
'p' = array( 'tosite' = 'nnwiki', 'totitle'
= 'Oslo', 'fromsite' = 'nowiki', 'fromtitle' = 'AnotherPage' ),
- 'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'badtoken', 'message' = 'loss of session data' ) )
),
- array( //1 add two links already exist together
+ 'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'notoken', 'message' = 'The token parameter must
be set' ) ) ),
+ array( //1 badtoken
+ 'p' = array( 'tosite' = 'nnwiki', 'totitle'
= 'Oslo', 'fromsite' = 'nowiki', 'fromtitle' = 'AnotherPage', 'token' =
'+\\' ),
+ 'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'badtoken', 'message' = 'Invalid token' ) ) ),
+ array( //2 add two links already exist together
'p' = array( 'tosite' = 'nnwiki', 'totitle'
= 'Oslo', 'fromsite' = 'nowiki', 'fromtitle' = 'Oslo' ),
'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'common-item') ) ),
- array( //2 add two links already exist together
+ array( //3 add two links already exist together
'p' = array( 'tosite' = 'dewiki', 'totitle'
= 'Berlin', 'fromsite' = 'nlwiki', 'fromtitle' = 'Oslo' ),
'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'no-common-item') ) ),
- array( //3 add two links from the same site
+ array( //4 add two links from the same site
'p' = array( 'tosite' = 'nnwiki', 'totitle'
= 'Hammerfest', 'fromsite' = 'nnwiki', 'fromtitle' = 'Hammerfest' ),
'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'param-illegal') ) ),
- array( //4 missing title
+ array( //5 missing title
'p' = array( 'tosite' = 'nnwiki', 'totitle'
= '', 'fromsite' = 'dewiki', 'fromtitle' = 'Hammerfest' ),
'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'param-illegal') ) ),
- array( //5 bad tosite
+ array( //6 bad tosite
'p' = array( 'tosite' = 'qwerty', 'totitle'
= 'Hammerfest', 'fromsite' = 'nnwiki', 'fromtitle' = 'Hammerfest' ),
'e' = array( 'exception' = array( 'type' =
'UsageException', 'code' = 'unknown_tosite') ) ),
- array( //6 bad fromsite
+ array( //7 bad fromsite
'p' = array( 'tosite' = 'nnwiki', 'totitle'
= 'Hammerfest', 'fromsite' = 'qwerty', 'fromtitle' = 'Hammerfest'