Skip to content
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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

5Vmc
Copy link

@5Vmc 5Vmc commented Dec 7, 2024

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

  • [true] My code is tested and passes existing tests.
  • [true] My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@CLAassistant
Copy link

CLAassistant commented Dec 7, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@westonruter westonruter left a 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.

Comment on lines 583 to 584
// 检查$path是否为null,若是则赋值为空字符串
$path = $path?? '';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// 检查$path是否为null,若是则赋值为空字符串
$path = $path?? '';
if ( null === $path ) {
return false;
}

Copy link
Author

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.

@westonruter westonruter added this to the v2.5.6 milestone Dec 7, 2024
…() 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,若是则赋值为空字符串
Copy link
Member

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:

Suggested change
// 检查$path是否为null,若是则赋值为空字符串

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants