From f6c6be3a980403b47d6e0aa75df083b4ea34352e Mon Sep 17 00:00:00 2001 From: Reedy Date: Fri, 13 Dec 2024 13:44:36 +0000 Subject: [PATCH] UserStatementProvider: Cast 'sub' to be a string Bug: T382139 Change-Id: I4b9f7d902b175951f0cf4e053d2949951c134814 --- src/UserStatementProvider.php | 3 ++- tests/phpunit/UserStatementProviderTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/UserStatementProvider.php b/src/UserStatementProvider.php index 0914a73f..f4284fc3 100644 --- a/src/UserStatementProvider.php +++ b/src/UserStatementProvider.php @@ -104,7 +104,8 @@ public function getUserStatement() { */ public function getUserProfile() { $profile = [ - 'sub' => Utils::getCentralIdFromLocalUser( $this->user ), + // 'sub' should be a StringOrURI - https://www.rfc-editor.org/rfc/rfc7519.html#section-4.1.2 + 'sub' => (string)Utils::getCentralIdFromLocalUser( $this->user ), ]; // Include some MediaWiki info about the user if ( !$this->user->isHidden() ) { diff --git a/tests/phpunit/UserStatementProviderTest.php b/tests/phpunit/UserStatementProviderTest.php index 4a13afa6..d59ad0f4 100644 --- a/tests/phpunit/UserStatementProviderTest.php +++ b/tests/phpunit/UserStatementProviderTest.php @@ -63,7 +63,7 @@ public function testGetUserStatement() { $userProfile = $userStatementProvider->getUserProfile(); foreach ( [ $userStatement, $userProfile ] as $data ) { - $this->assertSame( $user->getId(), $data['sub'] ); + $this->assertSame( (string)$user->getId(), $data['sub'] ); $this->assertSame( $user->getName(), $data['username'] ); $this->assertSame( 0, $data['editcount'] ); $this->assertSame( false, $data['confirmed_email'] );