Uh oh!
There was an error while loading. Please reload this page.
ext/standard: validate mode in array_filter() - #15647
Conversation
bukka
commented
Sep 2, 2024
I think this might be safer to go through deprecation first. |
bukka
commented
Sep 2, 2024
Technically it's a BC break as the invalid mode is currently ignored. |
jorgsowa
commented
Sep 2, 2024
Makes sense. I will wait for PHP 8.5. I was following a similar change with |
cmb69
commented
Oct 30, 2024
A deprecation is certainly more user friendly, but requiring the RFC process for this appears to be overkill. After all, users are not supposed to pass nonsense to well documented functions. |
bukka
commented
Nov 2, 2024
Well just that something users are not supposed to do, does not mean that it's not a BC break. In my opinion it is a BC break and as such we should go through the deprecation. I agree that doing RFC is overkill but I don't think we need RFC if we get some sort of agreement. |
Uh oh!
There was an error while loading. Please reload this page.
| @@ -6533,15 +6544,15 @@ PHP_FUNCTION(array_filter) | |||
| ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_key, string_key, operand) { | |||
| if (have_callback) { | |||
| if (use_type) { | |||
| if (mode) { | |||
There was a problem hiding this comment.
If you want to be explicit, you should use mode != ARRAY_FILTER_USE_VALUE, which should end up compiling to the same thing.
There was a problem hiding this comment.
I also missed this, this is still unresolved.
9245732 to
2111c36Compare
iluuu1994
left a comment
There was a problem hiding this comment.
LGTM. I wouldn't object to this in a minor version, but @bukka should confirm whether he does. If so, you can just change the error to a deprecation. According to the policy:
https://github.com/php/policies/blob/main/release-process.rst#feature-selection-and-development
However, any change that breaks user-facing backward compatibility MUST go through the RFC process.
From a pedantic PoV, this is breaking. In that case, this would even need an entry in the deprecation RFC.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e780744 to
cd686d9Compare
Girgias
left a comment
There was a problem hiding this comment.
Needs an UPGRADING entry but otherwise implementation looks good to me.
jorgsowa
commented
Jan 20, 2026
Thank you for review. Entry added to UPGRADING. |
4c2201a to
6edc245Comparejorgsowa
commented
Jan 25, 2026
Could this PR be merged? |
Uh oh!
There was an error while loading. Please reload this page.
Girgias
commented
Jan 26, 2026
Merged, as having it lie around isn't helpful. If someone complains this can always be revisited. |
jorgsowa
commented
Jan 26, 2026
Thank you @Girgias |
…RRAY_FILTER_USE_VALUE` In phpGH-15647, the `array_filter` function was changed to throw a `ValueError` exception when the `$mode` parameter receives an invalid. Additionally, it declares a new `ARRAY_FILTER_USE_VALUE`, assigned (`int 1`) to it. This changes the default value of the `array_filter` function's `$mode` parameter to use the new constant, changing it from `int $mode = 0` to `int $mode = ARRAY_FILTER_USE_KEY)`.
…RRAY_FILTER_USE_VALUE` In GH-15647, the `array_filter` function was changed to throw a `ValueError` exception when the `$mode` parameter receives an invalid. Additionally, it declares a new `ARRAY_FILTER_USE_VALUE`, assigned (`int 1`) to it. This changes the default value of the `array_filter` function's `$mode` parameter to use the new constant, changing it from `int $mode = 0` to `int $mode = ARRAY_FILTER_USE_KEY)`. ClosesGH-21100.
Validates
modein the functionarray_filter()and creates complementaryARRAY_FILTER_USE_VALUEwithout exposing it as a PHP constant.