From 528794061d1a748e82bd58880e4a7b2a3f0bb0c9 Mon Sep 17 00:00:00 2001 From: Una Pizca de Saber <79965488+pizcadesaber@users.noreply.github.com> Date: Fri, 21 Feb 2025 02:17:07 +0100 Subject: [PATCH 1/2] Fixes init validation for Termux Termux does not store versioned `libvips`, so a unique Termux condition is used to specify the file to locate. The INI directive `zend.max_allowed_stack_size` also does not exist, so retrieving it returns `false`. --- src/FFI.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/FFI.php b/src/FFI.php index 70a399b..cd3f9fa 100644 --- a/src/FFI.php +++ b/src/FFI.php @@ -243,12 +243,17 @@ private static function init(): void if (!ini_get('ffi.enable')) { throw new Exception("ffi.enable not set to 'true'"); } - if (version_compare(PHP_VERSION, '8.3', '>=') && - ini_get('zend.max_allowed_stack_size') != '-1') { + if (version_compare(PHP_VERSION, '8.3', '>=') && + ini_get('zend.max_allowed_stack_size') !== '-1' && + ini_get('zend.max_allowed_stack_size') !== false) { throw new Exception("zend.max_allowed_stack_size not set to '-1'"); } - $vips_libname = self::libraryName("libvips", 42); + // Use "libvips.so" on Termux, otherwise use the standard versioned library + $vips_libname = getenv('PREFIX') === '/data/data/com.termux/files/usr' + ? "libvips.so" + : self::libraryName("libvips", 42); + if (PHP_OS_FAMILY === "Windows") { $glib_libname = self::libraryName("libglib-2.0", 0); $gobject_libname = self::libraryName("libgobject-2.0", 0); From e532e64eb015517c7a662abb5c07faf3a4330241 Mon Sep 17 00:00:00 2001 From: Una Pizca de Saber <79965488+pizcadesaber@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:22:00 +0100 Subject: [PATCH 2/2] Reverts INI directive check --- src/FFI.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/FFI.php b/src/FFI.php index cd3f9fa..22b08f5 100644 --- a/src/FFI.php +++ b/src/FFI.php @@ -243,9 +243,8 @@ private static function init(): void if (!ini_get('ffi.enable')) { throw new Exception("ffi.enable not set to 'true'"); } - if (version_compare(PHP_VERSION, '8.3', '>=') && - ini_get('zend.max_allowed_stack_size') !== '-1' && - ini_get('zend.max_allowed_stack_size') !== false) { + if (version_compare(PHP_VERSION, '8.3', '>=') && + ini_get('zend.max_allowed_stack_size') != '-1') { throw new Exception("zend.max_allowed_stack_size not set to '-1'"); }