Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Scenario:
- In a specific entity bundle, e.g. content type, enable several display modes to be Panelized and select "enable default panel" for each one.
- Create content in the content type, verify that records are created in {panelizer_entity} for each view mode.
- Edit the entity bundle (content type) again, and disable Panelizer on one of the view modes - only uncheck the main checkbox, don't uncheck the other ones.
- Edit the node created above and re-save it.
- Verify that the record in {panelizer_entity} for the deleted view mode still exists.
Comment | File | Size | Author |
---|---|---|---|
#15 | panelizer-n2192863-15.patch | 999 bytes | DamienMcKenna |
#4 | skip-load-disabled-view-modes-2192863-4.patch | 806 bytes | niko- |
#2 | Screenshot from 2014-10-10 22:34:20.png | 84.73 KB | mglaman |
Comments
Comment #1
DamienMcKennaClarified the issue.
Comment #2
mglamanConfirmed. Tested through saves and revisions.
It is still created panelizer_entity rows for the disabled view mode and not pruning existing entries (of same revision ID, at least.)
Screenshot via phpMyAdmin. I disabled the content type after saving revision ID 2, revision ID 3 should not have the entry created.
This is the issue - correct? It keeps saving even though it shouldn't. Or should it also wipe out existing entries for that view mode if disabled? I'll give a patch a shot, but want to clarify end goal.
Comment #3
DamienMcKennaThat's... a good question. Hrmmm..
Comment #4
niko- CreditAttribution: niko- commentedMy debug shows following:
Panelizer loads all view modes for given entity and ignore view mode status flag.
We need load only enabled view modes.
Also this bug leads to the fact that all enabled view modes will be overridden with disabled one.
Patch for skiping disabled view modes attached.
Comment #5
niko- CreditAttribution: niko- commentedneed review
Comment #6
podarokThis check looks weird. Are we confident about all keys are available?
trailing whitespaces
Comment #7
mrjmd CreditAttribution: mrjmd commentedThe patch in #4 solved the immediate problem, but created others. It wasn't running an isset which was throwing errors (image attached).
I've cleaned it up and added an isset check.
Comment #8
mrjmd CreditAttribution: mrjmd commentedOoops, that wasn't quite right either. Here we go.
Comment #9
mglamanStupid nitpick. But couldn't $check_needed just equal array_key_exists() instead of having to decide true/false.
Not like it really changes what's done here, just a thought :D
Comment #10
mrjmd CreditAttribution: mrjmd commentedEasy fix, I like easy fixes. It's attached.
Regarding your question above in #2, I don't see why disabling a view mode should delete previous entries. So I'd say that this is all that's required here, but we'll see what Damien has to say.
Comment #11
mglamanAwesome!
As for my question in #2, I more so wasn't sure. In my opinion your patch is right approach, and adding something to go back and delete previous entries could lead to problems.
If there's issues that crop up from "But I disabled, and when I came back I had unexpected results!" then let it be at that time :) I think it's a small use case, but wanted to bring it up anyways.
Comment #12
niko- CreditAttribution: niko- commentedOne more thing
$bundle may be undefined we must use $bundles[$entity_id] instead.
Patch attached.
Comment #13
mglamanSlick catch. Line 1128 uses $bundles array. Hoping to have time to test this today and RTBC - instead of being that guy just making comments.
Comment #14
mglamanThis $check_needed is actually checking whether the view mode is customized through Field UI.
Example: I enabled Full Content, Teaser, Search Index from "Manage Display." RSS isn't visible on Panelizer config, and $check_needed is false.
The view mode array is status, default, and choice. These, when debugging, were 0 or 1, not boolean, so nothing actually got caught here.
Also did some simple benchmarking using Devel's timers. Standard Drupal install, Core toolbar, just ran "drush en panelizer -y".
Comment #15
DamienMcKennaI separated out the second variable check, to make the code more readable.
Comment #16
DamienMcKennaCommitted. Thank you all.