openagenda_preprocess_openagenda_agenda seems to be incompatible with path_alias

Created on 8 February 2024, 5 months ago
Updated 26 February 2024, 4 months ago

Problem/Motivation

openagenda_preprocess_openagenda_agenda hook adds a /event suffix after the node URL:

// Set event local link.
$event['local_url'] = $node->toUrl()->toString() . '/event/' . $event['slug'];

Though, in the processInbound method of the OpenagendaPathProcessor class the /event suffix is automatically added for path aliased nodes:

if ($processed_candidate_path !== $candidate_path && preg_match('/^\/node\/(\d+)$/', $processed_candidate_path, $matches)) {
  // See if that node contains an OpenAgenda field.
  if ($this->entityTypeManager->getStorage('node')->load($matches[1])->hasField('field_openagenda')) {
    // Rewrite the path to point to the route to our event controller.
    $path = $processed_candidate_path . '/event/' . $subpath;
  }
}

So the /event suffix ends added twice in the processed event URL and display fails.

Steps to reproduce

Simply create an alias for a node with an openagenda field and check the events URLs.

Proposed resolution

Only add the /event suffix if the node URL is of the form /node/123.

πŸ› Bug report
Status

Fixed

Version

3.4

Component

Code

Created by

πŸ‡«πŸ‡·France mably

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024