Right now the bulk update only lets the user target an entity type (e.g. node, taxonomy term) but on large sites it would be good to be able to target a specific bundle (e.g. blog post) so as to speed up path updates.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3138032.patch | 15.21 KB | korn3000 |
| #9 | bulk-generate-bundle-3138032-9.patch | 12.63 KB | mostepaniukvm |
| #7 | 3138032-7.patch | 7.07 KB | rokzabukovec |
| #2 | 3138032-2.patch | 3.77 KB | rokzabukovec |
Issue fork pathauto-3138032
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rokzabukovec commentedHi I created a patch that should solve this issue. You can select bundles on generate and update functions. I hope you can review the patch.
Best regards.
Comment #3
rokzabukovec commentedComment #5
berdirThanks for starting this, useful feature indeed, but it does need quite some more work :)
This only includes node, we should include the bundles for each entity type, probably using #state to only see the bundles for enabled entity types.
Also, storing this in configuration doesn't make sense. We should pass it along as a new argument to the batch operation.
You don't need a function here, the default behavior of array_filter() works fine.
The logic should be in the batch operation query that selects entities to update. This means we would still test all of them and just abort when trying to set the alias. And it is persisted, which means once you save the form, it would then keep respecting that and no longer generate any other aliases.
Comment #6
rokzabukovec commented@Berdir thank you for the review. I will continue to improve the solution.
Comment #7
rokzabukovec commentedHi,
I created a patch that enables the user to specify which bundle to generate aliases for. In this patch only the content bundles are selectable but someone could extend this for other bundles. I also wrote a test for this behavior.
Comment #9
mostepaniukvmExtended #7 patch and added
bundlesargument to drush command.What about extending deriver and get derivatives for every bundle? As I remember in most cases I usually add or change some bundle-specific pattern and get need to regenerate aliases only for specific bundle. What about plugins like
canonical_entities:taxonomy_term:channel?Comment #10
a.milkovskyDrush command changes worked good for me. A minor note:
DI
Comment #13
sokru commentedUpdated the patch so that the PathautoBulkUpdateForm supports selecting bundles for other entities than nodes.
The MR has tests that pass, so removed the "needs tests" tag.
Comment #14
korn3000 commentedPort of https://git.drupalcode.org/project/pathauto/-/merge_requests/94 for 1.14
Comment #16
mably commentedSummary
Allow the Pathauto bulk update to target specific entity bundles rather than regenerating aliases for all bundles of an entity type.
Problem
Previously, the "Bulk generate" form and the
drush pathauto:aliases-generatecommand only allowed selecting entity types (e.g. all nodes, all users). On sites with many content types and thousands of nodes, regenerating aliases for all node bundles when only one bundle's pattern changed was unnecessarily slow and could produce unwanted side effects on other bundles' aliases.Changes
$bundlesparameter to thebatchUpdate()method signature.batchUpdate()— when$bundlesis non-empty and the entity type has a bundle key, the batch query adds anINcondition to restrict processing to the selected bundles only.entity_type.bundle.infoservice. The form now dynamically renders a set of bundle checkboxes per entity type, shown/hidden via#stateswhen the corresponding entity type is selected. On submit, selected bundles are passed through tobatchProcess().bundlesargument to thedrush pathauto:aliases-generatecommand (comma-separated list of bundles, only valid when a single alias type is specified). Includes avalidateBundles()hook that checks bundles exist and enforces the single-type constraint. InjectedEntityTypeBundleInfoInterfacefor bundle discovery.testCreateBundlePath()functional test — creates both an Article and an Event node, runs bulk update selecting only the Article bundle, and asserts that only 1 alias is generated (the Article), confirming the Event was correctly excluded.Comment #17
mably commented