Skip to content

Commit 4fce0bc

Browse files
committed
Handle missing Remote Config parameter groups
1 parent 49d099f commit 4fce0bc

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ Please update your remote URL if you have forked or cloned the repository.
99

1010
## Unreleased
1111

12+
## Remote Config
13+
14+
* Fixed retrieving templates containing missing parameter groups
15+
([#1133](https://github.com/beste/firebase-php/pull/1133)).
16+
1217
## Messaging
1318

1419
* FCM `403 PERMISSION_DENIED` responses with the error code `SENDER_ID_MISMATCH` are now

src/RemoteConfig/ParameterGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @phpstan-type RemoteConfigParameterGroupShape array{
1313
* description?: string|null,
14-
* parameters: array<non-empty-string, RemoteConfigParameterShape>}
14+
* parameters?: array<non-empty-string, RemoteConfigParameterShape>}
1515
*/
1616
final class ParameterGroup implements JsonSerializable
1717
{

src/RemoteConfig/Template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private static function buildParameterGroup(string $name, array $parameterGroupD
266266
->withDescription($parameterGroupData['description'] ?? '')
267267
;
268268

269-
foreach ($parameterGroupData['parameters'] as $parameterName => $parameterData) {
269+
foreach (($parameterGroupData['parameters'] ?? []) as $parameterName => $parameterData) {
270270
$group = $group->withParameter(self::buildParameter($parameterName, $parameterData));
271271
}
272272

tests/Unit/RemoteConfig/TemplateTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ public function testParameterGroupsCanBeRemoved(): void
125125
$this->assertEmpty($template->parameterGroups());
126126
}
127127

128+
/**
129+
* @see https://github.com/beste/firebase-php/issues/1132
130+
*/
131+
public function testEmptyParameterGroupsCanBeImported(): void
132+
{
133+
$template = Template::fromArray(['parameterGroups' => ['empty' => []]]);
134+
135+
$this->assertSame([], $template->parameterGroups()['empty']->parameters());
136+
}
137+
128138
public function testPersonalizationValuesAreImportedInDefaultValues(): void
129139
{
130140
$data = [

0 commit comments

Comments
 (0)