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

(WP 6.4-compat) Add missing type attribute in WP 6.4 compat's block-hooks.php #55138

Conversation

fullofcaffeine
Copy link
Member

What?

Add missing type attribute in WP 6.4 compat's block-hooks.php

Why?

Activating Gutenberg 16.7+ in an env with WP 6.4 is causing failures in the following test: https://github.com/WordPress/wordpress-develop/blob/36d4e7ebcc2deb9ec9de7f4ffc4161135f87d1c5/tests/phpunit/tests/rest-api/rest-block-type-controller.php, because Gutenberg does not define the type in schema for block-type and block-hooks fields in its back compat shim. Example of a failure (there are around 10 if you try running it):

Unexpected incorrect usage notice for rest_sanitize_value_from_schema.
The "type" schema keyword for  is required. (This message was added in version 5.5.0.)
Failed asserting that an array is empty.

How?

See "What".

Testing Instructions

  1. Without applying this patch, Install Gutenberg 16.7 (or trunk) in a dev version of WP 6.4 with PHPUnit tests setup
  2. Run https://github.com/WordPress/wordpress-develop/blob/36d4e7ebcc2deb9ec9de7f4ffc4161135f87d1c5/tests/phpunit/tests/rest-api/rest-block-type-controller.php;
  3. Verify that tests fail;
  4. Now build a new GB from this branch and install it in that WP 6.4 env
  5. Run the test again - it should pass.

Testing Instructions for Keyboard

Screenshots or screencast

@fullofcaffeine fullofcaffeine requested review from gziolo and removed request for spacedmonkey October 6, 2023 18:22
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Warning: Type of PR label error

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: .

Read more about Type labels in Gutenberg.

@fullofcaffeine fullofcaffeine requested a review from ockham October 6, 2023 18:22
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/compat/wordpress-6.4/block-hooks.php

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Flaky tests detected in 502d671.
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/6435218018
📝 Reported issues:

Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

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

I can confirm this solves the issue.

@noahtallen noahtallen merged commit 72c7d06 into trunk Oct 6, 2023
47 of 49 checks passed
@noahtallen noahtallen deleted the add/missing-type-object-field-in-block-hooks-schema-6.4-compat branch October 6, 2023 22:41
@github-actions github-actions bot added this to the Gutenberg 16.9 milestone Oct 6, 2023
@noahtallen
Copy link
Member

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

cc @gziolo -- since this change is required to get the core PHPUnit tests to pass, does this need to be part of the WordPress backport? I'm not exactly sure how that works with compat files

noahtallen pushed a commit that referenced this pull request Oct 6, 2023
…s `block-hooks.php` (#55138)

* Add missing `type` attribute in WP 6.4 compat's `block-hooks.php`
* Type is required for API schemas
@gziolo
Copy link
Member

gziolo commented Oct 9, 2023

since this change is required to get the core PHPUnit tests to pass, does this need to be part of the WordPress backport? I'm not exactly sure how that works with compat files

It looks like everything is looking good on the core side. Thank you for bringing the same changes to the plugin to the code that offers backward compatibility for older versions of WordPress:

https://github.com/WordPress/wordpress-develop/blob/eb0ae5679a3477c4507b09a283c05b67b87130ab/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php#L717-L729

noahtallen pushed a commit that referenced this pull request Oct 10, 2023
…s `block-hooks.php` (#55138)

* Add missing `type` attribute in WP 6.4 compat's `block-hooks.php`
* Type is required for API schemas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants