Lightning uses this patch. Without it, Lightning's Panelizer and Panels IPE integration pretty much falls apart. But that patch will never be committed to Panels, because it is a dirty hack and it was never meant to be permanent anyway. We need a proper, permanent solution to the problem addressed by the patch, which is that Panelizer cannot influence the tempstore ID used by Panels IPE.

This new patch fixes that by introducing a new TempStoreTrait to IPE, which allows modules to change the tempstore ID via a hook.

Comments

phenaproxima created an issue. See original summary.

samuel.mortenson’s picture

Status: Needs review » Needs work

Awesome! I hope this gives Panelizer what it needs to reduce its TempStore issues and complexity.

My only review after a first pass is that we'll need API docs for this, so panels_ipe.api.php will need an update.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

Added hook documentation.

phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

StatusFileSize
new11.23 KB
new1.02 KB

I just realized I totally didn't even post a damn patch in #3.

Status: Needs review » Needs work

The last submitted patch, 5: 2793801-5.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new11.5 KB
new1.42 KB

Apparently PHP frowns on property collisions in traits. Who knew? (Answer: everyone but me.)

Status: Needs review » Needs work

The last submitted patch, 7: 2793801-7.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new13.2 KB
new1.58 KB

Finally, getting somewhere!

dsnopek’s picture

Status: Needs review » Needs work

Some quick review:

  1. +++ b/panels_ipe/panels_ipe.api.php
    @@ -26,3 +26,22 @@ function hook_panels_ipe_panels_display_presave(PanelsDisplayVariant $panels_dis
    +  if ($panels_display->getBuilder()->getPluginId() == 'panelizer') {
    +    $id = 'panelizer';
    +  }
    

    This example is totally contrived. Since we're dealing with the IPE, the builder plugin will always be 'ipe' :-)

    It isn't super important, because this is an example that won't actually run, but it'd be nice to something more realistic

  2. +++ b/panels_ipe/src/TempStoreTrait.php
    @@ -0,0 +1,51 @@
    +trait TempStoreTrait {
    

    I'm not crazy about this being a trait. By using a trait, we're copying a method to multiple places, rather than calling the same method in multiple places. If something else (outside of IPE) wants to get the right tempstore id, then the API is using the trait on one of it's classes, which isn't ideal.

    I think there should probably be some service that has this method lives on which is called from everywhere than needs to get the tempstore id.

damienmckenna’s picture

Anyone have feedback on dsnopek's feedback in #10?

samuel.mortenson’s picture

I've given feedback in #2793841: Properly integrate with Panels IPE as well, which would need to be addressed to validate that this hook is necessary. Long story short, Panelizer shouldn't have to implement a hook to alter the TempStore ID if Panelizer is originally setting the TempStore ID. Altering data that you set doesn't make sense to me.

japerry’s picture

StatusFileSize
new13.88 KB

Reroll of #9 for the pending Beta6 release.

damienmckenna’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

RTBC given it's already in Lightning.

samuel.mortenson’s picture

The only issue that relies on this functionality, #2793841: Properly integrate with Panels IPE, has unaddressed feedback from myself and @dsopek from over six months ago.

samuel.mortenson’s picture

StatusFileSize
new13.23 KB
new1.75 KB
new1.8 KB

My team ran into a problem where the entity context would get lost later in the request, and found that the only fix was to cache the modified temp store ID after the first change. This is a fairly simple caching change that shouldn't affect current users, but I'd like to get other eyes/testers on it. I've attached "panels-cache-tempstore-id.patch", which you should be able to apply directly over your existing patched Panels installation (if already using the last patch in your build).

The last submitted patch, 17: 2793801-17.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 17: panels-cache-tempstore-id.patch, failed testing.

samuel.mortenson’s picture

Status: Needs work » Reviewed & tested by the community

I'm guessing my use of drupal_static() broke unit tests. I'll move this back to RTBC and hide the patches from #17, don't want to hold up the issue. I'll file a follow up when this is committed.

profak’s picture

Hi, is this going to be merged?
Just tested with custom module, hook works. Tempstore ID can be altered.

+1 for @dsnopek comment about trait.

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new13.12 KB

Rerolled for 8.x-4.x.

phenaproxima’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev

Ah, forgot to change the ol' branch.

Status: Needs review » Needs work

The last submitted patch, 22: 2793801-22.patch, failed testing.

stephaneq’s picture

Status: Needs work » Needs review
StatusFileSize
new12.62 KB

Created a new patch, there was a syntax error in the previous one.

Status: Needs review » Needs work

The last submitted patch, 25: 2793801-24.patch, failed testing.

stephaneq’s picture

StatusFileSize
new13.28 KB

And another one, a "use" statement for the new trait was missing.

samuel.mortenson’s picture

This patch is no longer needed when using using the 8.x-4.x branches of Panels and Panelizer, and the Lightning distribution no longer patches those modules. How are current users using the patches from this issue? What issues does it solve in 8.x-4.x? We'll probably want to re-write the issue summary if the hook is still useful.

Mirroar’s picture

Status: Needs work » Needs review
Related issues: +#2778565: Multilingual support for Panelizer

Marked as "Needs Review" to test the patch from #27.

The patch is still required for panelizer on multilingual sites - #2778565: Multilingual support for Panelizer. Otherwise, temporary changes made on one language of an entity are shown on all languages without overrides.

Mirroar’s picture

StatusFileSize
new14.12 KB

Here's a straight reroll of #27 against panels 8.x-4.4

Ruedische’s picture

I've attached a patch, which applies against panels 8.x- 4.6 (without test).

Ruedische’s picture

StatusFileSize
new12.75 KB

Status: Needs review » Needs work

The last submitted patch, 32: panels-ipe_tempstore_id-2793801-32.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joelpittet’s picture

Status: Needs work » Closed (outdated)

No response to #28
I'm closing this as not needed.