diff --git a/CHANGELOG.md b/CHANGELOG.md index 38aa3c9..c744a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -1.15.0 +1.15.0 (2026-11-17) ------------------- * The pure PHP reader now rejects non-string map keys with @@ -34,6 +34,12 @@ CHANGELOG cannot throw. * `MaxMind\Db\Reader\Decoder::decode()` and `MaxMind\Db\Reader\Util::read()` declare their exceptions. +* The bundled libmaxminddb used by `--with-maxminddb-bundled` builds of the + extension is now 1.14.1. This fixes a build failure with `-Werror` on + platforms where `ssize_t` is 32 bits, such as i686. +* The classes in the pure PHP reader are now marked `@final`. They will be + `final` in the next major version. Static analyzers such as PHPStan report + a class that extends them. * On 64-bit Windows, the extension returned `uint32` and `uint64` values from 2^31 to `PHP_INT_MAX` as strings. It now returns them as integers. diff --git a/README.md b/README.md index 6e7ef47..3d97024 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ You should now have the file `composer.phar` in your project directory. Run in your project root: ``` -php composer.phar require maxmind-db/reader:^1.14.0 +php composer.phar require maxmind-db/reader:^1.15.0 ``` You should now have the files `composer.json` and `composer.lock` as well as diff --git a/composer.json b/composer.json index e235bca..6125243 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "maxmind-db/reader-ext": "C extension for significantly faster IP lookups (install via PIE: pie install maxmind-db/reader-ext)" }, "conflict": { - "ext-maxminddb": "<1.14.0 || >=2.0.0" + "ext-maxminddb": "<1.15.0 || >=2.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", diff --git a/dev-bin/release.sh b/dev-bin/release.sh index 7f8b12d..5934b97 100755 --- a/dev-bin/release.sh +++ b/dev-bin/release.sh @@ -44,10 +44,6 @@ if ! gh workflow view release.yml --repo maxmind/MaxMind-DB-Reader-php-ext &>/de fi check_command perl -if ! perl -MHTML::Entities -e 1; then - echo "Error: Cannot load HTML::Entities. Install the Perl HTML::Parser distribution before releasing." - exit 1 -fi check_command php check_command phpize check_command pecl @@ -168,8 +164,8 @@ export RELEASE_VERSION="$version" RELEASE_DATE="$date" RELEASE_NOTES="$notes" subst composer.json 's/(?<="ext-maxminddb": "<)[^ ,|"]+/$ENV{RELEASE_VERSION}/' subst package.xml 's/(?<=<(?:api)>)\d+\.\d+\.\d+(?=<)/$ENV{RELEASE_VERSION}/' subst package.xml 's/(?<=<(?:release)>)\d+\.\d+\.\d+(?=<)/$ENV{RELEASE_VERSION}/' - # Limit escaping to XML text characters to avoid HTML-only named entities. - subst package.xml 's{(?<=).*(?=)}{encode_entities($ENV{RELEASE_NOTES}, "<>&")}sme' -0777 -MHTML::Entities + # Escape only the XML text characters, so no HTML-only named entities appear. + subst package.xml 's{(?<=).*(?=)}{(my $t = $ENV{RELEASE_NOTES}) =~ s/&/&/g; $t =~ s//>/g; $t}sme' -0777 subst package.xml 's/(?<=)\d{4}-\d{2}-\d{2}(?=<)/$ENV{RELEASE_DATE}/' } diff --git a/ext/bundled-include/maxminddb_config.h b/ext/bundled-include/maxminddb_config.h index 0c12d19..06034b8 100644 --- a/ext/bundled-include/maxminddb_config.h +++ b/ext/bundled-include/maxminddb_config.h @@ -31,7 +31,7 @@ * every build, so a stale value here fails CI rather than shipping. */ #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.14.0" +#define PACKAGE_VERSION "1.14.1" #endif #endif /* MAXMINDDB_CONFIG_H */ diff --git a/ext/libmaxminddb b/ext/libmaxminddb index 0077fd7..4a3d17a 160000 --- a/ext/libmaxminddb +++ b/ext/libmaxminddb @@ -1 +1 @@ -Subproject commit 0077fd76d00a1656b9cb3028d467736504794f41 +Subproject commit 4a3d17a621c0ebcb81498fd34d313f67fd940ab5 diff --git a/ext/php_maxminddb.h b/ext/php_maxminddb.h index fae51a8..068c744 100644 --- a/ext/php_maxminddb.h +++ b/ext/php_maxminddb.h @@ -15,7 +15,7 @@ #ifndef PHP_MAXMINDDB_H #define PHP_MAXMINDDB_H 1 -#define PHP_MAXMINDDB_VERSION "1.14.0" +#define PHP_MAXMINDDB_VERSION "1.15.0" #define PHP_MAXMINDDB_EXTNAME "maxminddb" extern zend_module_entry maxminddb_module_entry; diff --git a/package.xml b/package.xml index 5f66c4f..812399a 100644 --- a/package.xml +++ b/package.xml @@ -14,57 +14,54 @@ goschwald@maxmind.com yes - 2026-09-10 + 2026-11-17 - 1.14.0 - 1.14.0 + 1.15.0 + 1.15.0 stable stable Apache License 2.0 - * Bounded the resources that the pure PHP decoder spends on a single lookup. A - crafted database could nest data-section pointers to shared targets so that - decoding one record cost exponential time and memory, or point many times at - one large value so that the decoder copied far more data than the file holds. - The decoder now follows the Reader Resource Limits section of the MaxMind DB - specification. Each lookup is limited to 65,536 values, 512 levels of - nesting, and 2 MiB of string and bytes payload. - * Exceeding a limit throws an `InvalidDatabaseException`. - * Opening a database whose metadata exceeds a limit throws the same - exception. - * A scalar that declares more than 16 bytes, the width of the widest - fixed-width type, is rejected as invalid data. + * The pure PHP reader now rejects non-string map keys with + `InvalidDatabaseException` instead of a `TypeError`, a warning, or an + implicit type conversion. +* The pure PHP reader now rejects malformed metadata with + `InvalidDatabaseException` instead of a `TypeError`, a warning, or an + implicit type conversion. Missing optional `languages` and `description` + fields default to empty arrays. +* Missing gmp/bcmath support and offsets that exceed the platform limit now + throw `MaxMind\Db\Reader\UnsupportedPlatformException`. It extends + `RuntimeException`, so existing catches continue to work. +* The pure PHP reader also throws `UnsupportedPlatformException` when the + metadata node count or the start of the data section exceeds the platform's + integer limit. These cases no longer produce `InvalidDatabaseException` or + overflow into a `TypeError`. +* `phpinfo()` and `php --ri maxminddb` now show whether the extension was built + with the bundled libmaxminddb or links a system library. The + `libmaxminddb library version` row reads, for example, `1.14.0 (bundled)` or + `1.9.1 (system)`. Pull request by Remi Collet. GitHub #289. +* The PHPDoc of the pure PHP reader now lists the exceptions that its methods + can throw: + * The `MaxMind\Db\Reader` constructor, `get()`, and `getWithPrefixLen()` + declare `UnsupportedPlatformException`. The reader throws it when an + integer needs gmp or bcmath and neither is installed, or a data offset + exceeds the platform limit. + * The constructor declares `UnexpectedValueException`. + * `close()` declares `BadMethodCallException` in place of `Exception`. + `metadata()` no longer declares `InvalidArgumentException`, which it + cannot throw. + * `MaxMind\Db\Reader\Decoder::decode()` and `MaxMind\Db\Reader\Util::read()` + declare their exceptions. * The bundled libmaxminddb used by `--with-maxminddb-bundled` builds of the - extension now applies the same decoder limits. The extension throws an - `InvalidDatabaseException` when a lookup exceeds them. -* The pure PHP reader is about 40% faster on City lookups. It no longer seeks - before a read that continues where the last one ended, and it checks read - lengths with `strlen()` instead of `ftell()`. -* The Windows build configuration now accepts either `libmaxminddb.lib` or - `maxminddb.lib` when building the extension. The `lib` prefix was removed - in libmaxminddb 1.6.0, but the libmaxminddb that PHP publishes for Windows - builds is still 1.5.0, which uses the prefixed name. Pull request by - Jean-Baptiste Nahan. GitHub #231. -* Replaced `XtOffsetOf()` with `offsetof()`. The `XtOffsetOf()` alias has - been removed in PHP 8.6. Pull request by Remi Collet. GitHub #252. -* The extension can now be built from a bundled copy of libmaxminddb, on - both Unix-like systems and Windows, by passing `--with-maxminddb-bundled` - to `configure` (or to `configure.bat` on Windows). This produces an - extension that does not depend on a system libmaxminddb, which is a - prerequisite for distributing precompiled builds; on Windows it also - replaces the 1.5.0 import library that PHP publishes for Windows builds. - The default is unchanged: without the flag, the extension links against a - system libmaxminddb as before. GitHub #265. -* The `conflict` constraint on `ext-maxminddb` in `composer.json` is again - updated when a release is cut. The substitution that maintains it stopped - matching in April 2024, when the constraint's separator changed from a comma - to `||`, so the constraint has read `<1.11.1` through four releases. Users of - the C extension should note the effect of reviving it: `ext-maxminddb` is a - Composer platform package, so this release conflicts with an older compiled - extension and `composer update` will require upgrading the two together. - GitHub #266. + extension is now 1.14.1. This fixes a build failure with `-Werror` on + platforms where `ssize_t` is 32 bits, such as i686. +* The classes in the pure PHP reader are now marked `@final`. They will be + `final` in the next major version. Static analyzers such as PHPStan report + a class that extends them. +* On 64-bit Windows, the extension returned `uint32` and `uint64` values + from 2^31 to `PHP_INT_MAX` as strings. It now returns them as integers. diff --git a/src/MaxMind/Db/Reader.php b/src/MaxMind/Db/Reader.php index 04ed2c0..1005d39 100644 --- a/src/MaxMind/Db/Reader.php +++ b/src/MaxMind/Db/Reader.php @@ -16,6 +16,8 @@ * * The declared exceptions describe the pure PHP reader. The C extension may * differ. + * + * @final */ class Reader { diff --git a/src/MaxMind/Db/Reader/Decoder.php b/src/MaxMind/Db/Reader/Decoder.php index eeb3d1c..56d92d0 100644 --- a/src/MaxMind/Db/Reader/Decoder.php +++ b/src/MaxMind/Db/Reader/Decoder.php @@ -6,6 +6,9 @@ // @codingStandardsIgnoreLine +/** + * @final + */ class Decoder { /** diff --git a/src/MaxMind/Db/Reader/InvalidDatabaseException.php b/src/MaxMind/Db/Reader/InvalidDatabaseException.php index b1da1ed..da2b1af 100644 --- a/src/MaxMind/Db/Reader/InvalidDatabaseException.php +++ b/src/MaxMind/Db/Reader/InvalidDatabaseException.php @@ -6,6 +6,8 @@ /** * This class should be thrown when unexpected data is found in the database. + * + * @final */ // phpcs:disable class InvalidDatabaseException extends \Exception {} diff --git a/src/MaxMind/Db/Reader/Metadata.php b/src/MaxMind/Db/Reader/Metadata.php index 62ecba9..e14f6b0 100644 --- a/src/MaxMind/Db/Reader/Metadata.php +++ b/src/MaxMind/Db/Reader/Metadata.php @@ -6,6 +6,8 @@ /** * This class provides the metadata for the MaxMind DB file. + * + * @final */ class Metadata { diff --git a/src/MaxMind/Db/Reader/UnsupportedPlatformException.php b/src/MaxMind/Db/Reader/UnsupportedPlatformException.php index eaa831c..0ae15a2 100644 --- a/src/MaxMind/Db/Reader/UnsupportedPlatformException.php +++ b/src/MaxMind/Db/Reader/UnsupportedPlatformException.php @@ -6,6 +6,8 @@ /** * The platform cannot decode a database value or offset. + * + * @final */ // phpcs:ignore PSR2.Classes.ClassDeclaration, Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore class UnsupportedPlatformException extends \RuntimeException {} diff --git a/src/MaxMind/Db/Reader/Util.php b/src/MaxMind/Db/Reader/Util.php index a8f8167..2915a77 100644 --- a/src/MaxMind/Db/Reader/Util.php +++ b/src/MaxMind/Db/Reader/Util.php @@ -4,6 +4,9 @@ namespace MaxMind\Db\Reader; +/** + * @final + */ class Util { /**