Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

php74.extensions.iconv: fix error signalling

The configure script checks whether iconv supports errno. Unfortunately, on PHP < 8, the test program includes $PHP_ICONV_H_PATH, which defaults to FHS path so it fails to build:

conftest.c:13:10: fatal error: /usr/include/iconv.h: No such file or directory
13 | #include </usr/include/iconv.h>
| ^~~~~~~~~~~~~~~~~~~~~~

That causes the feature check to report a false negative, leading PHP to use a degraded code that returns PHP_ICONV_ERR_UNKNOWN when error occurs, breaking granular error handling in applications.

To prevent this, let’s just include <iconv.h>.

PHP 8 just uses include path so the detection works there: https://github.com/php/php-src/commit/7bd1d703411e1e4b1f663f0cb06af619eea04b42

(cherry picked from commit 024243bac4612c62ef5be676818ed2465edae27f)

authored by Jan Tojnar and committed by talyz ffb99acc ac60476e

Changed files
+10 -4
pkgs
top-level
+10 -4
pkgs/top-level/php-packages.nix
··· 1007 1007 configureFlags = [ "--with-gmp=${gmp.dev}" ]; } 1008 1008 { name = "hash"; enable = lib.versionOlder php.version "7.4"; } 1009 1009 { name = "iconv"; 1010 - configureFlags = if stdenv.isDarwin then 1011 - [ "--with-iconv=${libiconv}" ] 1012 - else 1013 - [ "--with-iconv" ]; 1010 + configureFlags = [ 1011 + "--with-iconv${lib.optionalString stdenv.isDarwin "=${libiconv}"}" 1012 + ]; 1013 + patches = lib.optionals (lib.versionOlder php.version "8.0") [ 1014 + # Header path defaults to FHS location, preventing the configure script from detecting errno support. 1015 + (fetchpatch { 1016 + url = "https://github.com/fossar/nix-phps/raw/263861a8c9bdafd7abe44db6db4ef0179643680c/pkgs/iconv-header-path.patch"; 1017 + sha256 = "7GHnEUu+hcsQ4h3itDwk6p46ZKfib9JZ2XpWlXrdn6E="; 1018 + }) 1019 + ]; 1014 1020 doCheck = false; } 1015 1021 { name = "imap"; 1016 1022 buildInputs = [ uwimap openssl pam pcre' ];