Skip to content

Widgets: Avoid PHP 8.1 deprecations in the RSS widget for incomplete feed items. - #15833

Open
dhrupo wants to merge 1 commit into
WordPress:trunkfrom
dhrupo:61179-rss-widget-malformed-feed
Open

dhrupo wants to merge 1 commit into
WordPress:trunkfrom
dhrupo:61179-rss-widget-malformed-feed

Conversation

@dhrupo

@dhrupo dhrupo commented Nov 8, 2026

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/61179

Summary

wp_widget_rss_output() passes SimplePie item values straight to strip_tags() and html_entity_decode(). SimplePie returns null when an item has no <link>, <title> or <description>, and SimplePie\Author::get_name() returns null for an RSS <author> that holds only an email address. On PHP 8.1 and later each of these logs "Passing null to parameter #1 ($string) of type string is deprecated".

This PR builds on #6826 by snehapatil2001 and the 59052.patch by vishalpadhariya on https://core.trac.wordpress.org/ticket/59052. Both guard only the description. As requested in https://core.trac.wordpress.org/ticket/61179#comment:7, this also covers missing titles and links (and author names), and adds a second test feed for items that are not well formed.

The change casts the four values to strings where they are read. The rendered output does not change:

  • A missing title still shows "Untitled".
  • A missing link still renders the title without an anchor.
  • A missing description still gives an empty summary.
  • An author without a name still gives an empty <cite></cite>.

Note for review: #9042 (https://core.trac.wordpress.org/ticket/63611) edits the same title line to add html_entity_decode(). Whichever lands second needs a one-line rebase there, and that call also needs the (string) cast.

Testing

New fixture tests/phpunit/data/feed/rss-incomplete-items.xml with one complete item and items missing a title, link, description or author name. The new test renders it through wp_widget_rss_output() with summary, author and date on, and asserts the full HTML output.

Before the change (trunk), PHP 8.5:

1) Tests_Widgets_wpWidgetRss::test_wp_widget_rss_output_should_handle_incomplete_feed_items
strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated
/Volumes/Projects/wordpress-develop-61179/src/wp-includes/widgets.php:1656
Tests: 1, Assertions: 0, Errors: 1.

Removing each cast on its own makes the test fail at that spot (lines 1656, 1658, 1663 and 1692). On trunk with PHP 7.4 the same test passes, which shows the expected HTML matches the current output.

After the change:

PHP 7.4  new test                     OK (1 test, 1 assertion)
PHP 7.4  --group widgets,feed,feeds   OK (649 tests, 2563 assertions)
PHP 8.5  new test                     OK (1 test, 1 assertion)
PHP 8.5  --group widgets,feed,feeds   OK (649 tests, 2563 assertions)

Manual test in WordPress Playground (PHP 8.5, WP_DEBUG_LOG on), rendering an RSS widget for the same feed on the front end:

trunk widgets.php:   PHP Deprecated: strip_tags() ... widgets.php on line 1656 / 1658 / 1692
                     PHP Deprecated: html_entity_decode() ... widgets.php on line 1663
patched widgets.php: debug.log empty, widget output unchanged

Use of AI Tools

Claude Code was used to refresh the patch and write the tests; I reviewed and tested everything myself.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…feed items.

SimplePie returns `null` from `get_link()`, `get_title()`, `get_description()` and `SimplePie\Author::get_name()` when a feed item is missing that element. `wp_widget_rss_output()` passed those values straight to `strip_tags()` and `html_entity_decode()`, which triggers "Passing null to parameter #1" deprecation notices on PHP 8.1 and later.

This casts each value to a string before it is used, so the rendered output stays the same: a missing title still shows "Untitled", a missing link still renders the title without an anchor, and a missing description still gives an empty summary.

Includes a second test feed with items that are missing a title, link, description or author name, to cover feeds that are not well formed.

Props snehapatil2001, vishalpadhariya, peterwilsoncc, Presskopp, treibstoff, dhrupo.
Fixes #61179. See #59052.
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dhrupo.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

geminorum pushed a commit to geminorum/wordpress-develop that referenced this pull request Nov 9, 2026
Scripts and styles in the admin and on the login screen are no longer concatenated through `load-scripts.php` and `load-styles.php`. Concatenation paid off when browsers opened few connections per host over HTTP/1.1, but it has long been a source of bugs: dependencies outside the default directories were not honored, `SCRIPT_DEBUG` and the `script_loader_src` and `style_loader_src` filters were ignored, inline styles could be duplicated, and code run by the loaders without WordPress loaded caused fatal errors. It was turned off by default in r64320, once the assets of the next admin screen began to be prefetched in r64120, and this removes what remains.

Every item is now printed as its own tag, and what remains of the concatenation API is deprecated or removed:
* The properties of `WP_Scripts` and `WP_Styles` that held items back for concatenation are deprecated but still declared, so plugins reading or setting them keep working. The `do_item()` methods no longer check `do_concat`.
* The `_print_scripts()`, `_print_styles()`, `script_concat_settings()`, `in_default_dir()` and `WP_Dependencies::get_etag()` functions are deprecated.
* The `print_head_scripts`, `print_footer_scripts`, `print_admin_styles` and `print_late_styles` filters only decided whether held markup was printed, so they are applied with `apply_filters_deprecated()` and their return values are ignored.
* The `CONCATENATE_SCRIPTS` constant is no longer read.
* The `wp_should_concatenate_admin_scripts()` function and its filter, added in r64120 for the transition and never released, are removed.

The loaders now respond with 410 Gone and a one-line plain text explanation, without loading WordPress, so that requests from bots and stale links cost next to nothing. Code written to run inside them without WordPress loaded, such as `wp_theme_has_theme_json()`, now uses the functions it had avoided, and `wp-admin/includes/noop.php` no longer defines its stub functions.

Developed in WordPress#14463.
Follow-up to r10357, r43580, r60719, r62657, r64120, r64320, r64485.

Props westonruter, jonsurrell, peterwilsoncc, azaozz, markhowellsmead, sergiomdgomes, jerclarke, adamsilverstein, sukhendu2002, adnan007, momo360modena, desrosj, welcher.
See WordPress#15833, #36448, #36449, #36779, #43825, #45008, #47322, #52879, #63908, #64087, #65515.
Fixes #57548.


git-svn-id: https://develop.svn.wordpress.org/trunk@64585 602fd350-edb4-49c9-b593-d223f7449a82
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
Scripts and styles in the admin and on the login screen are no longer concatenated through `load-scripts.php` and `load-styles.php`. Concatenation paid off when browsers opened few connections per host over HTTP/1.1, but it has long been a source of bugs: dependencies outside the default directories were not honored, `SCRIPT_DEBUG` and the `script_loader_src` and `style_loader_src` filters were ignored, inline styles could be duplicated, and code run by the loaders without WordPress loaded caused fatal errors. It was turned off by default in r64320, once the assets of the next admin screen began to be prefetched in r64120, and this removes what remains.

Every item is now printed as its own tag, and what remains of the concatenation API is deprecated or removed:
* The properties of `WP_Scripts` and `WP_Styles` that held items back for concatenation are deprecated but still declared, so plugins reading or setting them keep working. The `do_item()` methods no longer check `do_concat`.
* The `_print_scripts()`, `_print_styles()`, `script_concat_settings()`, `in_default_dir()` and `WP_Dependencies::get_etag()` functions are deprecated.
* The `print_head_scripts`, `print_footer_scripts`, `print_admin_styles` and `print_late_styles` filters only decided whether held markup was printed, so they are applied with `apply_filters_deprecated()` and their return values are ignored.
* The `CONCATENATE_SCRIPTS` constant is no longer read.
* The `wp_should_concatenate_admin_scripts()` function and its filter, added in r64120 for the transition and never released, are removed.

The loaders now respond with 410 Gone and a one-line plain text explanation, without loading WordPress, so that requests from bots and stale links cost next to nothing. Code written to run inside them without WordPress loaded, such as `wp_theme_has_theme_json()`, now uses the functions it had avoided, and `wp-admin/includes/noop.php` no longer defines its stub functions.

Developed in WordPress#14463.
Follow-up to r10357, r43580, r60719, r62657, r64120, r64320, r64485.

Props westonruter, jonsurrell, peterwilsoncc, azaozz, markhowellsmead, sergiomdgomes, jerclarke, adamsilverstein, sukhendu2002, adnan007, momo360modena, desrosj, welcher.
See WordPress#15833, #36448, #36449, #36779, #43825, #45008, #47322, #52879, #63908, #64087, #65515.
Fixes #57548.


git-svn-id: https://develop.svn.wordpress.org/trunk@64585 602fd350-edb4-49c9-b593-d223f7449a82
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.

1 participant