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

gutenberg_render_block_core_template_part should validate postId attribute as ID for a wp_template_part post #26734

Open
bobbingwide opened this issue Nov 5, 2020 · 5 comments
Labels
[Block] Template Part Affects the Template Parts Block [Type] Bug An existing feature does not function as intended

Comments

@bobbingwide
Copy link
Contributor

Describe the bug
When I first started developing my experimental FSE theme called Fizzie I used export as CSV from the original site, updated the template parts, then tried to use them directly in another site.

I discovered that the postId attribute was not being fully validated.
This led to a lot of confusion until I determined that the posts being loaded were not template parts at all.

I realised that, so long as get_post_status() returns a non null value any content could be loaded.

To reproduce
Steps to reproduce the behavior:

  1. Manually edit the postId attribute on a wp:template-part block to be a valid post ID.
  2. View content that loads the template part.
  3. See the content from the referenced post, which was not a template part.

Expected behavior
The post that's found using the postId attribute should only be used if the post_type of the post is wp_template_part.
The status should also be checked to be published.
Any other status should not be allowed.

Screenshots
See bobbingwide/fizzie#1 (comment)

Editor version (please complete the following information):

  • WordPress version: [e.g: 5.3.2] 5.6-beta3
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? [e.g: "gutenberg plugin", "default"] 9.3.0 and Gutenberg source

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] Version 86.0.4240.111 (Official Build) (64-bit)

Additional context

@bobbingwide
Copy link
Contributor Author

Note: I have prototyped a fix for this in a local workaround to this and a few other problems.
See bobbingwide/fizzie#18 (comment)

@youknowriad
Copy link
Contributor

@bobbingwide did you consider opening Pull Requests for some of these fixes?

@bobbingwide
Copy link
Contributor Author

@youknowriad Yes I did. But my particular need for them to be fixed in Gutenberg right now has reduced as I have implemented local workarounds. I'm not good at creating PRs. I will try but I used to have problems with formatting pre-checks.

@youknowriad
Copy link
Contributor

@bobbingwide Let me know if you need help with anything including checks.

@bobbingwide
Copy link
Contributor Author

This problem has not been addressed in Gutenberg 10.2.0. It still only checks the post_status and not the post type of the post found using the post ID.
See #26734.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants