Skip to content

Conversation

@juanfra
Copy link
Member

@juanfra juanfra commented Jan 16, 2026

What?

This PR fixes a potential bug where preg_replace() failures could silently corrupt content in the normalize_content() function. It's an edge case.

Why?

If any of these preg_replace() calls failed and returned null, the code would continue with null being cast to an empty string in subsequent operations. This could silently corrupt content without any indication of an error.

How?

Added null coalescing operator to all three preg_replace() calls in normalize_content().

Not sure if we want to document the @since for any modifications. If that's the case, please let me know, and I'll be happy to make the addition.

Open WordPress Playground Preview

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

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: juanfra <[email protected]>
Co-authored-by: jeffpaul <[email protected]>
Co-authored-by: dkotter <[email protected]>

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

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.33%. Comparing base (9a4845d) to head (fd0d510).
⚠️ Report is 20 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #177      +/-   ##
=============================================
- Coverage      50.91%   50.33%   -0.58%     
+ Complexity       375      366       -9     
=============================================
  Files             27       26       -1     
  Lines           1974     1951      -23     
=============================================
- Hits            1005      982      -23     
  Misses           969      969              
Flag Coverage Δ
unit 50.33% <100.00%> (-0.58%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul merged commit efd35ce into WordPress:develop Jan 23, 2026
21 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Jan 23, 2026
@juanfra juanfra deleted the fix/null-handling-preg-replace branch January 24, 2026 09:09
@dkotter dkotter modified the milestones: 0.3.0, 0.2.1 Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants