I want an option in bulk generation to also generate aliases for content that already has aliases. I’ve included a patch that solves the issue for me. It adds a checkbox to the bulk generate form. This is useful if you change a pattern and have selected "Create a new alias. Leave the existing alias functioning."

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeanfredrik created an issue. See original summary.

Berdir’s picture

Issue tags: +Needs tests
+++ b/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php
@@ -121,7 +121,9 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt
     $query = db_select($entity_type->get('base_table'), 'base_table');
     $query->leftJoin('url_alias', 'ua', "CONCAT('" . $this->getSourcePrefix() . "' , base_table.$id_key) = ua.source");
     $query->addField('base_table', $id_key, 'id');
-    $query->isNull('ua.source');
+    if(!$force_new) {
+      $query->isNull('ua.source');
+    }

The feature makes a lot of sense, we have existing issues where this was discussed as well.

I think in this case, we can skip the join completely, that should make the query also a bit faster? or more than a bit, considering the join condition.

Also, tests. We have existing bulk generate tests, we could for example change the pattern and force a re-generation to make sure it works after the existing tests.

Berdir’s picture

Status: Active » Needs work
LpSolit’s picture

Status: Needs work » Closed (duplicate)

This is already fixed in issue #2678558.