Warning reported when saving entities other than nodes

Created on 17 August 2023, about 1 year ago

Problem/Motivation

When saving any entity other than a node, like a media entity, a warning is reported:

Could not find /node/123 in path_alias table.

This happens in the BetaAliasStorage::updateTable method, because code in _cbl_save_beta_alias() in the .module code assumes it's a node being saved.

  $nid = $form_object->getEntity()->id();
  if ($alias) {
    \Drupal::service('betasite.beta_alias_storage')->saveAlias($nid, $alias);
  }
  else {
    \Drupal::service('betasite.beta_alias_storage')->deleteAlias($nid);
  }

Both the saveAlias() and deleteAlias methods add a "/node/" before the parameter, so it always looks for node paths, which it won't find with non-node entities.

Steps to reproduce

  • Enable the betasite module
  • Create a new media item and save it
  • Check the watchdog logs for the error, where it will say "/node/[ID]" and the ID will be the media entity ID.

Proposed resolution

The code needs reworked in the saveAlias/deleteAlias so that it knows what type of entity it is, and which path to check for.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SamLerner

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

Comments & Activities

Production build 0.71.5 2024