backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Switching the node_admin_theme option should flush the layout cache but doesn't

Open indigoxela opened this issue 1 year ago • 10 comments

Description of the bug

It's a rather subtle problem, as the default admin theme and the default theme aren't that different. But it's visible. Even more if the layouts do differ significantly.

Steps To Reproduce

  1. Switch the setting "Use the administration theme when editing or creating content" off and save on admin/appearance
  2. Open a node form, like node/add/post
  3. Inspect the current layout via admin bar dropdown "This page"
  4. Switch the setting "Use the administration theme when editing or creating content" back on and save (do not flush caches manually)
  5. Open a node form
  6. Inspect the current layout via admin bar

Actual behavior

When the default theme is selected for node edit/create, the Default Layout should be in use. When the admin theme is selected, the Default Administrative Layout should be used. But switching doesn't change that, so the wrong Layout is used, until one flushes caches.

This leads to visual glitches. I've seen this before, but didn't actually realize the source of the glitch.

wrong-layout

^^ That's a harmless example, it can look a lot weirder, depending on layout adaptions (blocks).

Expected behavior

The right layout after switching.

Additional information

  • Backdrop CMS version: latest dev, not sure when this problem started

indigoxela avatar Jan 18 '24 14:01 indigoxela

A PR is available for testing and review.

I tried to narrow the flush down to specific items, but all the node/add/NODETYPE have their own entry, and that's potentially a lot. Flushing is easier.

indigoxela avatar Jan 18 '24 14:01 indigoxela

I spun up a fresh site at backdropcms.org and tried the steps you describe and cannot replicate the problem you describe.

izmeez avatar Jan 23 '24 18:01 izmeez

The tugboat demo is BD 1.26.2

izmeez avatar Jan 23 '24 18:01 izmeez

I spun up a fresh site at backdropcms.org and tried the steps you describe and cannot replicate the problem you describe.

It's essential to follow the exact steps, in order to put the old value into the cache_layout_path table. That cached, but outdated value will then be used to apply the layout to node/add/THETYPE - the wrong layout.

The visual glitch can be subtle, but with the "This page" dropdown you can verify that the wrong layout's in use.

indigoxela avatar Jan 24 '24 05:01 indigoxela

Tested and reviews. RTBC

argiepiano avatar Jan 24 '24 13:01 argiepiano

I think the PR diff makes good sense.

izmeez avatar Jan 25 '24 02:01 izmeez

@indigoxela I made a suggestion in the PR to use Layout module's dedicated cache clear function, in the event that other caches are in place (or are in the future). The admin theme setting is so tightly tied to the default admin layout that I think this is a reasonable thing to do.

quicksketch avatar Mar 13 '24 18:03 quicksketch

I made a suggestion in the PR to use Layout module's dedicated cache clear function

Merging wasn't such a good idea... :laughing: Syntax error. There was a semicolon missing in your commit. I'll fix it, and rebase.

indigoxela avatar Mar 14 '24 05:03 indigoxela

Done, merged-fixed-rebased. Do we need another round of testing? Or is it still RTBC?

indigoxela avatar Mar 14 '24 06:03 indigoxela

There was a semicolon missing in your commit. I'll fix it, and rebase.

That's why we have testing :joy: Thanks for fixing that. With the parent function doing the exact same thing as before (plus additional cache clearing) this looks good to me. I'll get it on my next pass through RTBC issues.

quicksketch avatar Mar 14 '24 07:03 quicksketch

Thanks @indigoxela, @izmeez, and @argiepiano! I merged https://github.com/backdrop/backdrop/pull/4639 into 1.x and 1.27.x.

quicksketch avatar Apr 28 '24 20:04 quicksketch