fix(Firestore): use x-goog-request-params header#8267
Merged
Conversation
Contributor
Author
|
This requires more research, mostly because when calling the I can fix this by supplying the $stream = $firestoreClient->listen([
'headers' => [
'x-goog-request-params' => [
'database=' . $database
]
]
]);But this is non-intuitive and error-prone. With minimal changes to the GAPIC layer, we could make this work by only supplying the "database" option: $stream = $firestoreClient->listen(['database' => $database]);And follow this up by generating a "PHPDoc" explaining the database option's usage, which would hopefully be enough to make this discoverable and implementable by developers: /**
* Listens to changes. This method is only available via gRPC or WebChannel
* (not REST).
*
* @example samples/V1/FirestoreClient/listen.php
*
* @param array $callOptions {
* Optional.
*
+ * @type string $datbase
+ * Set the database of the call, to be added as a routing header
* @type int $timeoutMillis
* Timeout to use for this call.
* }
*
* @return BidiStream
*
* @throws ApiException Thrown if the API call fails.
*/
public function listen(array $callOptions = []): BidiStream
{
+ $requestParamHeaders = [];
+ if (isset($callOptions['database'])) {
+ $requestParamHeaders['database'] = $callOptions['database'];
+ }
+ $requestParams = new \Google\ApiCore\RequestParamsHeaderDescriptor($requestParamHeaders);
+ $callOptions['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $callOptions['headers']) : $requestParams->getHeader();
return $this->startApiCall('Listen', null, $callOptions);
} |
2 tasks
Member
|
LGTM |
viacheslav-rostovtsev
previously approved these changes
Aug 27, 2025
…le-cloud-php into firestore-change-headers
viacheslav-rostovtsev
approved these changes
Aug 27, 2025
Hectorhammett
approved these changes
Sep 4, 2025
purva9413
pushed a commit
to purva9413/google-cloud-php
that referenced
this pull request
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
listenBIDI streaming method, this is GAPIC only, but this call can still be made by supplying the routing headers manually