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

RSS block: check for description field before rendering excerpt #66985

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Nov 14, 2024

What? and How?

In the RSS block render code, check for author and description (excerpt) before passing to strip_tags and html_entity_decode.

Why?

Some RSS feeds don't have description or author fields.

And PHP complains:

Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated 
Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated

Noticed while testing #66419

Testing Instructions

  1. Insert an RSS block
  2. Insert an RSS feed that doesn't have description fields, e.g., http://rss.news.yahoo.com/rss/world
  3. Enable "Display excerpt" and "Display author" in the block's settings.
  4. Save and check that PHP deprecation warning doesn't appear in the editor or frontend.
  5. Insert an RSS feed that doesn't have author fields: https://feeds.simplecast.com/qm_9xx0g
  6. Save and check that PHP deprecation warning doesn't appear in the editor or frontend.

@ramonjd ramonjd added [Type] Bug An existing feature does not function as intended [Block] RSS Affects the RSS Block - used to display entries from an RSS/Atom feed labels Nov 14, 2024
@ramonjd ramonjd self-assigned this Nov 14, 2024
@ramonjd ramonjd requested a review from ajitbohra as a code owner November 14, 2024 03:21
Copy link

github-actions bot commented Nov 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>

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

Copy link

github-actions bot commented Nov 14, 2024

Flaky tests detected in 03bcd86.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11830605502
📝 Reported issues:

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for the quick fix!

✅ RSS feeds without descriptions no longer throw warnings
✅ RSS feeds with descriptions continue to display appropriately
❓ Is it worth also fixing the "author" use case as well?

Using the RSS feeds supplied in the test instructions, I saw similar PHP warnings when choosing to display the author while it was missing:

strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated

I think we might need to guard against that here.

Would you like to roll that fix into this PR or do it separately?

In case you'd prefer the latter, I'll approve this one now.

@ramonjd
Copy link
Member Author

ramonjd commented Nov 14, 2024

Is it worth also fixing the "author" use case as well?

Oh yeah, why not?! Thanks for testing. I didn't come across that but definitely worth fixing here.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Thanks for fixing up the author side of things as well. Appreciate it 👍

I've taken this for another spin and no longer receive the warnings for missing authors or description in the RSS feeds.

@ramonjd ramonjd merged commit 160482d into trunk Nov 14, 2024
63 checks passed
@ramonjd ramonjd deleted the update/rss-block-excerpt-check branch November 14, 2024 05:49
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] RSS Affects the RSS Block - used to display entries from an RSS/Atom feed [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants