From fda4d48e843a8a0b49faa013818af94180e8148e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Fri, 5 Aug 2016 22:50:11 +0000 Subject: [PATCH] Revert "API: Remove deprecated response values from action=login" Revert commit 23e5cdb5034dca5bbdfc2ac9c111c5fac20ff579 temporarily so Pywikibot users can catch up with API changes Bug: T121527 Bug: T142155 Change-Id: I3879a5d76a1727dd653daeebc79d4d9cabd0332e --- includes/api/ApiLogin.php | 13 +++++++++++++ tests/phpunit/includes/api/ApiLoginTest.php | 1 + 2 files changed, 14 insertions(+) diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 1dadc0721a..0e4c6e0c84 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -212,6 +212,15 @@ class ApiLogin extends ApiBase { $result['lguserid'] = intval( $user->getId() ); $result['lgusername'] = $user->getName(); + + // @todo: These are deprecated, and should be removed at some + // point (1.28 at the earliest, and see T121527). They were ok + // when the core cookie-based login was the only thing, but + // CentralAuth broke that a while back and + // SessionManager/AuthManager *really* break it. + $result['lgtoken'] = $user->getToken(); + $result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' ); + $result['sessionid'] = $session->getId(); break; case 'NeedToken': @@ -219,6 +228,10 @@ class ApiLogin extends ApiBase { $this->setWarning( 'Fetching a token via action=login is deprecated. ' . 'Use action=query&meta=tokens&type=login instead.' ); $this->logFeatureUsage( 'action=login&!lgtoken' ); + + // @todo: See above about deprecation + $result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' ); + $result['sessionid'] = $session->getId(); break; case 'WrongToken': diff --git a/tests/phpunit/includes/api/ApiLoginTest.php b/tests/phpunit/includes/api/ApiLoginTest.php index 917a6adaff..155a9dd982 100644 --- a/tests/phpunit/includes/api/ApiLoginTest.php +++ b/tests/phpunit/includes/api/ApiLoginTest.php @@ -190,6 +190,7 @@ class ApiLoginTest extends ApiTestCase { $this->assertArrayHasKey( "login", $data[0] ); $this->assertArrayHasKey( "result", $data[0]['login'] ); $this->assertEquals( "Success", $data[0]['login']['result'] ); + $this->assertArrayHasKey( 'lgtoken', $data[0]['login'] ); } public function testBotPassword() { -- 2.20.1