Skip to content

Commit 1f65867

Browse files
authored
chore(docs): Add clarification to Firestore MIGRATING.md (#8885)
* chore(docs): Add clarification to Firestore MIGRATING.md * add client options changes * document exceptions * remove unused use
1 parent 5d89b6b commit 1f65867

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

Firestore/MIGRATING.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,32 @@
22

33
This document outlines the key breaking changes introduced in version 2 of the google-cloud-php Firestore library and provides guidance on how to update your code.
44

5-
## 1. Removal of the `Connection` Layer
5+
## 1. Client Options changes
6+
7+
The following client options are removed/replaced with other options present in
8+
[`ClientOptions`][ClientOptions]. This was done to ensure client options are consistent across all
9+
Google Cloud clients.
10+
11+
- `authCache` -> Moved to `credentialsConfig.authCache`
12+
- `authCacheOptions` -> Moved to `credentialsConfig.authCacheOptions`
13+
- `credentialsFetcher` -> Moved to `credentials`
14+
- `keyFile` -> Moved to `credentials`
15+
- `keyFilePath` -> Moved to `credentials`
16+
- `scopes` -> Moved to `credentialsConfig.scopes`
17+
- `quotaProject` -> Moved to `credentialsConfig.quotaProject`
18+
- `httpHandler` -> Moved to `transportConfig.rest.httpHandler`
19+
- `authHttpHandler` -> Moved to `credentialsConfig.authHttpHandler`
20+
21+
## 2. Removal of the `Connection` Layer
622

723
The most significant change in v2 is the removal of the `ConnectionInterface` and its `Grpc` implementation. All classes that previously depended on the connection layer now interact directly with the auto generated client for Firestore (`Google\Cloud\Firestore\V1\Client\FirestoreClient`).
824

925
This change simplifies the library's architecture but requires updates to how you instantiate several core classes.
1026

11-
## 2. Constructor Changes
27+
**Note**: If you primarily use factory methods (e.g. `$firestore->collection(...)`, `$collection->document(...)`), your
28+
code likely requires no changes, as the library handles these dependencies internally.
29+
30+
## 3. Constructor Changes
1231

1332
Due to the removal of the `Connection` layer, the constructors for the following classes have changed. They no longer accept a `ConnectionInterface` instance and instead require a `Google\Cloud\Firestore\V1\Client\FirestoreClient` instance.
1433

@@ -58,7 +77,7 @@ $docRef = new DocumentReference(
5877

5978
You will need to apply similar changes wherever you instantiate the classes listed above. The main `FirestoreClient` will now manage the GAPIC client instance.
6079

61-
## 3. `WriteBatch` Class Removed
80+
## 4. `WriteBatch` Class Removed
6281

6382
The `WriteBatch` class, which was previously a deprecated alias for `BulkWriter`, has been completely removed.
6483

Firestore/src/AggregateQuery.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Google\ApiCore\ApiException;
2121
use Google\ApiCore\Options\CallOptions;
2222
use Google\Cloud\Core\ApiHelperTrait;
23+
use Google\Cloud\Core\Exception\ServiceException;
2324
use Google\Cloud\Core\OptionsValidator;
2425
use Google\Cloud\Core\RequestProcessorTrait;
2526
use Google\Cloud\Firestore\V1\Client\FirestoreClient;
@@ -98,6 +99,7 @@ public function addAggregation($aggregate)
9899
* {@see \Google\Cloud\Firestore\ExplainOptions}
99100
* }
100101
* @return AggregateQuerySnapshot
102+
* @throws ServiceException
101103
*/
102104
public function getSnapshot($options = [])
103105
{

Firestore/src/BulkWriter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Google\ApiCore\Options\CallOptions;
2222
use Google\Cloud\Core\ApiHelperTrait;
2323
use Google\Cloud\Core\DebugInfoTrait;
24+
use Google\Cloud\Core\Exception\ServiceException;
2425
use Google\Cloud\Core\OptionsValidator;
2526
use Google\Cloud\Core\RequestProcessorTrait;
2627
use Google\Cloud\Core\Timestamp;
@@ -665,6 +666,7 @@ public function flush($waitForRetryableFailures = false)
665666
* @param array $options Configuration Options
666667
* @return array [https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1beta1#commitresponse](CommitResponse)
667668
* @codingStandardsIgnoreEnd
669+
* @throws ServiceException
668670
*/
669671
public function commit(array $options = []): array
670672
{
@@ -723,6 +725,7 @@ public function commit(array $options = []): array
723725
* @param array $options Configuration Options
724726
* @return void
725727
* @throws \RuntimeException If no transaction ID is provided at class construction.
728+
* @throws ServiceException
726729
*/
727730
public function rollback(array $options = []): void
728731
{
@@ -928,6 +931,7 @@ private function createWritesBatchIds($waitForRetryableFailures = false)
928931
* Labels associated with this batch write.
929932
* }
930933
* @return array [https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1beta1#BatchWriteResponse](BatchWriteResponse)
934+
* @throws ServiceException
931935
*/
932936
private function sendBatch(array $writes, array $options = [])
933937
{

Firestore/src/FirestoreClient.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Google\Cloud\Core\DetectProjectIdTrait;
2626
use Google\Cloud\Core\EmulatorTrait;
2727
use Google\Cloud\Core\Exception\AbortedException;
28-
use Google\Cloud\Core\Exception\GoogleException;
2928
use Google\Cloud\Core\GeoPoint;
3029
use Google\Cloud\Core\Iterator\ItemIterator;
3130
use Google\Cloud\Core\Iterator\PageIterator;
@@ -177,7 +176,6 @@ class FirestoreClient
177176
* The service domain for the client. Defaults to 'googleapis.com'.
178177
* }
179178
* @throws \InvalidArgumentException
180-
* @throws GoogleException If the gRPC extension is not enabled.
181179
*/
182180
public function __construct(array $config = [])
183181
{

Firestore/src/SnapshotTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Google\ApiCore\Options\CallOptions;
2222
use Google\Cloud\Core\ApiHelperTrait;
2323
use Google\Cloud\Core\Exception\NotFoundException;
24+
use Google\Cloud\Core\Exception\ServiceException;
2425
use Google\Cloud\Core\RequestProcessorTrait;
2526
use Google\Cloud\Core\Timestamp;
2627
use Google\Cloud\Core\TimestampTrait;
@@ -109,6 +110,7 @@ private function createSnapshotWithData(
109110
* @throws \InvalidArgumentException if an invalid `$options.readTime` is
110111
* specified.
111112
* @throws NotFoundException If the document does not exist.
113+
* @throws ServiceException
112114
*/
113115
private function getSnapshot(FirestoreClient $gapicClient, $name, array $options = []): array
114116
{
@@ -159,6 +161,7 @@ private function getSnapshot(FirestoreClient $gapicClient, $name, array $options
159161
* firestore document paths or DocumentReference instances.
160162
* @param array $options Configuration options.
161163
* @return DocumentSnapshot[]
164+
* @throws ServiceException
162165
*/
163166
private function getDocumentsByPaths(
164167
FirestoreClient $gapicClient,

0 commit comments

Comments
 (0)