From 303db2bf69872a4679a6a7b7b1f5b0d80f3d4179 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Thu, 21 Nov 2024 18:03:04 -0500 Subject: [PATCH 1/8] PHP 8.4 --- .github/workflows/build.yml | 2 +- build.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4745be522..7237b791b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - php: ["8.0", "8.1", "8.2", "8.3"] + php: ["8.0", "8.1", "8.2", "8.3", "8.4"] rust: [stable, nightly] clang: ["15", "17"] phpts: [ts, nts] diff --git a/build.rs b/build.rs index bcaabb416..393b1ce5d 100644 --- a/build.rs +++ b/build.rs @@ -16,7 +16,7 @@ use bindgen::RustTarget; use impl_::Provider; const MIN_PHP_API_VER: u32 = 20200930; -const MAX_PHP_API_VER: u32 = 20230831; +const MAX_PHP_API_VER: u32 = 20240924; pub trait PHPProvider<'a>: Sized { /// Create a new PHP provider. From 5e43894186356ca0f853e6f98f85cdf4f5b30f07 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Thu, 21 Nov 2024 19:30:37 -0500 Subject: [PATCH 2/8] Support php 8.4 internal api changes --- build.rs | 8 +++++++- src/builders/function.rs | 8 ++++++++ src/zend/function.rs | 4 ++++ src/zend/handlers.rs | 15 ++++++++++++--- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 393b1ce5d..ee15bb55d 100644 --- a/build.rs +++ b/build.rs @@ -230,7 +230,9 @@ fn check_php_version(info: &PHPInfo) -> Result<()> { const PHP_83_API_VER: u32 = 20230831; - println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php_zts, php_debug, docs)"); + const PHP_84_API_VER: u32 = 20240924; + + println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"); println!("cargo:rustc-cfg=php80"); if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) { @@ -245,6 +247,10 @@ fn check_php_version(info: &PHPInfo) -> Result<()> { println!("cargo:rustc-cfg=php83"); } + if version >= PHP_84_API_VER { + println!("cargo:rustc-cfg=php84"); + } + Ok(()) } diff --git a/src/builders/function.rs b/src/builders/function.rs index 60eddcc96..99f74f7e2 100644 --- a/src/builders/function.rs +++ b/src/builders/function.rs @@ -55,6 +55,10 @@ impl<'a> FunctionBuilder<'a> { arg_info: ptr::null(), num_args: 0, flags: 0, // TBD? + #[cfg(php84)] + doc_comment: ptr::null(), + #[cfg(php84)] + frameless_function_infos: ptr::null(), }, args: vec![], n_req: None, @@ -79,6 +83,10 @@ impl<'a> FunctionBuilder<'a> { arg_info: ptr::null(), num_args: 0, flags: MethodFlags::Abstract.bits(), + #[cfg(php84)] + doc_comment: ptr::null(), + #[cfg(php84)] + frameless_function_infos: ptr::null(), }, args: vec![], n_req: None, diff --git a/src/zend/function.rs b/src/zend/function.rs index 6e6dd1a39..a16ea1e61 100644 --- a/src/zend/function.rs +++ b/src/zend/function.rs @@ -38,6 +38,10 @@ impl FunctionEntry { arg_info: ptr::null(), num_args: 0, flags: 0, + #[cfg(php84)] + doc_comment: ptr::null(), + #[cfg(php84)] + frameless_function_infos: ptr::null(), } } diff --git a/src/zend/handlers.rs b/src/zend/handlers.rs index 7e88a7e05..5c0da7394 100644 --- a/src/zend/handlers.rs +++ b/src/zend/handlers.rs @@ -238,9 +238,18 @@ impl ZendObjectHandlers { let mut zv = Zval::new(); val.get(self_, &mut zv)?; - #[allow(clippy::unnecessary_mut_passed)] - if zend_is_true(&mut zv) == 1 { - return Ok(1); + cfg_if::cfg_if! { + if #[cfg(php84)] { + #[allow(clippy::unnecessary_mut_passed)] + if zend_is_true(&mut zv) == true { + return Ok(1); + } + } else { + #[allow(clippy::unnecessary_mut_passed)] + if zend_is_true(&mut zv) == 1 { + return Ok(1); + } + } } } } From 8b19be90c0c769116f9231755f473195d8e949e1 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Thu, 21 Nov 2024 19:35:04 -0500 Subject: [PATCH 3/8] fmt --- build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index ee15bb55d..523256497 100644 --- a/build.rs +++ b/build.rs @@ -232,7 +232,9 @@ fn check_php_version(info: &PHPInfo) -> Result<()> { const PHP_84_API_VER: u32 = 20240924; - println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"); + println!( + "cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)" + ); println!("cargo:rustc-cfg=php80"); if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) { From df8f501c7c5f07731e2f3175e3bfbd8f9a2208f4 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Mon, 25 Nov 2024 14:16:09 -0500 Subject: [PATCH 4/8] Force 8.4.1 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7237b791b..13a28584c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: ${{ matrix.os == 'windows-latest' && matrix.php == '8.4' && '8.4.1' || matrix.php }} env: phpts: ${{ matrix.phpts }} debug: true From 624d14c81e511ddea6affc4771bbe275f2c03d20 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 26 Nov 2024 10:59:12 -0500 Subject: [PATCH 5/8] Revert "Force 8.4.1" This reverts commit df8f501c7c5f07731e2f3175e3bfbd8f9a2208f4. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13a28584c..7237b791b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.os == 'windows-latest' && matrix.php == '8.4' && '8.4.1' || matrix.php }} + php-version: ${{ matrix.php }} env: phpts: ${{ matrix.phpts }} debug: true From 5dd213797cab80a323ce309cb19dfdd6dd3bc48f Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 26 Nov 2024 10:59:30 -0500 Subject: [PATCH 6/8] Don't use archive for 8.4.1 --- windows_build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/windows_build.rs b/windows_build.rs index bc0e75d89..2bb43fec7 100644 --- a/windows_build.rs +++ b/windows_build.rs @@ -207,8 +207,10 @@ impl DevelPack { Ok(devpack_path) } + let is_archive = if version == "8.4.1" { false } else { true }; + download(&zip_name, false) - .or_else(|_| download(&zip_name, true)) + .or_else(|_| download(&zip_name, is_archive)) .map(DevelPack) } From 80f55581fecd3dc0cb4c3f5c711f917cf0f77eb6 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 26 Nov 2024 11:14:18 -0500 Subject: [PATCH 7/8] Use vs17 on php 8.4+ --- windows_build.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/windows_build.rs b/windows_build.rs index 2bb43fec7..22a87d1c0 100644 --- a/windows_build.rs +++ b/windows_build.rs @@ -163,12 +163,28 @@ impl DevelPack { /// Downloads a new PHP development pack, unzips it in the build script /// temporary directory. fn new(version: &str, is_zts: bool, arch: Arch) -> Result { + // If the PHP version is more than 8.4.1, use VS17 instead of VS16. + let version_float = version + .split('.') + .take(2) + .collect::>() + .join(".") + .parse::() + .context("Failed to parse PHP version as float")?; + + // PHP builds switched to VS17 in PHP 8.4.1. + let visual_studio_version = if version_float >= 8.4f32 { + "vs17" + } else { + "vs16" + }; + + let zip_name = format!( "php-devel-pack-{}{}-Win32-{}-{}.zip", version, if is_zts { "" } else { "-nts" }, - "vs16", /* TODO(david): At the moment all PHPs supported by ext-php-rs use VS16 so - * this is constant. */ + visual_studio_version, arch ); From cc2e462a3ff710ddf9648c962878acc499339dd2 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 26 Nov 2024 11:15:23 -0500 Subject: [PATCH 8/8] fmt --- windows_build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/windows_build.rs b/windows_build.rs index 22a87d1c0..39dd4ac89 100644 --- a/windows_build.rs +++ b/windows_build.rs @@ -179,7 +179,6 @@ impl DevelPack { "vs16" }; - let zip_name = format!( "php-devel-pack-{}{}-Win32-{}-{}.zip", version,