-
Notifications
You must be signed in to change notification settings - Fork 466
fix: Deprecated null value warning in titleRendered callback
#3229
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
|
Great catch! We still want the resolver to return |
titleRendered callback
titleRendered callbacktitleRendered callback
|
Perhaps something like this: 'titleRendered' => function () { }, |
src/Model/Post.php
Outdated
| return $this->html_entity_decode( apply_filters( 'the_title', $title, $id ), 'titleRendered', true ); | ||
| $processedTitle = !empty($title) ? $this->html_entity_decode( apply_filters( 'the_title', $title, $id ), 'titleRendered', true ) : ''; | ||
|
|
||
| return $processedTitle === '' ? null : $processedTitle; |
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.
Avoid too many return statements within this method.
- formatting
| return $this->html_entity_decode( apply_filters( 'the_title', $title, $id ), 'titleRendered', true ); | ||
| $processedTitle = ! empty( $title ) ? $this->html_entity_decode( apply_filters( 'the_title', $title, $id ), 'titleRendered', true ) : ''; | ||
|
|
||
| return empty( $processedTitle ) ? null : $processedTitle; |
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.
Avoid too many return statements within this method.
|
Code Climate has analyzed commit ebd83de and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
This PR addresses a deprecation warning in PHP 8+ caused by passing a null value to the trim() function within the titleRendered method. Previously, if $this->data->post_title was null, it would be passed to apply_filters, potentially resulting in a null value for trim(). This caused a warning in environments using PHP 8+.
Changes Made:
Reason for Change:
Testing Notes: