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

Revert "Full Site Editing Framework: Fix template resolution priorities." #27322

Closed
wants to merge 6 commits into from

Conversation

aristath
Copy link
Member

@aristath aristath commented Nov 27, 2020

#27303 caused some tests to fail.
This PR reverts the changes. If merged then we should reopen #27177 and find a better solution

@youknowriad
Copy link
Contributor

Do you why the test failed? Is the logic wrong?

@aristath
Copy link
Member Author

Do you why the test failed? Is the logic wrong?

I have no idea why the test fails...
I just made this as a draft to check if the code in this PR is indeed the culprit for the failing tests @talldan mentioned in #27303 (comment)
The logic seems correct and I can't see how that code would cause the Multi-entity editor states › Multi-entity edit › should only dirty the child when editing the child error.
I'm trying to debug it, but if you have any ideas or insights I welcome your input!

@github-actions
Copy link

github-actions bot commented Nov 27, 2020

Size Change: -10 B (0%)

Total Size: 1.2 MB

Filename Size Change
build/block-library/editor-rtl.css 8.95 kB -7 B (0%)
build/block-library/editor.css 8.95 kB -8 B (0%)
build/block-library/style-rtl.css 8.27 kB +3 B (0%)
build/block-library/style.css 8.27 kB +2 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.8 kB 0 B
build/api-fetch/index.js 3.42 kB 0 B
build/autop/index.js 2.84 kB 0 B
build/blob/index.js 664 B 0 B
build/block-directory/index.js 8.72 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/index.js 134 kB 0 B
build/block-editor/style-rtl.css 11.3 kB 0 B
build/block-editor/style.css 11.3 kB 0 B
build/block-library/index.js 148 kB 0 B
build/block-library/theme-rtl.css 789 B 0 B
build/block-library/theme.css 790 B 0 B
build/block-serialization-default-parser/index.js 1.87 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/index.js 172 kB 0 B
build/components/style-rtl.css 15.3 kB 0 B
build/components/style.css 15.3 kB 0 B
build/compose/index.js 9.95 kB 0 B
build/core-data/index.js 14.8 kB 0 B
build/data-controls/index.js 828 B 0 B
build/data/index.js 8.8 kB 0 B
build/date/index.js 11.2 kB 0 B
build/deprecated/index.js 768 B 0 B
build/dom-ready/index.js 571 B 0 B
build/dom/index.js 4.95 kB 0 B
build/edit-navigation/index.js 11.1 kB 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.42 kB 0 B
build/edit-post/style.css 6.4 kB 0 B
build/edit-site/index.js 24 kB 0 B
build/edit-site/style-rtl.css 3.92 kB 0 B
build/edit-site/style.css 3.92 kB 0 B
build/edit-widgets/index.js 26.3 kB 0 B
build/edit-widgets/style-rtl.css 3.13 kB 0 B
build/edit-widgets/style.css 3.13 kB 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/index.js 43.3 kB 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.85 kB 0 B
build/element/index.js 4.62 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/index.js 6.87 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.27 kB 0 B
build/html-entities/index.js 623 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 698 B 0 B
build/keyboard-shortcuts/index.js 2.54 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.1 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.32 kB 0 B
build/notices/index.js 1.81 kB 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.43 kB 0 B
build/priority-queue/index.js 790 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/reusable-blocks/index.js 2.92 kB 0 B
build/rich-text/index.js 13.3 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.69 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@aristath
Copy link
Member Author

I tried different approaches and I can confirm that this PR is indeed the culprit, it causes the test to fail.
The surprising thing is that even deleting the post-status check (see test commit on dfe78fb) causes the tests to fail, though I am unsure how or why.

I think we should revert #27303 by merging this one, then reopen #27177 and figure out a better way to handle it.
cc @youknowriad

@youknowriad
Copy link
Contributor

so if I'm understanding properly. The fix is correct but the test fails and we don't really know why. It could suggest an issue in the test itself in which case maybe we'd prefer to keep the fix while disabling the test temporarily. (though both approaches are decent, we just need to follow-up).

I'm also pinging @noahtallen and @david-szabo97 as they worked on that particular test it seems.

@noahtallen
Copy link
Member

Taking a look at the test now

@noahtallen
Copy link
Member

The test is failing because when you create a custom template with the slug front-page, the test expects your custom template to be loaded. However, the current behavior is that the theme front-page template is loaded. (Interestingly, I had to fix the same bug couple weeks ago :P)

@noahtallen
Copy link
Member

I didn't fix the root bug, but I did fix the test here: #27347. The test shouldn't break by these bugs, since it makes the test seem unreliable. (The test is not trying to test template resolution anyways.) Entity editing always seems different from template resolution, so people tend to merge PRs which break the test without realizing it!

@youknowriad
Copy link
Contributor

, the test expects your custom template to be loaded. However, the current behavior is that the theme front-page template is loaded.

Why there is both a theme front-page template and a customized one, I thought once you customized a template, it just takes the theme one (auto-draft) and publish it?

@ntsekouras
Copy link
Contributor

I think the root problem lies in the fact that wp_templates can have the same slug. In the failing tests we create a template with the slug front-page and there is also an auto-draft from the theme with the same slug.

Then, when we query wp_templates in gutenberg_resolve_template it fetches two front-page wp_templates. So for example if in that query here:

'orderby' => 'post_name__in',

we add a second orderby param

'orderby'        => 'post_name__in modified',

it will make the tests pass.

I'm not sure if there is a reason for not having unique slugs, but it makes sense to me that we should.

@noahtallen
Copy link
Member

Here's how I'm thinking of it:

  1. My theme twentytwentyone-blocks can provide a front-page template (or maybe it won't)
  2. I can provide a front-page template for myself
  3. Any other theme could provide a front-page template once I switch to it

If number 2 exists, then we need to show your custom copy of the front-page template. Otherwise, we would show the theme one. And if none exists, we would fall back the template hierarchy.

I'm not exactly sure what makes most sense in terms of storing the template. But in my mind, there is a difference between "I've created a custom template for this slug myself" and "I've modified the template which the theme provides".

Why there is both a theme front-page template and a customized one

Nik is definitely right, and to expand further, for the broken e2e test, we basically just need any published template to test dirty states with. It just so happens that the test creates and publishes a custom front-page template and tests with that (at the time, I don't know if the FSE theme used for e2e tests provided a front-page template, so it may not have been a concern at the time the test was written).

I updated the test in #27347 to create an arbitrary template that should not cause any conflicts with whatever the theme is providing. IMO we can move forward with that to fix the broken test and continue to figure out how exactly templates should be stored and resolved in this situation! Again, the broken test isn't trying to cover any of the template resolution behavior, it just made a bad assumption about how template resolution would work in the way it sets up the test

@aristath
Copy link
Member Author

Thank you @noahtallen and @ntsekouras for debugging the tests!
Since this is apparently not an issue with the PR #27303 I'll go ahead and close this one which reverts it.

We should definitely figure out what to do with templates that have the same slugs though.
If the user creates a template with a slug front-page, then perhaps the auto-draft of the template should be deleted automatically?
But then again, the only way to create templates is from Appearance > Templates. That menu however will eventually be merged with the site-editor, and from that UI it will not be possible to create multiple templates for the same slug... So yes, we now have a bug there. But is it even worth fixing a bug for an implementation that will eventually become obsolete? 🤔

@aristath aristath closed this Nov 30, 2020
@aristath aristath deleted the revert-27303-fix/27177 branch November 30, 2020 06:29
@ntsekouras
Copy link
Contributor

That menu however will eventually be merged with the site-editor

But is it even worth fixing a bug for an implementation that will eventually become obsolete?

Probably not! @noahtallen 's change in tests to decouple template resolution and multi entities editing were great and we're now missing some tests for template resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants