From 9645885413f202c62b12782cf2b1c8c12f655e0f Mon Sep 17 00:00:00 2001 From: hectorhammett Date: Fri, 1 May 2026 19:50:58 +0000 Subject: [PATCH] Remove obsolete ADC keyfile check --- Core/src/ClientTrait.php | 20 +------------------- Core/tests/Unit/ClientTraitTest.php | 27 --------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/Core/src/ClientTrait.php b/Core/src/ClientTrait.php index 1f6e5cd5f245..3f25e88875be 100644 --- a/Core/src/ClientTrait.php +++ b/Core/src/ClientTrait.php @@ -182,8 +182,7 @@ private function detectProjectId(array $config) 'projectId' => null, 'projectIdRequired' => false, 'hasEmulator' => false, - 'preferNumericProjectId' => false, - 'suppressKeyFileNotice' => false + 'preferNumericProjectId' => false ]; if ($config['projectId']) { @@ -202,23 +201,6 @@ private function detectProjectId(array $config) if (isset($config['keyFile']['project_id'])) { return $config['keyFile']['project_id']; } - - if ($config['suppressKeyFileNotice'] !== true) { - $serviceAccountUri = 'https://cloud.google.com/iam/docs/' . - 'creating-managing-service-account-keys#creating_service_account_keys'; - - trigger_error( - sprintf( - 'A keyfile was given, but it does not contain a project ' . - 'ID. This can indicate an old and obsolete keyfile, ' . - 'in which case you should create a new one. To suppress ' . - 'this message, set `suppressKeyFileNotice` to `true` in your client configuration. ' . - 'To learn more about generating new keys, see this URL: %s', - $serviceAccountUri - ), - E_USER_NOTICE - ); - } } if (getenv('GOOGLE_CLOUD_PROJECT')) { diff --git a/Core/tests/Unit/ClientTraitTest.php b/Core/tests/Unit/ClientTraitTest.php index 5d9a28ef2a55..867497fe3dda 100644 --- a/Core/tests/Unit/ClientTraitTest.php +++ b/Core/tests/Unit/ClientTraitTest.php @@ -358,33 +358,6 @@ public function testDetectProjectIdEmulator() $this->assertEquals($projectId, $res); } - - public function testDetectProjectIdWithKeyfileMissingProjectId() - { - set_error_handler(static function (int $errno, string $errstr): never { - throw new Exception($errstr, $errno); - }, E_USER_NOTICE); - $this->expectException(Exception::class); - $this->expectExceptionMessage('A keyfile was given'); - - $trait = TestHelpers::impl(ClientTrait::class); - - $res = $trait->call('detectProjectId', [[ - 'keyFile' => [] - ]]); - } - - public function testDetectProjectIdWithKeyfileMissingProjectIdSuppressNotice() - { - $trait = TestHelpers::impl(ClientTraitStubOnGceReturnsFalse::class); - - $res = $trait->call('detectProjectId', [[ - 'keyFile' => [], - 'suppressKeyFileNotice' => true - ]]); - - $this->assertTrue(true); - } } //@codingStandardsIgnoreStart