Problem/Motivation

When using preview in combination with creating a new node the $entity->in_preview property set in the prepareEntity method of PreviewHandler persists when saving the node and can throw off any custom conditional logic that depends on it.

Steps to reproduce

Prerequisite: add a debug print or use xdebug to inspect the entity in e.g. your Elasticearch normalizer.

  • Fill out a node form that's configured for previewing
  • Use preview - the debug print indicates that $entity->in_preview == TRUE as expected
  • Save the node - the debug print still indicates that we're in preview mode

Proposed resolution

Change $entity->in_preview to $entity->_in_preview so it's transient and doesn't persist through serialization.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

artis.bajars created an issue. See original summary.

artis.bajars’s picture

Status: Active » Needs review