Opened 6 months ago
Last modified 3 weeks ago
#61179 reviewing defect (bug)
Deprecated messages about passing null in widgets.php
Reported by: | Presskopp | Owned by: | hellofromTonya |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | Widgets | Keywords: | php81 has-patch has-unit-tests |
Focuses: | php-compatibility | Cc: |
Description
I found the following message in my error logs:
PHP Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in ...\wp-includes\widgets.php on line 1630
This is the latest nightly on PHP8.3, but if you search for "widgets.php on line 1630" in your search engine, you will find online sites having the same issue
Line 1630 is the following:
$desc = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
Change History (7)
This ticket was mentioned in PR #6826 on WordPress/wordpress-develop by @snehapatil02.
5 months ago
#1
- Keywords has-patch has-unit-tests added
@snehapatil02 commented on PR #6826:
4 months ago
#2
@mukeshpanchal27
Changes made:
- Modified the RSS widget output function in wp-includes/widgets.php
- Added a check to ensure the RSS item description is not empty before processing
- If the description is empty, we set $desc to an empty string
- This prevents calling html_entity_decode() with a null value
@snehapatil02 commented on PR #6826:
4 months ago
#3
@mukeshpanchal27 Done with the suggested changes.
#4
@
2 months ago
- Focuses php-compatibility added
- Keywords php81 added
- Milestone changed from Awaiting Review to 6.7
- Version changed from 6.6 to 2.8
The $item
is an instance of SimplePie_Item
. It's get_description()
method returns a `string` on success, otherwise, it returns `null`.
Thus, yes, defensive logic is needed to avoid passing null
to html_entity_decode()
. Moving this ticket into 6.7.
Which version of WordPress introduced this issue?
wp_widget_rss_output()
was introduced in 2.5.0. However, using SimplePie was introduced in 2.8.0 via [10666]. Changed the Version that introduced the code to 2.8.
Also marking this ticket as php-compatibility
focus with php81
keyword to denote when the deprecation was introduced in PHP.
#5
@
2 months ago
- Owner set to hellofromTonya
- Status changed from new to reviewing
Self-assigning to shepherd it forward and for committer review and commit.
This ticket was mentioned in Slack in #core by chaion07. View the logs.
4 weeks ago
#7
@
3 weeks ago
- Milestone changed from 6.7 to 6.8
I've reviewed the linked pull request.
The same issue occurs with empty/missing titles and links so I think the patch needs a little more work to improve the handling of invalid and malformed feeds.
The test suite uses wordpress-org-news.xml
to test well formed feeds, I think it needs a second file to test for edge cases for feeds that are not well formed.
As WordPress 6.7 is going in to the RC phase in a few days, I'm going to move this off the milestone for further work in the 6.8 release cycle.
## Ticket
https://core.trac.wordpress.org/ticket/61179
## Description
widgets.php
file when running WordPress on PHP 8.3. The warning occurs becausehtml_entity_decode()
is called withnull
as its first parameter, which is deprecated in PHP 8.3.## Changes
html_entity_decode
call inwidgets.php
to use the null coalescing operator (??
) to provide an empty string as a default value if$item->get_description()
returnsnull
.## Testing Instructions
null
for its description. Check that no deprecation warnings are logged and the output is correct.