Opened 3 months ago
Last modified 4 weeks ago
#61179 new defect (bug)
Deprecated messages about passing null in widgets.php
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | Widgets | Keywords: | has-patch has-unit-tests |
Focuses: | 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 (3)
This ticket was mentioned in PR #6826 on WordPress/wordpress-develop by @snehapatil02.
6 weeks ago
#1
- Keywords has-patch has-unit-tests added
@snehapatil02 commented on PR #6826:
4 weeks 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 weeks ago
#3
@mukeshpanchal27 Done with the suggested changes.
## 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.