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

fix: enforce display condition to return string in render_block filter #2192

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

Soare-Robert-Daniel
Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel commented Apr 22, 2024

Closes #2191

Summary

Because the function render_blocks for block conditions could not return anything, an error is raised because the filter render_block must return a string.

I refactored the function so that it always returns a string. Also, change from add_action to add_filter since render_block exists as a filter, and with the new phpdoc added to the function, phpstan does not allow us to use the add_action since we are always returning something.

Note

By being aware of #2177, in this PR, the introduced test is critical to succeed.


Test instructions

  1. Use Otter Free.
  2. Create a new post and insert an Image Block
  3. Set the condition to be visible to the Logged User.
  4. Check the page if the block is rendered.
  5. Log out, then recheck the page. The block should be hidden, and no fatal error should happen.

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@Soare-Robert-Daniel Soare-Robert-Daniel added the pr-checklist-skip Allow this Pull Request to skip checklist. label Apr 22, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel self-assigned this Apr 22, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel marked this pull request as ready for review April 22, 2024 10:45
@pirate-bot
Copy link
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 239.1 KB 239.1 KB 0 B (0.00%)
Blocks 1.5 MB 1.5 MB 0 B (0.00%)
CSS 93.17 KB 93.17 KB 0 B (0.00%)
Dashboard 201.53 KB 201.53 KB 0 B (0.00%)
Onboarding 154.18 KB 154.18 KB 0 B (0.00%)
Export Import 90.95 KB 90.95 KB 0 B (0.00%)
Pro 355.91 KB 355.91 KB 0 B (0.00%)

@pirate-bot
Copy link
Contributor

Plugin build for 33b4b38 is ready 🛎️!

@pirate-bot
Copy link
Contributor

E2E Tests

Playwright Test Status:

Performance Results serverResponse: 221.4, firstPaint: 565.3, domContentLoaded: 1578.35, loaded: 1578.85, firstContentfulPaint: 3673.8, firstBlock: 5542.3, type: 12.49, minType: 10.23, maxType: 16.44, typeContainer: 8.25, minTypeContainer: 6.91, maxTypeContainer: 9.43, focus: 42.62, minFocus: 36.91, maxFocus: 53.8, inserterOpen: 27.85, minInserterOpen: 24.37, maxInserterOpen: 32.55, inserterSearch: 6.4, minInserterSearch: 5.98, maxInserterSearch: 7.12, inserterHover: 3.41, minInserterHover: 2.83, maxInserterHover: 4.5, listViewOpen: 158.27, minListViewOpen: 138.7, maxListViewOpen: 204.34

@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Apr 22, 2024
@Soare-Robert-Daniel Soare-Robert-Daniel linked an issue Apr 22, 2024 that may be closed by this pull request
@Soare-Robert-Daniel Soare-Robert-Daniel requested review from GrigoreMihai and removed request for preda-bogdan April 22, 2024 13:32
@Soare-Robert-Daniel Soare-Robert-Daniel merged commit 7618567 into development Apr 22, 2024
34 checks passed
@Soare-Robert-Daniel Soare-Robert-Daniel deleted the fix/logged-out-cond-crash branch April 22, 2024 13:46
@Soare-Robert-Daniel Soare-Robert-Daniel mentioned this pull request Apr 22, 2024
@pirate-bot
Copy link
Contributor

🎉 This PR is included in version 2.6.11 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist. released Indicate that an issue has been resolved and released in a particular version of the product.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fatal error using block conditions and wp 6.5+
3 participants