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

Block categories: Inconsistent legacy mappings #23118

Closed
sirreal opened this issue Jun 12, 2020 · 5 comments
Closed

Block categories: Inconsistent legacy mappings #23118

sirreal opened this issue Jun 12, 2020 · 5 comments
Labels
[Package] Blocks /packages/blocks [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request.

Comments

@sirreal
Copy link
Member

sirreal commented Jun 12, 2020

Describe the bug

When reviewing changes from #19279, I noticed that the compatibility mappings for legacy block categories appear to have inconsistent mappings in PHP and JavaScript. In PHP formatting is mapped to media, whereas in JavaScript it's mapped to text:

gutenberg/lib/compat.php

Lines 339 to 355 in 84df4bd

$substitution = array(
'common' => array(
'slug' => 'text',
'title' => __( 'Text', 'gutenberg' ),
'icon' => null,
),
'formatting' => array(
'slug' => 'media',
'title' => __( 'Media', 'gutenberg' ),
'icon' => null,
),
'layout' => array(
'slug' => 'design',
'title' => __( 'Design', 'gutenberg' ),
'icon' => null,
),
);

const LEGACY_CATEGORY_MAPPING = {
common: 'text',
formatting: 'text',
layout: 'design',
};

I'm not sure how this bug manifests, but I'd expect these mappings to be consistent.

CC: @mtias

@sirreal sirreal added [Type] Bug An existing feature does not function as intended [Package] Blocks /packages/blocks labels Jun 12, 2020
@mcsf
Copy link
Contributor

mcsf commented Jun 24, 2020

The original PR's description does list Text as the destination for Formatting. I guess we should patch the PHP rules, then, and do it quickly so that no mistakes are carried over in the 5.5 PHP backporting process in #23210.

@gziolo
Copy link
Member

gziolo commented Jun 24, 2020

There is no mapping in WordPress core. It’s a simple act of replacing categories 😃

@mcsf
Copy link
Contributor

mcsf commented Jun 26, 2020

There is no mapping in WordPress core. It’s a simple act of replacing categories 😃

Looking at https://github.com/WordPress/wordpress-develop/blob/24465974cd6333137490b55ab663f3d1f844a95e/src/wp-admin/includes/post.php#L2180-L2210, category Design still needs to be added.

@gziolo
Copy link
Member

gziolo commented Jun 29, 2020

Design is already there in WordPress core:
https://github.com/WordPress/wordpress-develop/blob/24465974cd6333137490b55ab663f3d1f844a95e/src/wp-admin/includes/post.php#L2191-L2195

I examined code and I think everything looks good. The confusion comes from the fact that the compat layer in PHP only updates the list of default categories and JS does the mapping.

@gziolo gziolo closed this as completed Jun 29, 2020
@gziolo gziolo added [Status] Not Implemented Issue/PR we will (likely) not implement. [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request. and removed [Type] Bug An existing feature does not function as intended [Status] Not Implemented Issue/PR we will (likely) not implement. labels Jun 29, 2020
@mcsf
Copy link
Contributor

mcsf commented Jun 29, 2020

Design is already there in WordPress core:

Never mind, I don't know how I missed that. 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Blocks /packages/blocks [Status] Not Applicable Issue outside Gutenberg, is not a bug, or is a support request.
Projects
None yet
Development

No branches or pull requests

3 participants