Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303317

Change subject: Revert "API: Remove deprecated response values from 
action=login"
......................................................................

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
---
M RELEASE-NOTES-1.28
M includes/api/ApiLogin.php
M tests/phpunit/includes/api/ApiLoginTest.php
3 files changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/303317/1

diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28
index 53fdc83..608bc56 100644
--- a/RELEASE-NOTES-1.28
+++ b/RELEASE-NOTES-1.28
@@ -53,9 +53,6 @@
   the value of $wgMaxArticleSize.
 * Property 'modulemessages' from action=parse&prop=modules was removed
   (deprecated since 1.26).
-* The following response properties from action=login, deprecated in 1.27, are
-  now removed: lgtoken, cookieprefix, sessionid. Clients should handle cookies
-  to properly manage session state.
 
 === Action API internal changes in 1.28 ===
 * Added a new hook, 'ApiMakeParserOptions', to allow extensions to better
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php
index 1dadc07..0e4c6e0 100644
--- a/includes/api/ApiLogin.php
+++ b/includes/api/ApiLogin.php
@@ -212,6 +212,15 @@
 
                                $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 @@
                                $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 917a6ad..155a9dd 100644
--- a/tests/phpunit/includes/api/ApiLoginTest.php
+++ b/tests/phpunit/includes/api/ApiLoginTest.php
@@ -190,6 +190,7 @@
                $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() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3879a5d76a1727dd653daeebc79d4d9cabd0332e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to