- Issue created by @Summit
- 🇳🇱Netherlands Summit
Hi,
This worked for me for a particular one, within PHPMYADMIN. Is this save
DELETE FROM `path_alias` WHERE `alias` LIKE '%alias_name%';
DELETE FROM `path_alias_revision` WHERE `alias` LIKE '%alias_name%';
greetings, - First commit to issue fork.
- 🇸🇮Slovenia miroslavstankov
Hi,
I think deleting aliases directly in phpMyAdmin (DELETE FROM path_alias WHERE alias LIKE '%apple%';) is risky. It doesn’t check if aliases are linked to nodes and could mess up Drupal’s cache, causing broken links or errors.
A better approach i think is using a simple Drush script to safely delete only aliases not tied to nodes. Something like:$pattern = '/apple/%'; // Change to your pattern, e.g., '/strawberry/%'.
$aliases = \Drupal::entityTypeManager()->getStorage('path_alias')->loadByProperties(['alias' => $pattern]);
foreach ($aliases as $alias) {
$path = $alias->getPath();
if (preg_match('/^\/node\/(\d+)$/', $path, $matches) && !Node::load($matches[1])) {
$alias->delete();
echo "Deleted: " . $alias->getAlias() . "\n";
}
}I’d love to hear other solutions too if anyone has them!