Codeinwp / otter-blocks

Create beautiful and attracting posts, pages, and landing pages with Gutenberg Blocks and Template Library by Otter.
https://wordpress.org/plugins/otter-blocks/
GNU General Public License v3.0
129 stars 33 forks source link

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

Closed Soare-Robert-Daniel closed 2 months ago

Soare-Robert-Daniel commented 2 months ago

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 https://github.com/Codeinwp/otter-blocks/issues/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

pirate-bot commented 2 months ago

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 commented 2 months ago

Plugin build for 33b4b381484cf78a1e91b9fb3684ff1f6dabf773 is ready :bellhop_bell:!

pirate-bot commented 2 months ago

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 commented 2 months ago

:tada: This PR is included in version 2.6.11 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: