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

Synced patterns/Reusable blocks: exporting the theme breaks synced patterns #53806

Open
MaggieCabrera opened this issue Aug 18, 2023 · 6 comments
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended

Comments

@MaggieCabrera
Copy link
Contributor

Description

If you build a theme using reusable blocks and then export the theme (both using the core functionality or Create Block theme plugin) the template exported will have the synced patterns as <!-- wp:block {"ref":62} /--> which will not work if you try to run the theme on a different environment. We should fix this, even if it's just resolving those refs into the referenced markup of the pattern upon exporting.

Step-by-step reproduction instructions

Create a synced pattern on one of the theme's templates.
Export the theme
Try installing that theme on a different environment, you will see what's on the screenshot below

Screenshots, screen recording, code snippet

Screenshot 2023-08-18 at 11 20 33

Environment info

No response

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

@MaggieCabrera MaggieCabrera added the [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) label Aug 18, 2023
@Mamaduka
Copy link
Member

I can't find the issue right now, but the Navigation block has the same problem.

This is a general bug with any synced block using database IDs as ref.

@MaggieCabrera
Copy link
Contributor Author

I can't find the issue right now, but the Navigation block has the same problem.

This is a general bug with any synced block using database IDs as ref.

true, but for the nav block removing the ID from the block makes it fall back to a list of pages, and the ref is pointing to content. In the case of patterns, we are talking about markup, that is supposed to be part of the theme, not specific to the content of the user's site.

@Mamaduka
Copy link
Member

Thanks for clarifying, @MaggieCabrera!

@annezazu annezazu added the [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. label Aug 18, 2023
@annezazu
Copy link
Contributor

Heads up to @WordPress/block-themers!

@aaronrobertshaw aaronrobertshaw moved this to Todo in Patterns Aug 28, 2023
@jordesign jordesign added the [Type] Bug An existing feature does not function as intended label Aug 30, 2023
@annezazu annezazu changed the title Reusable blocks: exporting the theme breaks synced patterns Synced patterns/Reusable blocks: exporting the theme breaks synced patterns Aug 31, 2023
@talldan
Copy link
Contributor

talldan commented Jun 14, 2024

I think the solution for this (same as the navigation block) is for the pattern block to reference patterns using a slug instead of an id. It's discussed in the following two issues:

Though I think there would still be additional work to make sure the referenced synced patterns are exported as files.

@dballari
Copy link

I just took care of this in a plugin of mine, it could be incorporated into the import / export tool if necessary. One thing that it took me more than 10 years to realize is that the import / export tool tries to keep ids, and referential integrity is only lost when the id is already used by another item. I mentioned it in another issue: #62566 (comment)
my solution was to store in an option the ids that where modified (of both navigations and menus) and than perform search replace on the content. Look at lines from 389 to 545 of this file . But if the solution is referencing these objects by slug like suggested by @youknowriad then my fix is not needed. I will keep loving WordPress anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Todo
Development

No branches or pull requests

6 participants