Problem/Motivation

Serializing objects throws exceptions as we end up serializing things that shouldn't be (e.g. contain drupal settings or services). The specific classes with problems are:

  • \Drupal\page_manager\Entity\Page
  • \Drupal\page_manager\Entity\PageVariant
  • \Drupal\page_manager\Plugin\DisplayVariant\PageBlockDisplayVariant (possibly should be fixed upstream in CTools)

Proposed resolution

Most of this should be solved upstream by traits etc, but we need to deal with ::$context ourselves. We currently have some code that has already been fixed upstream (#2650588: Entities with plugin collections should be updated before serialization), so could also be removed now.

API changes

Changes to ::__sleep for the problem classes.

Postponed on:

Comments

andrewbelcher created an issue. See original summary.

andrewbelcher’s picture

Assigned: andrewbelcher » Unassigned
Status: Active » Needs review
StatusFileSize
new7.17 KB
new9.82 KB

So here are some patches, one just the test and one with the fix as well.

I have added:

dependencies:
  - system (>8.0.4)

As #2650588: Entities with plugin collections should be updated before serialization was released in 8.0.4. Is this still the right way TM to depend on a minimum version of core?

The addition of \Drupal\page_manager\Plugin\DisplayVariant\PageBlockDisplayVariant::__sleep could arguable by better in \Drupal\ctools\Plugin\DisplayVariant\BlockDisplayVariant as that includes the trait that introduces the context... Very happy to update the patch to remove that and create a CTools issue, though we'll either be blocked on that or have to put it in here with an @todo to remove it...

The last submitted patch, 2: unable_to_serialize-2696283-2-test_only.patch, failed testing.

andrewbelcher’s picture

Issue summary: View changes
Status: Needs review » Postponed

Postponing this on a couple other issues - have updated the issue summary and will get the patch that applies on top of those two uploaded soon.

andrewbelcher’s picture

StatusFileSize
new9.14 KB
new11.79 KB

Here's some updated patches that apply on top of the current patches in #2692325: Add description to Page/#2690047: Allow setting the Page on a PageVariant.

I have also fixed a bug in the testHttpStatusCodeVariantPlugin where I was creating the wrong plugin type and I've expanded the tests to actually check the post-serialization values are as expected.

andrewbelcher’s picture

StatusFileSize
new9.14 KB
new11.79 KB

Re-uploaded so they can be tested when this is unpostponed.

andrewbelcher’s picture

Status: Postponed » Needs review

Ok, those other issues are committed now.

The last submitted patch, 6: unable_to_serialize-2696283-6-test_only.patch, failed testing.

andrewbelcher’s picture

Assigned: Unassigned » andrewbelcher
Category: Task » Bug report
Priority: Major » Critical
Status: Needs review » Needs work
Issue tags: -pm-ui-blocker
Parent issue: #2550879: Use CTools Wizard API to add/edit Pages (and move plugin UI using PluginWizardInterface) »

This got partially committed as part of #2550879: Use CTools Wizard API to add/edit Pages (and move plugin UI using PluginWizardInterface). Unfortunately, it looks like the solution currently here (which was committed) is actually insufficient and could introduce rather than solve problems.

Specifically, dependency on core are no semver compatible (#2641658: Module version dependency in .info.yml is ineffective for patch releases). It looks like it ends up completely , so HEAD of page_manager will currently pass dependency validation on >=8.0. This means that anyone who is on anything after e.g. 8.0.1 will not get a any notice that they are on an incompatible core version.

Since the changes here defer some of the serialization work to \Drupal\Core\Config\Entity\ConfigEntityBase::__sleep that was released in 8.0.4 that will cause exceptions on earlier version.

Also, the version committed has >8.0.4 rather than >=8.0.4 and an @fixme was committed referring to this issue.

I'll work on a patch that will:

  1. Get the dependency in page_manager.info.yml
  2. Remove the @fixme
  3. Add a hook_requirements() check that will check the core version
andrewbelcher’s picture

Status: Needs work » Needs review
StatusFileSize
new9.14 KB
new11.77 KB

Ok - here is a patch to fix things.

andrewbelcher’s picture

Unfortunately can't get the test bot to test against an old release of core :( So that will just pass...

The last submitted patch, 10: unable_to_serialize-2696283-10-test_only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: unable_to_serialize-2696283-10.patch, failed testing.

andrewbelcher’s picture

StatusFileSize
new9.7 KB
new12.34 KB

Ok, so 3 things I've found:

- That fix was actually in 8.0.5 (8.0.4 was security only)
- Drupal\page_manager\Event\PageManagerEvents::PAGE_CONTEXT requires the router, so I'm manually adding context to avoid that. Not 100% sure what has changed to make that now an issue...
- Drupal\page_manager\Entity\PageVariant::getVariantPluginCollection now sets the uuid if it doesn't exist, so I've cleared that out of the unserialized config for the assert as that is a legitimate change.

I've not bothered testing the test only patch as it will pass as we can't test prior to 8.0.5 on DrupalCI.

andrewbelcher’s picture

Status: Needs work » Needs review
andrewbelcher’s picture

StatusFileSize
new12.04 KB
new964 bytes

Just had a hangout with @EclipseGc. One of the changes I made to do with the UUID is actually going to be fixed upstream in CTools (preserving the UUID), so I've reverted that bit of the test. It will fail tests until CTools is updated. This does mean we may need a minimum version of CTools, which I've not included...

Status: Needs review » Needs work

The last submitted patch, 16: unable_to_serialize-2696283-16.patch, failed testing.

eclipsegc’s picture

Status: Needs work » Fixed

After updating and releasing a new ctools alpha this test all passes and looks great. Fixed.

Eclipse

andrewbelcher’s picture

Do we not need to version our dependency on CTools?

eclipsegc’s picture

We could, but given these are all alphas, it's pretty reasonable to expect that you should have the latest. We've had these sorts of interdependencies everywhere for many many years in this ecosystem. If we were to do it, it just means we'll be constantly updating that one line and that strikes me as odd.

Eclipse

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.