Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG
=========

3.3.1 (unreleased)
------------------

* Updated the `GeoIp2\Model\City` constructor to handle an empty
`subdivisions` array. This provides compatibility with some third-party
databases that publish empty subdivisions arrays. Pull request by Jarek
Jakubowski. GitHub #290.

3.3.0 (2025-11-20)
------------------

Expand Down
20 changes: 20 additions & 0 deletions tests/GeoIp2/Test/Model/InsightsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,24 @@ public function testMostSpecificSubdivisionWithNoSubdivisions(): void
'mostSpecificSubdivision is set even on an empty response'
);
}

// We do not expect well-formed databases from MaxMind to have empty
// subdivisions arrays, but we support it due to encountering a third-party
// database that had them.
public function testEmptySubdivisionsArray(): void
{
$raw = [
'subdivisions' => [],
'traits' => ['ip_address' => '1.1.1.1'],
];

$model = new Insights($raw, ['en']);

$this->assertCount(0, $model->subdivisions);

$this->assertInstanceOf(
'GeoIp2\Record\Subdivision',
$model->mostSpecificSubdivision
);
}
}