Page Manager issue with conflict module

Created on 24 November 2019, over 5 years ago
Updated 14 April 2020, almost 5 years ago

Lightning in v4.0.5 has added integration with the conflict module and I am currently using page manager in a distribution and have run into an issue that seems to have an ultimate root cause in Panelizer.

The source of the issue was in conflict.module calling the getRouteObject.

function conflict_entity_load(array $entities, $entity_type_id) {
  // @todo decide whether this is the right place for storing a clone of the
  // loaded entity. Another possible place would be the form state for the main
  // entity and the field state for inline entities. The problem with the
  // current solution is that even entities loaded e.g. for a non inline entity
  // form widget will be cloned.
    $route =  \Drupal::routeMatch()->getRouteObject();
    // The route object will not be present if the entity is being loaded before
    // the routing has completed. This happens e.g. in
    // Drupal\Core\ParamConverter\EntityConverter::convert(), therefore we have
    // to check if the route object is not present that we are still in the
    // browser. This is not a perfect solution as there will be cases where we
    // will clone unnecessary the entity, but currently the most simple solution.
    if ((is_null($route) && (php_sapi_name() != 'cli')) || $route && ($route_defaults = $route->getDefaults()) && isset($route_defaults['_entity_form'])) {
      foreach ($entities as $entity) {
        if ($entity instanceof ContentEntityInterface) {
          $clone = clone $entity;
          $entity->{EntityConflictHandlerInterface::CONFLICT_ENTITY_ORIGINAL} = $clone;

          $serialized = serialize($clone);
          $hash = $entity_type_id . '_' . $entity->id() . sha1($serialized);
          $entity->{EntityConflictHandlerInterface::CONFLICT_ENTITY_ORIGINAL_HASH} = $hash;

          \Drupal::keyValueExpirable('conflict_original_entity')
            ->setWithExpireIfNotExists($hash, $serialized, 86400);
        }
      }
    }
}

Which was resulting in this error:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Symfony\Component\Routing\Exception\MissingMandatoryParametersException</em>: Some mandatory parameters are missing (&quot;user&quot;) to generate a URL for route &quot;&lt;current&gt;&quot;. in <em class="placeholder">Drupal\Core\Routing\UrlGenerator-&gt;doGenerate()</em> (line <em class="placeholder">182</em> of <em class="placeholder">core/lib/Drupal/Core/Routing/UrlGenerator.php</em>).

The following patch fixes this problem.

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇨🇦Canada sylus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024