Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#53757 closed defect (bug) (fixed)

Widget editor calls get_block_categories() with incorrect arg type

Reported by: Enchiridion Owned by: audrasjb
Priority: normal Milestone: 5.8.1
Component: Widgets Version: 5.8
Severity: normal Keywords: has-patch commit fixed-major
Cc: Focuses:

Description

Just updated to 5.8.0 and found a couple issues with the new block widget editor while fixing all the new deprecated filters related to blocks.

\wp-admin\widgets-form-blocks.php:55
sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( 'widgets-editor' ) ) ),

\wp-includes\class-wp-customize-widgets.php:865
sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( 'widgets-customizer' ) ) ),

In these two places, get_block_categories() is being passed a string instead of the required WP_Post or WP_Block_Editor_Context instance. The string is causing a fatal error due to the type hinting on my function for the block_categories_all filter.

Change History (9)

#1 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review5.8.1

#2 @audrasjb
5 years ago

  • Keywords needs-patch added

Good catch. It looks like we should replace 'widgets-customizer' and 'widgets-editor' with $block_editor_context variable on both files.

This ticket was mentioned in PR #1532 on WordPress/wordpress-develop by pbearne.


5 years ago
#3

  • Keywords has-patch added; needs-patch removed

Replaced 'widgets-customizer' and 'widgets-editor' with $block_editor context in get_block_categories() function calls

Trac ticket: https://core.trac.wordpress.org/ticket/53757

willrowe commented on PR #1532:


5 years ago
#4

Just got errors related to this, thanks for the fix @pbearne!

#5 @audrasjb
5 years ago

  • Keywords commit added
  • Owner set to audrasjb
  • Status newaccepted

PR #1532 applies cleanly against trunk and fixes the issue on my side. Thanks for the PR!

Marking for commit consideration as this issue is clearly related to the widget editor and needs to be addressed in the next point release.

#6 @SergeyBiryukov
5 years ago

  • Resolutionfixed
  • Status acceptedclosed

In 51700:

Widgets: Pass correct context to get_block_categories() calls.

The get_block_categories() function expects either a WP_Post or a WP_Block_Editor_Context instance as the context argument, not a string.

Follow-up to [50996], [50997].

Props Enchiridion, pbearne, audrasjb.
Fixes #53757.

#7 @SergeyBiryukov
5 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closedreopened

Reopening for backporting to the 5.8 branch.

#9 @desrosj
5 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 51711:

Widgets: Pass correct context to get_block_categories() calls.

The get_block_categories() function expects either a WP_Post or a WP_Block_Editor_Context instance as the context argument, not a string.

Follow-up to [50996], [50997].

Props Enchiridion, pbearne, audrasjb, SergeyBiryukov.
Merges [51700] to the 5.8 branch.
Fixes #53757.

Note: See TracTickets for help on using tickets.