#56284 closed defect (bug) (fixed)
Site Editor: Pass correct context into get_block_categories
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
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.
3 years ago
#1
- Keywords has-patch added
3 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
@
3 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.
#7
@
3 years ago
- Owner set to gziolo
- Resolution set to fixed
- Status changed from new to closed
In 53784:
3 years ago
#8
Committed with https://core.trac.wordpress.org/changeset/53784.
Passes correct context into get_block_categories and removes
$post
global from the site-editor.php file.Trac ticket: https://core.trac.wordpress.org/ticket/56284