From 5f85fe1e8ae2a00004e854c7585bc0f8840c0009 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 26 Jun 2023 20:51:23 +0200 Subject: [PATCH] php83: init at 8.3.0alpha2 (#239151) * php83: init at 8.3.0alpha2 * phpExtensions.blackfire: disable for php 8.3 * phpExtensions.apcu: patch for 8.3 only --- nixos/tests/all-tests.nix | 1 + pkgs/development/interpreters/php/8.3.nix | 57 ++++++++++++++++++ .../php/fix-fileinfo-ext-php83.patch | 14 +++++ .../development/php-packages/apcu/default.nix | 9 ++- pkgs/top-level/all-packages.nix | 10 ++++ pkgs/top-level/php-packages.nix | 58 ++++++++++++------- 6 files changed, 126 insertions(+), 23 deletions(-) create mode 100644 pkgs/development/interpreters/php/8.3.nix create mode 100644 pkgs/development/interpreters/php/fix-fileinfo-ext-php83.patch diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a7179a028e98..6e9c893c809e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -597,6 +597,7 @@ in { php = handleTest ./php {}; php81 = handleTest ./php { php = pkgs.php81; }; php82 = handleTest ./php { php = pkgs.php82; }; + php83 = handleTest ./php { php = pkgs.php83; }; phylactery = handleTest ./web-apps/phylactery.nix {}; pict-rs = handleTest ./pict-rs.nix {}; pinnwand = handleTest ./pinnwand.nix {}; diff --git a/pkgs/development/interpreters/php/8.3.nix b/pkgs/development/interpreters/php/8.3.nix new file mode 100644 index 000000000000..b49c89050f8c --- /dev/null +++ b/pkgs/development/interpreters/php/8.3.nix @@ -0,0 +1,57 @@ +{ callPackage, fetchurl, ... }@_args: + +let + base = (callPackage ./generic.nix (_args // { + version = "8.3.0alpha2"; + hash = null; + })).overrideAttrs (oldAttrs: { + src = fetchurl { + url = "https://downloads.php.net/~eric/php-8.3.0alpha2.tar.xz"; + hash = "sha256-YLCxgiDcsBisOmAodf0h8HyaCIh+4i1Q7QZw/h4KR5I="; + }; + }); +in +base.withExtensions ({ all, ... }: with all; ([ + bcmath + calendar + curl + ctype + dom + exif + fileinfo + filter + ftp + gd + gettext + gmp + iconv + imap + intl + ldap + mbstring + mysqli + mysqlnd + opcache + openssl + pcntl + pdo + pdo_mysql + pdo_odbc + pdo_pgsql + pdo_sqlite + pgsql + posix + readline + session + simplexml + sockets + soap + sodium + sysvsem + sqlite3 + tokenizer + xmlreader + xmlwriter + zip + zlib +])) diff --git a/pkgs/development/interpreters/php/fix-fileinfo-ext-php83.patch b/pkgs/development/interpreters/php/fix-fileinfo-ext-php83.patch new file mode 100644 index 000000000000..fbd6a66dbd14 --- /dev/null +++ b/pkgs/development/interpreters/php/fix-fileinfo-ext-php83.patch @@ -0,0 +1,14 @@ +diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c +index a6f3e64db6..c3047233db 100644 +--- a/ext/fileinfo/fileinfo.c ++++ b/ext/fileinfo/fileinfo.c +@@ -14,6 +14,9 @@ + +----------------------------------------------------------------------+ + */ + ++#ifdef HAVE_CONFIG_H ++#include "config.h" ++#endif + #include "php.h" + + #include "libmagic/magic.h" diff --git a/pkgs/development/php-packages/apcu/default.nix b/pkgs/development/php-packages/apcu/default.nix index 556d28ba0139..ffb3ef3771bc 100644 --- a/pkgs/development/php-packages/apcu/default.nix +++ b/pkgs/development/php-packages/apcu/default.nix @@ -1,4 +1,4 @@ -{ buildPecl, lib, pcre2, fetchFromGitHub }: +{ buildPecl, lib, pcre2, fetchFromGitHub, php, fetchpatch }: let version = "5.1.22"; @@ -13,6 +13,13 @@ in buildPecl { sha256 = "sha256-L4a+/kWT95a1Km+FzFNiAaBw8enU6k4ZiCFRErjj9o8="; }; + patches = lib.optionals (lib.versionAtLeast php.version "8.3") [ + (fetchpatch { + url = "https://github.com/krakjoe/apcu/commit/c9a29161c68c0faf71046e8f03f6a90900023ded.patch"; + hash = "sha256-B0ZKk9TJy2+sYGs7TEX2KxUiOVawIb+RXNgToU1Fz5I="; + }) + ]; + buildInputs = [ pcre2 ]; doCheck = true; checkTarget = "test"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 175f022efc3d..69aa034d24d3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17338,6 +17338,16 @@ with pkgs; phpExtensions = php.extensions; phpPackages = php.packages; + # Import PHP83 interpreter, extensions and packages + php83 = callPackage ../development/interpreters/php/8.3.nix { + stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; + pcre2 = pcre2.override { + withJitSealloc = false; # See https://bugs.php.net/bug.php?id=78927 and https://bugs.php.net/bug.php?id=78630 + }; + }; + php83Extensions = recurseIntoAttrs php83.extensions; + php83Packages = recurseIntoAttrs php83.packages; + # Import PHP82 interpreter, extensions and packages php82 = callPackage ../development/interpreters/php/8.2.nix { stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 6d03fddc015c..2be6447f83be 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -1,7 +1,6 @@ { stdenv , lib , pkgs -, fetchgit , phpPackage , autoconf , pkg-config @@ -10,22 +9,16 @@ , curl , cyrus_sasl , enchant2 -, fetchpatch , freetds -, freetype , gd , gettext , gmp , html-tidy , icu64 -, libXpm , libffi , libiconv -, libjpeg , libkrb5 -, libpng , libsodium -, libwebp , libxml2 , libxslt , libzip @@ -46,6 +39,7 @@ , uwimap , valgrind , zlib +, fetchpatch }: lib.makeScope pkgs.newScope (self: with self; { @@ -84,15 +78,15 @@ lib.makeScope pkgs.newScope (self: with self; { # will mark the extension as a zend extension or not. mkExtension = lib.makeOverridable ({ name - , configureFlags ? [ "--enable-${extName}" ] - , internalDeps ? [ ] - , postPhpize ? "" - , buildInputs ? [ ] - , zendExtension ? false - , doCheck ? true - , extName ? name - , ... - }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // { + , configureFlags ? [ "--enable-${extName}" ] + , internalDeps ? [ ] + , postPhpize ? "" + , buildInputs ? [ ] + , zendExtension ? false + , doCheck ? true + , extName ? name + , ... + }@args: stdenv.mkDerivation ((builtins.removeAttrs args [ "name" ]) // { pname = "php-${name}"; extensionName = extName; @@ -216,8 +210,6 @@ lib.makeScope pkgs.newScope (self: with self; { ast = callPackage ../development/php-packages/ast { }; - blackfire = pkgs.callPackage ../development/tools/misc/blackfire/php-probe.nix { inherit php; }; - couchbase = callPackage ../development/php-packages/couchbase { }; datadog_trace = callPackage ../development/php-packages/datadog_trace { }; @@ -282,7 +274,7 @@ lib.makeScope pkgs.newScope (self: with self; { redis = callPackage ../development/php-packages/redis { }; - relay = callPackage ../development/php-packages/relay { inherit php; }; + relay = callPackage ../development/php-packages/relay { inherit php; }; smbclient = callPackage ../development/php-packages/smbclient { }; @@ -332,7 +324,16 @@ lib.makeScope pkgs.newScope (self: with self; { } { name = "exif"; doCheck = false; } { name = "ffi"; buildInputs = [ libffi ]; } - { name = "fileinfo"; buildInputs = [ pcre2 ]; } + { + name = "fileinfo"; + buildInputs = [ pcre2 ]; + patches = lib.optionals (lib.versionAtLeast php.version "8.3") [ + # Fix the extension unable to be loaded due to missing `get_module` function. + # `ZEND_GET_MODULE` macro that creates it is conditional on `COMPILE_DL_FILEINFO` being defined. + # https://github.com/php/php-src/issues/11408#issuecomment-1602106200 + ../development/interpreters/php/fix-fileinfo-ext-php83.patch + ]; + } { name = "filter"; buildInputs = [ pcre2 ]; } { name = "ftp"; buildInputs = [ openssl ]; } { @@ -519,7 +520,18 @@ lib.makeScope pkgs.newScope (self: with self; { ''; doCheck = false; } - { name = "session"; doCheck = false; } + { name = "session"; + doCheck = false; + patches = lib.optionals (lib.versionAtLeast php.version "8.3") [ + # Fix GH-11529: Crash after dealing with an Apache request + # To be removed in next alpha + # See https://github.com/php/php-src/issues/11529 + (fetchpatch { + url = "https://github.com/php/php-src/commit/8d4370954ec610164a4503431bb0c52da6954aa7.patch"; + hash = "sha256-w1uF9lRdfhz9I0gux0J4cvMzNS93uSHL1fYG23VLDPc="; + }) + ]; + } { name = "shmop"; } { name = "simplexml"; @@ -625,5 +637,7 @@ lib.makeScope pkgs.newScope (self: with self; { # Produce the final attribute set of all extensions defined. in builtins.listToAttrs namedExtensions - ); + ) // lib.optionalAttrs (!(lib.versionAtLeast php.version "8.3")) { + blackfire = callPackage ../development/tools/misc/blackfire/php-probe.nix { inherit php; }; + }; })