-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/standard: Deprecate passing string which are not one byte long to ord() #19440
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
Conversation
d558365
to
7006002
Compare
@nielsdos do you have any idea why the CI is failling with a memory exhaustion? I can't seem to reproduce this locally at all :| |
It happens during output collection. Could it be that one test emits an extreme amount of deprecations? |
You could try removing the |
php_error_docref(NULL, E_DEPRECATED, | ||
"Providing a string which is not one byte long is deprecated, use ord($str[0]) instead"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the deprecation is converted to an exception - should RETURN_LONG still be used? Can you add a test case for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of a conversion, the return value is simply discarded by the VM or JIT. So no special exception handling is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RM approval
ext/standard/string.c
Outdated
"Providing an empty string is deprecated"); | ||
} else { | ||
php_error_docref(NULL, E_DEPRECATED, | ||
"Providing a string which is not one byte long is deprecated, use ord($str[0]) instead"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the restrictive vs non-restrictive clause thing, so it needs to be "that" instead of "which" ?
"Providing a string which is not one byte long is deprecated, use ord($str[0]) instead"); | |
"Providing a string that is not one byte long is deprecated, use ord($str[0]) instead"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Crell any opinion on the wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a restrictive clause, so that
is slightly more correct but both are widely used. I'd say go with that
.
https://www.merriam-webster.com/grammar/when-to-use-that-and-which
The bigger issue is that the comma should be a period, and use
should start a new sentence. Otherwise it's a run-on sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from mbstring.
d7c8d95
to
000fe44
Compare
This PR was merged into the 6.4 branch. Discussion ---------- [Console] do not pass the empty string to ord() | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT see php/php-src#19440 and https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord Commits ------- 30037a1 do not pass the empty string to ord()
This PR was merged into the 7.3 branch. Discussion ---------- [JsonPath] do not pass more than one byte to ord() | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT see php/php-src#19440 Commits ------- cbdcffc do not pass more than one byte to ord()
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord