-
Notifications
You must be signed in to change notification settings - Fork 385
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
fixed In PHP, it's deprecated to pass a null value to the first param… #7947
base: develop
Are you sure you want to change the base?
Conversation
…eter ($string) which is of type string.
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.
Thank you for the PR. I have a suggestion for improving it a bit further.
// 检查$path是否为null,若是则赋值为空字符串 | ||
$path = $path?? ''; |
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.
// 检查$path是否为null,若是则赋值为空字符串 | |
$path = $path?? ''; | |
if ( null === $path ) { | |
return false; | |
} |
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.
Thank you very much for taking the time to review my PR and providing such valuable suggestions. I really appreciate.
…() function raises a deprecation warning. Specifically, passing null to parameter
@@ -580,6 +580,10 @@ private function maybe_add_lightbox_attributes( $attributes, $node ) { | |||
private function is_gif_url( $url ) { | |||
$ext = self::$anim_extension; | |||
$path = wp_parse_url( $url, PHP_URL_PATH ); | |||
// 检查$path是否为null,若是则赋值为空字符串 |
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.
For this project, code comments are in English. In any case, no need for a comment here since the reason is self-explanatory:
// 检查$path是否为null,若是则赋值为空字符串 |
Summary
In PHP version 8.2, an issue has been identified where the substr() function raises a deprecation warning. Specifically, passing null to parameter #1 ($string) which is of type string is now deprecated. This problem occurs on line 583 of the file
Fixes
Our code in this pull request aims to address this deprecation issue by ensuring that a valid non-null string value is passed to the relevant parameter within the substr() function call, thereby making the code compliant with the requirements of PHP 8.2 and avoiding the appearance of such deprecation warnings.
Checklist