Skip to content

Commit 4fea864

Browse files
Update to version 1.39.0
1 parent e168796 commit 4fea864

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": ["rpc"],
66
"homepage": "https://grpc.io",
77
"license": "Apache-2.0",
8-
"version": "1.38.0",
8+
"version": "1.39.0",
99
"require": {
1010
"php": ">=7.0.0"
1111
},

src/lib/BaseStub.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,22 @@ public function __construct($hostname, $opts, $channel = null)
8686
}
8787

8888
private static function updateOpts($opts) {
89-
if (!file_exists($composerFile = __DIR__.'/../../composer.json')) {
90-
// for grpc/grpc-php subpackage
91-
$composerFile = __DIR__.'/../composer.json';
92-
}
93-
$package_config = json_decode(file_get_contents($composerFile), true);
9489
if (!empty($opts['grpc.primary_user_agent'])) {
9590
$opts['grpc.primary_user_agent'] .= ' ';
9691
} else {
9792
$opts['grpc.primary_user_agent'] = '';
9893
}
99-
$opts['grpc.primary_user_agent'] .=
100-
'grpc-php/'.$package_config['version'];
94+
if (defined('\Grpc\VERSION')) {
95+
$version_str = \Grpc\VERSION;
96+
} else {
97+
if (!file_exists($composerFile = __DIR__.'/../../composer.json')) {
98+
// for grpc/grpc-php subpackage
99+
$composerFile = __DIR__.'/../composer.json';
100+
}
101+
$package_config = json_decode(file_get_contents($composerFile), true);
102+
$version_str = $package_config['version'];
103+
}
104+
$opts['grpc.primary_user_agent'] .= 'grpc-php/'.$version_str;
101105
if (!array_key_exists('credentials', $opts)) {
102106
throw new \Exception("The opts['credentials'] key is now ".
103107
'required. Please see one of the '.

0 commit comments

Comments
 (0)