If one misspells a pattern for a specific content type but has already applied it or want to change for a new one, "bulk update generate" won't work (fair enough). The only way to achieve is to delete all aliases for all content but there might be some aliases that one'd like to keep.

Would then might be interesting to be able to choose which content type to delete the aliases from.

[edit]
Maybe there could be a "force update/recreation" option.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

progzy created an issue. See original summary.

Berdir’s picture

I'd expect that bulk update should support *updates*.

progzy’s picture

Yes you're right ; would be more straightforward. There is actually no "bulk update" tab currently. This is called "bulk generate". So the feature request should be "add bulk update capabilities". What do you think @Berdir ?

progzy’s picture

Issue summary: View changes
Berdir’s picture

Issue tags: -bulk

Sorry, I somehow thought it would update those aliases.

Not sure then, adding that would make that form a lot more complicated and it would also complicate the API's quite a bit.

progzy’s picture

As said in the form:

Bulk generation will only generate URL aliases for items that currently have no aliases

So it actually does what it says.

Maybe there could be a checkbox with a "force" label to force recreation/update.

progzy’s picture

Title: Bulk delete per content type » Bulk generate - "Force" option
Issue summary: View changes
Berdir’s picture

One way to do that already is to use the action, e.g. through views bulk operations. However, that's currently limited to a single page (unless someone ported that feature from views bulk operations already).

Anonymous’s picture

I've built a custom module that adds a Views Bulk Operations action and an action for the admin/content page to force generate/update URL aliases here https://github.com/vilepickle/force_update_alias

Berdir’s picture

Note that This issue is about D8 and the module already contains an update alias action in 8.x.

Anonymous’s picture

Thanks, didn't notice that.

LpSolit’s picture

Now that Token is able to play with books correctly, I wanted to rename all book aliases, but unfortunately, this is not doable without first deleting *all* aliases for type = content (wow, I only want to do it for type = book). So I think the tab should be renamed "Bulk regenerate", because if we are able to delete all aliases of a given type and then create aliases for this same given type, then we are able to do it in one shot (at least from a user perspective). But we should be able to select article/book/base page/etc... separately instead of 'content' as a whole. And as mentioned in issue #2451307, we should be able to limit the mass create/update/delete to nodes with Set URL alias automatically' set to true only.

Would my proposal be accepted?

Berdir’s picture

I'm not sure what the right mix of features is, I don't want to make it too complicated.

I would start with two options, which can also be combined: "Update existing alias", and "Force generation of aliases", the second option alone would force it for those without an alias yet and the combined it would force for all.

Per bundle selection might be better for a follow-up.

As commented, there is also the views action, so you could create a view of book nodes and apply the update alias action, which will actually force-update existing aliases. That currently doesn't support batch to process large data sets but might still work better for your use case.

LpSolit’s picture

Assigned: Unassigned » LpSolit

I have a working patch. I need to test it a bit more first (and sleep a bit ;)). I will upload it tomorrow.

LpSolit’s picture

Title: Bulk generate - "Force" option » Bulk generate should be able to recreate aliases
Status: Active » Needs review
FileSize
8.22 KB

I didn't update PathautoBulkUpdateTest.php yet, because it will depend on the UI. So an initial review would be welcome.

It passes all tests locally except PathautoNodeWebTest for an obscure reason:

Uncaught PHP Exception InvalidArgumentException: "Invalid database prefix: " at core/lib/Drupal/Core/Test/TestDatabase.php line 81

But I get the same error message with my patch backed out, so the reason for this failure must be elsewhere.

So PathautoNodeWebTest fails on my machine but not here!? I'm jealous. :)

Status: Needs review » Needs work

The last submitted patch, 15: patch_2678558.diff, failed testing.

LpSolit’s picture

Status: Needs work » Needs review
FileSize
8.54 KB
LpSolit’s picture

Updated patch, now including tests for the new feature.

Berdir’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
Priority: Normal » Major
Status: Needs review » Needs work

Great work.

I was wondering for a second if this could cause the batch to loop forever, but we already handle that with the ID > current condition, so that should be fine. Ignoring the fact that this logic can only work for entities that have positive integers as ID's and not UUID's or so, but that would already be completely broken for them and this doesn't make it worse.

I guess a separate option to force re-generating the aliases, even if previously the user opted out might make sense, but lets do that in a separate issue.

We already have a number of related issues around bulk delete/update, and we could pick one of those to additionally also implement a force checkbox (We'll have to adjust some titles/descriptions added here but that's fine). You're welcome to look into that too. What would also be a great help for getting another beta or even a release candidate out would be to check for existing related issues and either set them to closed (duplicate) or postponed needs more feedback to try the latest dev and see if that fixes their problems.

The only thing I don't like is hiding the action inside the results through batchStart(). Lets pass that along to batchProcess() and make a new, explicit argument in batchUpdate(). That makes this an API change, but it is one anyway, otherwise existing implementations might not respect this new settings and would be "broken". This kind of forces them to update and respect it and it also gives us the perfect place to document the various values on \Drupal\pathauto\AliasTypeBatchUpdateInterface::batchUpdate().

LpSolit’s picture

Status: Needs work » Needs review
FileSize
13 KB
3.61 KB

Passing $action to batchProcess() and batchUpdate() was my initial idea, but I thought you would be against it due to the API change. Happy to see we have the same idea on this. :)

Here are both the updated patch and its interdiff.

  • Berdir committed 9a65022 on 8.x-1.x authored by LpSolit
    Issue #2678558 by LpSolit: Bulk generate should be able to recreate...
Berdir’s picture

Status: Needs review » Fixed

Awesome, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.