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

Edge case: The editors break if the pattern category taxonomy is unregistered #67060

Open
3 of 6 tasks
carolinan opened this issue Nov 18, 2024 · 2 comments · May be fixed by #67063
Open
3 of 6 tasks

Edge case: The editors break if the pattern category taxonomy is unregistered #67060

carolinan opened this issue Nov 18, 2024 · 2 comments · May be fixed by #67063
Assignees
Labels
[Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

The wp_pattern_category is a taxonomy registered on the wp_block post type.

It can be unregistered using unregister_taxonomy_for_object_type

If the taxonomy is unregistered, the editors break with the following JavaScript error:

react-dom.min.js?ver=18:1 TypeError: Cannot read properties of undefined (reading 'map')
    at Pe (private-selectors.js:333:47)
    at private-selectors.js:394:6
    at Array.map (<anonymous>)
    at private-selectors.js:393:6
    at s (rememo.js:270:18)
    at r (factory.js:56:10)
    at r (index.js:249:13)
    at selectors.js:2482:22
    at s (rememo.js:270:18)
    at r (factory.js:56:10)

Image

I am not sure what the use case would be: But since unregistering is supported by WordPress, the editors should not break if it happens.

Step-by-step reproduction instructions

Unregister the taxonomy. For example, copy the following to functions.php in your active theme:

add_action( 'init', 'unregister' );
function unregister() {
	unregister_taxonomy_for_object_type( 'wp_pattern_category', 'wp_block' );
}

Create a new post. Confirm if there is a JavaScript error.

Screenshots, screen recording, code snippet

No response

Environment info

I am using WordPress 6.7 with Gutenberg trunk and:

define( 'WP_DEBUG', true );
define( 'WP_DEVELOPMENT_MODE', 'theme' );
define( 'WP_ENVIRONMENT_TYPE', 'local' );

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Nov 18, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 18, 2024
@im3dabasia
Copy link

I was able to reproduce the error, and after testing the patch, I can confirm that it resolves the issue.

@carolinan carolinan added the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Nov 18, 2024
@carolinan
Copy link
Contributor Author

I have set this to low priority because I believe that unregistering this taxonomy would be a very uncommon edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants