From be120d100c079d9163a4a4ad63d69bb65d8993ab Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Thu, 12 Nov 2026 22:55:37 +0000 Subject: [PATCH] [BUGFIX] Report the version of imagick instead of @PACKAGE_VERSION@ The images build imagick from its Git branch master, where the version in php_imagick.h is the placeholder @PACKAGE_VERSION@; only the packaging of PECL fills it in. phpversion('imagick') returned the placeholder, and libraries that compare it, e.g. TCPDF, took the wrong path. The build now fills in the version of package.xml before it compiles imagick. --- ci/image-tests/Checks/PhpChecks.php | 8 ++++++++ docker/php-official/8.2-alpine/Dockerfile | 2 ++ docker/php-official/8.2/Dockerfile | 2 ++ docker/php-official/8.3-alpine/Dockerfile | 2 ++ docker/php-official/8.3/Dockerfile | 2 ++ docker/php-official/8.4-alpine/Dockerfile | 2 ++ docker/php-official/8.4/Dockerfile | 2 ++ docker/php-official/8.5-alpine/Dockerfile | 2 ++ docker/php-official/8.5/Dockerfile | 2 ++ template/Dockerfile/images/php.twig | 4 ++++ 10 files changed, 28 insertions(+) diff --git a/ci/image-tests/Checks/PhpChecks.php b/ci/image-tests/Checks/PhpChecks.php index c27124e27..33f2577c7 100644 --- a/ci/image-tests/Checks/PhpChecks.php +++ b/ci/image-tests/Checks/PhpChecks.php @@ -201,6 +201,14 @@ public function testComposer(): void $this->assertCommandSucceeds('/usr/local/bin/composer'); } + /** + * phpversion('imagick') is a version number, not the placeholder of the source, which libraries compare. + */ + public function testImagickReportsItsVersion(): void + { + self::assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $this->stdout('php -r \'echo phpversion("imagick");\'')); + } + public function testGraphicsMagick(): void { self::assertTrue($this->file('/usr/bin/gm')->isExecutable, '/usr/bin/gm should be executable'); diff --git a/docker/php-official/8.2-alpine/Dockerfile b/docker/php-official/8.2-alpine/Dockerfile index 7041dee5a..9470cf9ba 100644 --- a/docker/php-official/8.2-alpine/Dockerfile +++ b/docker/php-official/8.2-alpine/Dockerfile @@ -151,6 +151,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && PKG_CONFIG_PATH=/usr/local docker-php-ext-configure intl \ && docker-php-ext-configure gd --with-avif --with-jpeg --with-freetype --with-webp \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && docker-php-ext-configure ldap \ diff --git a/docker/php-official/8.2/Dockerfile b/docker/php-official/8.2/Dockerfile index 519ff80ba..bf20e5675 100644 --- a/docker/php-official/8.2/Dockerfile +++ b/docker/php-official/8.2/Dockerfile @@ -153,6 +153,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && docker-php-ext-configure ldap \ && docker-php-ext-configure ftp --with-openssl-dir \ && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ diff --git a/docker/php-official/8.3-alpine/Dockerfile b/docker/php-official/8.3-alpine/Dockerfile index dd122dc8c..96356c571 100644 --- a/docker/php-official/8.3-alpine/Dockerfile +++ b/docker/php-official/8.3-alpine/Dockerfile @@ -151,6 +151,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && PKG_CONFIG_PATH=/usr/local docker-php-ext-configure intl \ && docker-php-ext-configure gd --with-avif --with-jpeg --with-freetype --with-webp \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && docker-php-ext-configure ldap \ diff --git a/docker/php-official/8.3/Dockerfile b/docker/php-official/8.3/Dockerfile index 3bb6508e8..a58a0c6a8 100644 --- a/docker/php-official/8.3/Dockerfile +++ b/docker/php-official/8.3/Dockerfile @@ -153,6 +153,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && docker-php-ext-configure ldap \ && docker-php-ext-configure ftp --with-openssl-dir \ && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ diff --git a/docker/php-official/8.4-alpine/Dockerfile b/docker/php-official/8.4-alpine/Dockerfile index e6bb624e3..294c93628 100644 --- a/docker/php-official/8.4-alpine/Dockerfile +++ b/docker/php-official/8.4-alpine/Dockerfile @@ -151,6 +151,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && PKG_CONFIG_PATH=/usr/local docker-php-ext-configure intl \ && docker-php-ext-configure gd --with-avif --with-jpeg --with-freetype --with-webp \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && docker-php-ext-configure ldap \ diff --git a/docker/php-official/8.4/Dockerfile b/docker/php-official/8.4/Dockerfile index 3730fa07b..7e06f2219 100644 --- a/docker/php-official/8.4/Dockerfile +++ b/docker/php-official/8.4/Dockerfile @@ -152,6 +152,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && docker-php-ext-configure ldap \ && docker-php-ext-configure ftp --with-ftp-ssl \ && docker-php-ext-install -j"$(nproc)" \ diff --git a/docker/php-official/8.5-alpine/Dockerfile b/docker/php-official/8.5-alpine/Dockerfile index 59316df79..095235aa5 100644 --- a/docker/php-official/8.5-alpine/Dockerfile +++ b/docker/php-official/8.5-alpine/Dockerfile @@ -151,6 +151,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && PKG_CONFIG_PATH=/usr/local docker-php-ext-configure intl \ && docker-php-ext-configure gd --with-avif --with-jpeg --with-freetype --with-webp \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && docker-php-ext-configure ldap \ diff --git a/docker/php-official/8.5/Dockerfile b/docker/php-official/8.5/Dockerfile index 034cbe200..e2f155154 100644 --- a/docker/php-official/8.5/Dockerfile +++ b/docker/php-official/8.5/Dockerfile @@ -152,6 +152,8 @@ RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && docker-php-ext-configure ldap \ && docker-php-ext-configure ftp --with-ftp-ssl \ && docker-php-ext-install -j"$(nproc)" \ diff --git a/template/Dockerfile/images/php.twig b/template/Dockerfile/images/php.twig index f8dce0ef6..994671ffe 100644 --- a/template/Dockerfile/images/php.twig +++ b/template/Dockerfile/images/php.twig @@ -72,6 +72,8 @@ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && docker-php-ext-configure ldap \ {% if version == '8.2' or version == '8.3' %} && docker-php-ext-configure ftp --with-openssl-dir \ @@ -227,6 +229,8 @@ && PKG_CONFIG_PATH=/usr/local docker-php-ext-configure intl \ && docker-php-ext-configure gd --with-avif --with-jpeg --with-freetype --with-webp \ && git clone --branch master --depth 1 https://github.com/Imagick/imagick.git /usr/src/php/ext/imagick \ + # imagick leaves its version to the packaging of PECL; take it from package.xml, so that phpversion('imagick') reports it + && sed -i "s/@PACKAGE_VERSION@/$(sed -n 's:.*\([0-9][0-9.]*\).*:\1:p' /usr/src/php/ext/imagick/package.xml | head -n 1)/" /usr/src/php/ext/imagick/php_imagick.h \ && git clone --branch latest --depth 1 https://github.com/php-amqp/php-amqp.git /usr/src/php/ext/amqp \ && cd /usr/src/php/ext/amqp && git submodule update --init \ && docker-php-ext-configure ldap \