Skip to content

Boost: Fix sprintf function call compatibility with Gutenberg 21.2 #44418

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

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

LiamSarsfield
Copy link
Contributor

@LiamSarsfield LiamSarsfield commented Jul 22, 2025

Fixes HOG-219: Cornerstone pages UI broken when Gutenberg plugin is active

Proposed changes:

  • Fixed incorrect usage of sprintf() in CornerstoneTitleSummary component where an anonymous function was passed as the second argument instead of calling the function to get its return value

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

N/A

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  1. Go to Jetpack Boost settings
  2. Navigate to Cornerstone Pages section
  3. Verify the title summary displays correctly formatted text instead of raw function code
  4. Add/remove cornerstone pages and verify the summary updates correctly
  5. Test with different numbers of cornerstone pages (0, 1, multiple)

Compatibility Testing:

  • Test with Gutenberg 21.2+ (should work correctly)
  • Test with Gutenberg 21.1.1 and earlier (should continue working)
  • Test without Gutenberg plugin (should continue working with WordPress core)

Background

Root Cause: The issue was caused by incorrect usage of sprintf() where we passed an anonymous function as the second argument instead of calling the function first.

Why it worked before: WordPress core and Gutenberg ≤21.1.1 used the sprintf-js library that would automatically execute function arguments via its computed values functionality.

What changed: Gutenberg 21.2 updated their @wordpress/i18n implementation to use a standards-compliant sprintf that doesn't execute function arguments, causing the function code to be displayed as text. (WordPress/gutenberg#70434)

The fix: Changed from sprintf(template, functionRef) to sprintf(template, functionRef()) to ensure we pass the actual value instead of the function reference.

@github-actions github-actions bot added [Plugin] Boost A feature to speed up the site and improve performance. [Status] In Progress labels Jul 22, 2025
Copy link
Contributor

github-actions bot commented Jul 22, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Boost plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 22, 2025
@LiamSarsfield LiamSarsfield added [Type] Bug When a feature is broken and / or not performing as intended and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 22, 2025
Copy link

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/boost/app/assets/src/js/features/cornerstone-pages/cornerstone-pages.tsx 0/13 (0.00%) 0.00% -2 💚

Full summary · PHP report · JS report

@LiamSarsfield LiamSarsfield requested review from kraftbj, dilirity and a team July 22, 2025 16:51
@LiamSarsfield LiamSarsfield marked this pull request as ready for review July 22, 2025 16:51
Copy link
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

Confirmed the bug and that this patch resolves it.

@kraftbj
Copy link
Contributor

kraftbj commented Jul 22, 2025

I'm going to go ahead and merge this so trunk is good against latest Gutenberg. If there's more to be done @LiamSarsfield , can you note it and open a new PR?

@kraftbj kraftbj merged commit 3cd517b into trunk Jul 22, 2025
76 checks passed
@kraftbj kraftbj deleted the fix/boost/gutenberg-plugin-conflict-HOG-219 branch July 22, 2025 19:37
@LiamSarsfield
Copy link
Contributor Author

If there's more to be done @LiamSarsfield , can you note it and open a new PR?

This is the only culprit of this specific issue I found, though if I encounter any further ones, will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Boost A feature to speed up the site and improve performance. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants