Panelizer has a lot of node moderation code built in at this point. I'm not entirely sure this is necessary and after quite a bit of digging, I've found a few errors in the existing code. My efforts here are to make more seamless integration with Workbench_moderation simple a straight forward. Long term I'd like to see the existing moderation code in panelizer put into a sub-module that can be enabled per node type, but I've not attempted to do anything along those lines yet.
Within this code are 3 small changes, the first two are populating missing revision variables during various stages of panelizer's normal workflow. Panelizer expects these to be there and they aren't for various minor logic reasons. The 3rd change is a change to entity_save() on the PanelizerEntityNode class, which now checks to see if a.) workbench_moderation is enabled and b.) if this node bundle is moderated. If it is it then loads the current live node, does a node save against the passed revision, and then does a simple drupal_write_record against the live node revision to reset which node revision is referenced in the node table. This steps around workbench_moderation's nasty double node_save process, but still results in the same sort of workflow. This appears to be a perfect workbench_moderation process because I can draft/edit/customize/revert/etc node revisions and corresponding panelizer displays w/o any problems (or extra modules).
That being said, my revision id fixes look like they may have caused issues for the existing revision support in panelizer because new node revisions don't appear to be created by changing page content/layouts/panelizer anythings. I'll dig into this issue further, but I'd still like to seriously consider putting that code path into a submodule anyway.
Eclipse
Comment | File | Size | Author |
---|---|---|---|
#72 | panelizer-2457113-workbench-moderation-72.patch | 9.3 KB | muschpusch |
| |||
#69 | panelizer-n2457113-69.patch | 9.99 KB | japerry |
| |||
#43 | interdiff_33-43.txt | 2.41 KB | heddn |
#43 | panelizer-better_revision-2457113-43.patch | 8.04 KB | heddn |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc at Acquia commentedHere's my current patch.
Eclipse
Comment #2
EclipseGc CreditAttribution: EclipseGc at Acquia commentedAlso, for the record, I'm not thrilled with this workbench_moderation specific logic, but I've not yet come up with a better solution. I'll be looking to see if there's not a better way to tackle this as well in this issue.
Eclipse
Comment #3
EclipseGc CreditAttribution: EclipseGc at Acquia commentedOk, after sleeping on it for a bit and then looking again it became obvious that we were loading the entity revision we wanted to save during panelizer_panels_cache_save() instead of using the modified one in the $cache that tells us whether or not we should be generating a new revision. I've not checked, but if this works the way I think it works, then dev of panelizer is generating a new revision all the time and never used the log text. Both work appropriately now both inside and outside of workbench_moderation.
Vanilla behavior:
Updates the existing revision & revision time stamp.
Generates a new revision and adds a log message.
Workbench Moderation behavior:
Updates the current revision's display.
Generates new node revision in default workbench moderation state. (this has a tendency to generate multiple revision splits and make the current revision of the node very difficult to track, but it operates sanely under the circumstances, even if supporting this use case feels crazy.
Updates the current draft revision.
Generates a new revision split from the current draft at the same state.
Generates a new revision at the current state (I suspect this should revert back to the default state from a "purity" perspective for workbench_moderation).
All in all, I think this is a huge move in the right direction and fixes some bugs that were extraordinarily difficult to track down. I hope others will give this code a try and give us some feedback, but my initial tests are quite promising.
Eclipse
Comment #4
EclipseGc CreditAttribution: EclipseGc at Acquia commentedCheck values in the cache instead of wherever this entity came from.
Previously we updated the $form_state['entity'] but this was not passed back through the panelizer cache save process, so we couldn't check to see if a new revision should be created or not.
This could lead to situations where we didn't load the appropriate cache entity because there was never a subsequent ":" in $view_mode. Limiting this fixes that issue.
Instead of reloading the entity from scratch, we're pulling it out of the $cache object which is where our revision/log information resides.
I'm not super thrilled with this, but at least it properly generates new revisions and doesn't require workbench_moderation's double node_save() awful.
Comment #5
EclipseGc CreditAttribution: EclipseGc at Acquia commentedComment #6
EclipseGc CreditAttribution: EclipseGc at Acquia commentedAlso worth mentioning, reverting seems to work flawlessly in both workbench_moderation and vanilla situations.
Eclipse
Comment #7
DamienMcKennaComment #8
EclipseGc CreditAttribution: EclipseGc at Acquia commentedOk, I think I'm pretty happy with this. The latest version of this patch adds a new node option for leveraging revisions during panelizer workflows so that the revision handling panelizer supports can be turned on or off as necessary. This included adding a form validation step for the form which I followed what was already in place for form submission, so should be pretty straight forward. Need to get some eyes on this patch and see how it's working for other people, we will also need an update hook to auto-enable this new node option since that's the default for how panelizer is working right now.
Behavior Profile:
Node types without revisioning:
This will only ever have one display per nid.
Node types with revisioning but no panelizer revisioning:
If a new node revision is create somehow (say via workbench_moderation or similar) we should end up with a clone display that can be manipulated per revision.
Node types with panelizer revisioning:
A new revision can be spawned for every atomic panelizer interaction (if the user doing the work wishes it so) or at just each major stage. This happens the same way it does in HEAD and is very granular in how it can be applied.
Eclipse
Comment #9
EclipseGc CreditAttribution: EclipseGc at Acquia commentedHere the interdiff
Comment #10
EclipseGc CreditAttribution: EclipseGc at Acquia commentedOk, and here's the update hook to keep it all sane.
Eclipse
Comment #12
EclipseGc CreditAttribution: EclipseGc at Acquia commentedreroll
Comment #13
EclipseGc CreditAttribution: EclipseGc at Acquia commentedComment #14
dawehnerWhy don't you just subclass in workbench module itself + probably some plugin alter?
Comment #15
EclipseGc CreditAttribution: EclipseGc at Acquia commentedLast I looked there aren't plugin alters, and as best as I know, I can't do a handler per entity bundle, otherwise I'd have done EXACTLY that. :-D Open to other ideas though.
Eclipse
Comment #16
DamienMcKennaCould you please split off the smaller fixes from the grand tamale? I think you might be resolving some other issues as part of it.
Comment #17
EclipseGc CreditAttribution: EclipseGc at Acquia commentedWhich fixes? Let me know and I can either justify or split as appropriate.
This patch contains a fix for how I was saving node entities previously as my old process could lead to nodes displaying with field values from new revisions. This new code is simpler and follows workbench_moderation's expected workflow which means a new revision for every panelizer save. This is the same thing wbm does for node edits, and keeps us in line with it's expected workflow. This means new revisions (and thus new displays) every time you save the customize page or layout stuff.
I also spent some time testing without IPE turned on, and due to how workbench_moderation tracks node drafts, it's impossible to customize draft pages without IPE.
Eclipse
Comment #18
EclipseGc CreditAttribution: EclipseGc at Acquia commentedFailed to check that we weren't attempting to edit the current live vid before creating a new one. Simple fix.
Eclipse
Comment #19
saltednutAs of #17 (and also in #18), when editing via IPE, I am seeing one problem where I get a warning before leaving the page. Might have to do with leaving behind an abandoned layout when a new revision for every panelizer save is created.
Everything works correctly - its just an annoyance. The warning is not actually true, I don't lose unsaved changes if I click "leave this page" -- is there something we need to update in javascript to prevent this confusion?
Comment #20
DamienMcKenna@brantwynn: Check the patch in #1402860: Panelizer is incompatible with moderation to see if it resolves that issue, if so it's a bug in Panels.
Comment #21
DamienMcKennaComment #22
saltednut@DamienMcKenna The patch from #1402860-82: Panelizer is incompatible with moderation (which applies to Panels) does not resolve the IPE alert problem that #17 introduced.Sorry, I had not tested correctly against the latest version of Panels. The patch does seem to work alongside #17 to get rid of the popup.
Comment #23
EclipseGc CreditAttribution: EclipseGc at Acquia commentedMoving this back to needs review since #1402860: Panelizer is incompatible with moderation does solve it and is a separate issue from this. Adding another related issues that need to be gotten into panels.
Eclipse
Comment #26
saltednutRerolled to fix the .install file.
Comment #27
gremy CreditAttribution: gremy commented@eclipsegc The patch from https://www.drupal.org/node/1402860 does not fix the problem. I just applied it and it does not work for me.
I am still seeing the information of the published node in the "View Draft" tab.
I am using the latest version of panopoly, which is using panelizer 7.x-3.1.
I tried upgrading panelizer to it's latest dev version, and then applying the patch from this issue, and the problem still persists.
Comment #28
DamienMcKennaRerolled as one minor bug was fixed in #2408691: Undefined offset in panelizer_panels_cache_get() in IPE, and "Invalid pane id" when revision is enabled.
Comment #29
DamienMcKennaComment #30
DamienMcKennaI'm... not completely comfortable with changing the way Panelizer works with core's revision handling... I wonder if all of the changes will be necessary given some of the changes going on in WM? I'm going to hold off on the WM side of things but will continue to work on this from the POV of resolving revisions problems with & without IPE.
Comment #31
DamienMcKennaComment #32
reescott CreditAttribution: reescott commentedThis patch didn't seems to be applying correctly.
Comment #33
reescott CreditAttribution: reescott commented@DamienMcKenna Rerolled #28 against latest dev version and also fixed an error on line 150 that mistakenly disabled the "Create New Revision" checkbox on content type Publishing Options tab, making it difficult to enable revisions and moderation for using Workbench Moderation.
Comment #34
DamienMcKennaI'm considering pushing out 3.2 Really Soon with this as-is and then doing a quick turn-around on 3.3 that focuses exclusively on revisions. The first thing to do towards that goal is document what works and what doesn't, which will go into #2151837: Update README.txt file.
Comment #35
DamienMcKennaComment #36
dsnopek@DamienMcKenna: I'd be all for a quick 3.2 with what's there now! Last time we ran the latest Panelizer -dev through Panopoly's automated tests it worked great.
Comment #37
joelstein CreditAttribution: joelstein commentedJust a quick note about the content type form.
The patch in #33 prevents me from selecting "Create new revision". Both it and "Enable panelizer revisions" are disabled without any way to select one or the other. Note: I'm not using Workbench Moderation... just Drupal's built-in revisions.
The patch in #28 does allow me to check "Create new revision", FYI.
Comment #38
saltednutI believe this was the intent of @eclipsegc because of the nature of how the IPE would interact with Workbench.
The main idea is that you shouldn't be able to use the IPE unless you are already working on a draft.
Otherwise, you'd be making changes to the published layout.
It is implied that new drafts will be made going forward as long as one works on drafts (even when making changes to the layout in the IPE).
So, that is why this patch disables the functionality that it does in #33.
We do use this patch in the Lightning Features package provided for both Demo Framework and Lightning distros.
Comment #39
joelstein CreditAttribution: joelstein commentedMakes sense, however since the title of the issue is to get revision handling "inside and outside of Workbench Moderation", I think the patch should accomplish both.
It won't make sense to commit something that breaks Panelizer revision handling for sites without Workbench Moderation. :)
Comment #40
saltednutYes, that's totally valid ^ - hence my disclosure! :)
It might make sense to add an if statement here where we check for WBM using
module_exists()
before disabling those checkboxes.Comment #41
MustangGB CreditAttribution: MustangGB commentedIs this being pushed back to 3.3 now, so 3.2 can get out the door?
Comment #42
heddnre #37/#40, Based on these points, I think this should be wrapped by a module_exists.
Comment #43
heddnComment #45
heddnComment #46
heddnMissing the default options value for new site installs that didn't go through an upgrade.
Comment #47
heddnComment #48
japerryRe-rolled based on all the changes from sept 8th and 9th.
Comment #49
RobLoachThis seems like quite the substantial change. Relying on the form's display state to hold the entity data looks like a monumental change in how entity information is saved.
If Workbench Moderation is not enabled, is revision information still maintained? Why does Panelizer modify the handling of revisions? This functionality seems way out of scope for Panelizer.
Should this change live in Workbench Moderation rather than Panelizer?
Comment #50
gremy CreditAttribution: gremy commentedI just tried it in Panopoly with the latest panelizer dev version and applied the panelizer-better_revision-2457113-48.patch patch, and if I create a new Draft revision, and press "View Draft" I still see the content of the Published revision, with the pink styling of the unpublished.
Comment #51
DamienMcKennaWe need some tests to lock down a) how core works, b) how IPE works and c) how WM works, and also confirm that we're working with WM with Drafty (#2376839: Rewrite to use the new Drafty module).
And yes, we'll be working on expanding Panelizer's base test suite.
Comment #52
DamienMcKennaNew issues for writing tests: #2579447: Write tests to cover the standard node workflows, including core revisions, excluding IPE, #2579449: Write tests to cover the standard term workflows, excluding IPE. #2579451: Write tests to cover the standard user workflows, excluding IPE, #2579453: Write tests to cover IPE usage on nodes, inc core revisions
The absolute priority is ensuring that core's workflows are not broken by other modules, and only then will we fix Workbench Moderation support.
Comment #53
DamienMcKennaAnyone who wants to help move this forward should collaborate on #2579447: Write tests to cover the standard node workflows, including core revisions, excluding IPE first. Thanks.
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedAny update here? I see the linked issue is fixed now.
Comment #55
DamienMcKenna@vilepickle: I'm currently working on tests for the node handling and core revisioning, once I have that tied down more I'll be able to look at WM.
Comment #56
DamienMcKennaI've added several tests recently around the editorial workflow, lets see what we can do for this.
Lets start with a reroll.
Comment #57
DamienMcKennaPS anyone want to help with the new release, please help write tests for this and the other issues marked as being part of the 3.2 release. Thanks!
Comment #58
DamienMcKennaMinor changes to comments.
Comment #59
DamienMcKennaA minor tweak to the logic, it only allows revisions to be disabled if Workbench Moderation is enabled.
Comment #60
DamienMcKennaThere's a minor regression - if the "Enable moderation of revisions" option is enabled the "node/$nid/panelizer/$view_mode/content" path no longer shows the second-level local tasks (Settings, Context, Layout, Content) though the paths still work and they still show on the Overview page.
Comment #61
DamienMcKennaA bug against the new intended workflow:
Comment #62
DamienMcKennaI think that, in general, a little more work needs to be done with the UX here. It's unclear why some links & pages are no longer accessible but others are, the UX doesn't make it clear what the intended workflow is and doesn't hide pages that should no longer be part of the workflow.
So this definitely needs more work.
Comment #63
DamienMcKennaPulling this for the 3.2 release plan, will come back to it afterwards.
Comment #64
drummAttached is a quick reroll.
Comment #65
drummI don't really understand the added update function:
I read the code as doing the opposite of what the comment says, if panelizer isn't in the options array, it is added.
Comment #66
DamienMcKenna@drumm: yes. The idea is that if the variable doesn't exist already it'll load the default, which will include the new 'panelizer' option, but if the variable was set before it'll enable the 'panelizer' option.
Comment #67
drummI see this looks okay now. I initially thought that was for panelizing the content type, but it really means “Enable Panelizer revisions”
This patch updates the comment to
Only set the variable if it was*n’t* previously configured.
Comment #68
japerryNote, if you applied patch #65 or #67, you must go back into your system table and revert your update status to 7301 before installing Panelizer 7.x-3.3.
Here is a re-roll that works with the Security release.
Comment #69
japerryoops. in the re-roll missed some syntax. trying again.
Comment #71
DamienMcKennaNow that Workbench Moderation v3 is out with some rewritten internals, this needs to be updated to make sure it still works.
Comment #72
muschpusch CreditAttribution: muschpusch at Factorial GmbH commentedUpdated patch with updated panelizer_install_N functions.
Comment #73
cboyden CreditAttribution: cboyden commentedI've tested this patch with the following recipes, and it's working as expected. Probably needs more review though. Setting to needs review for testbot.
Comment #74
cboyden CreditAttribution: cboyden commentedWe've been using this for quite a while now and it's working as expected.
Comment #75
DamienMcKennaThat's fantastic, thanks for the update cboyden!
Comment #77
DamienMcKennaCommitted. Finally. Thank you all!