Skip to content

Add PHP 8.5 initial support #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Aug 5, 2025
Merged

Add PHP 8.5 initial support #819

merged 79 commits into from
Aug 5, 2025

Conversation

crazywhalecc
Copy link
Owner

@crazywhalecc crazywhalecc commented Jul 15, 2025

What does this PR do?

Support PHP 8.5 alpha.

TODO

Tracked all unsupported things and future versions in #842 .

Checklist before merging

If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
If a modification is not involved, please skip it directly.

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:
    • PHP_CS_FIXER_IGNORE_ENV=1 composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:sort-config
  • If it's an extension or dependency update, please ensure the following:
    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

@crazywhalecc crazywhalecc self-assigned this Jul 15, 2025
@crazywhalecc crazywhalecc added kind/php-and-sapi Issues related to php source and SAPI mixed PR This PR contains multiple updates labels Jul 15, 2025
@crazywhalecc crazywhalecc marked this pull request as draft July 15, 2025 13:19
@henderkes
Copy link
Collaborator

Hahaha, I have been working on this, too.

@henderkes
Copy link
Collaborator

We should also put a watch on php/php-src#18660 because it might land in 8.5.

@henderkes
Copy link
Collaborator

It was merged, opcache is always statically compiled into php 8.5.

@crazywhalecc
Copy link
Owner Author

Looks like we have to wait alpha3 or test master branch directly.

@crazywhalecc
Copy link
Owner Author

We should also put a watch on php/php-src#18660 because it might land in 8.5.

Looks like we don't need to patch opcache for PHP 8.5 at all. We only need to add version check and just ignore opcache extension like json, but the phpmicro project would have to create an empty patch file to avoid backward conflicts.

Copy link
Owner Author

@crazywhalecc crazywhalecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change

@henderkes
Copy link
Collaborator

I find a few related issues like here: https://stackoverflow.com/questions/14078182/openssl-file-get-contents-failed-to-enable-crypto

Question is why that only happens when MUSL is defined

@crazywhalecc
Copy link
Owner Author

crazywhalecc commented Aug 2, 2025

Interesting. When I use configure.ac patches instead of passing CPPFLAGS=-D__MUSL__, everything works as expected.

So the conclusion for now:

Currently we could know that the ssl bug is not related to __MUSL__, but related to CPPFLAGS define.

@henderkes
Copy link
Collaborator

I will upstream a fix for that to php-src. There are better ways to detect musl without breaking cross-compilation.

@crazywhalecc
Copy link
Owner Author

I will upstream a fix for that to php-src. There are better ways to detect musl without breaking cross-compilation.

That's great! btw how do you plan to detect musl from cross toolchain?

And please review all the changes again. I will merge this branch soon and then introduce some logger refactoring based on it.

@henderkes
Copy link
Collaborator

henderkes commented Aug 3, 2025

Musl doesn't define the _USE_GNU macro in features.h, so we can write a feature test

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/features.h>
#ifdef _USE_GNU
#error Not using musl
#endif

and try to compile that. Won't break cross-compilation.

@henderkes
Copy link
Collaborator

php/php-src#19352

Comment on lines 33 to 34
} else {
$args .= ' --without-openssl-argon2';
Copy link
Collaborator

@henderkes henderkes Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed, I mean that we must disable the fake password-argon2 extension in case openssl-argon2 is used.

Copy link
Owner Author

@crazywhalecc crazywhalecc Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. But --with-password-argon2 is different from --with-openssl-argon2. Considering that Herd and some laravel projects use it, and it has not been deprecated yet, we should treat them separately. We cannot remove it until password-argon2 is deprecated in PHP standard extension.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with-openssl-argon2 implements the functionality of with-password-argon2. When both are defined, I'm not sure which backend will be used.

Essentially we need to have this check in both extensions and use the openssl one if possible, but fall back to the coding contest implementation.

Copy link
Owner Author

@crazywhalecc crazywhalecc Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to config.m4 and function source, --with-password-argon2 is defined to use the standalone libargon2, while --with-openssl-argon2 is using openssl. And these are used from different function: password_hash and openssl_password_hash. They shouldn't conflict.

Copy link
Collaborator

@henderkes henderkes Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password_hash exists either way. When no implementation is chosen, it falls back to libsodium (no threads option). Argon2 and openssl can change the bachend implementation, but I'm not sure which backend will be chosen in case both are enabled. Remi explicitly enables --with-openssl-argon2 and --without-password-argon2.

We want it to use the openssl backend because it's the most well-maintained implementation.

Copy link
Owner Author

@crazywhalecc crazywhalecc Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like if we enabled libargon2, it will use it first. Otherwise it will search from zend bucket.

Anyway, I don't think we have to adjust pwhash function and dependency here. But if we could confirm and validate that openssl is able to cover it, we could make password-argon2 to depends on openssl instead of libargon2 later.

Copy link
Collaborator

@henderkes henderkes Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, only from php 8.4 for NTS and 8.5 for ZTS sadly. My point is that we should let openssl be the backend for the password_hash function if possible. I'll look into it tomorrow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henderkes
Copy link
Collaborator

php/php-src#19360

Could simplify it a little.

@henderkes
Copy link
Collaborator

closes #845

@crazywhalecc crazywhalecc merged commit 085abd6 into main Aug 5, 2025
13 checks passed
@crazywhalecc crazywhalecc deleted the php-85 branch August 5, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/php-and-sapi Issues related to php source and SAPI mixed PR This PR contains multiple updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build 错误,str_contains(): Argument #1 ($haystack) must be of type string, false given Switch argon2 implementation to openssl in 8.5
2 participants