Skip to content

Commit 25b724d

Browse files
committed
fix descriptor fix for protobuf extension
1 parent c34532f commit 25b724d

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

BigQueryStorage/metadata/descriptor_fix.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ class DescriptorFix
3131
public static $is_initialized = false;
3232

3333
public static function initOnce() {
34-
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
35-
3634
if (static::$is_initialized == true) {
37-
return;
35+
return;
3836
}
3937

38+
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
4039
if ($pool instanceof \Google\Protobuf\Internal\DescriptorPool) {
4140
// add a no-op reference for "google.protobuf.DescriptorProto"
4241
$pool->addMessage('google.protobuf.DescriptorProto', \Google\Protobuf\DescriptorProto::class)->finalizeToPool();

SecurityCenter/metadata/descriptor_fix.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
namespace GPBMetadata\Google\Cloud\Securitycenter\V1 {
3030

31-
class KubernetesDescriptorFix
31+
class DescriptorFix
3232
{
3333
public static $is_initialized = false;
3434

@@ -37,19 +37,18 @@ public static function initOnce() {
3737
return;
3838
}
3939

40-
// This is required to load the descriptor for PBObject
41-
\GPBMetadata\Google\Cloud\Securitycenter\V1\Kubernetes::initOnce();
42-
4340
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
44-
$pool->addMessage(
45-
'google.cloud.securitycenter.v1.Kubernetes.Object',
46-
\Google\Cloud\SecurityCenter\V1\Kubernetes\PBObject::class
47-
)->finalizeToPool();
41+
if ($pool instanceof \Google\Protobuf\Internal\DescriptorPool) {
42+
$pool->addMessage(
43+
'google.cloud.securitycenter.v1.Kubernetes.Object',
44+
\Google\Cloud\SecurityCenter\V1\Kubernetes\PBObject::class
45+
)->finalizeToPool();
46+
}
4847

4948
static::$is_initialized = true;
5049
}
5150
}
5251

53-
KubernetesDescriptorFix::initOnce();
52+
DescriptorFix::initOnce();
5453
}
5554

0 commit comments

Comments
 (0)