#56284 closed defect (bug) (fixed)
Site Editor: Pass correct context into get_block_categories
| Reported by: | Mamaduka | Owned by: | gziolo |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.1 |
| Component: | Editor | Version: | 5.9 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Site Editor passes global $post as a context when setting up block categories. Instead, it should pass $block_editor_context, since global $post is null in this file.
To reproduce:
<?php add_filter( 'block_categories_all', function( $categories, $context ) { error_log( var_export( $context instanceof WP_Block_Editor_Context, true ) ); return $categories; }, 10, 2 );
Expected:
The example above should log true twice.
Actual:
Logs true and false.
Note: The second log represents the get_block_categories call when setting up the categories. The first comes from get_block_editor_settings, where context is correctly set.
Change History (8)
This ticket was mentioned in PR #3021 on WordPress/wordpress-develop by Mamaduka.
4 years ago
#1
- Keywords has-patch added
4 years ago
#3
Thank you for working on it and the ping @Mamaduka. It looks like a step in the right direction. It feels like there are more places where the same issue might exist already, or it might get exposed in the future when the context passed on different screens further evolves.
#4
@
4 years ago
To clarify, with the patch applied, the filter presented in the description runs only once and it has the correct block context provided.
4 years ago
#8
Committed with https://core.trac.wordpress.org/changeset/53784.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Passes correct context into get_block_categories and removes
$postglobal from the site-editor.php file.Trac ticket: https://core.trac.wordpress.org/ticket/56284