Needs review
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
9 Jun 2022 at 00:22 UTC
Updated:
13 Feb 2026 at 13:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
vacho commentedThis patch works for content types (nodes), is needed to extend for another entity kinds.
Comment #8
mably commentedHere's a summary of the changes made:
Files modified
1. src/Form/PathautoAdminDelete.php — Form UI + submit logic
2. src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php — Bundle filter in query
3. tests/src/Functional/PathautoMassDeleteTest.php — Test coverage
Test results
Comment #9
mably commentedMandatory screenshot:
Comment #11
mably commentedHere's a summary of the changes made to
src/Drush/Commands/PathautoCommands.php:EntityTypeBundleInfoInterfacedependency - imported the interface and added it as a constructor parameter for bundle validationdeleteAliases()- new#[CLI\Argument]attribute and$bundles = NULLparameter. When bundles are specified (or custom aliases are kept), the batch path is used with the fullbatchProcess($type, $bundles, $keep_custom)signature. Added a usage example forcanonical_entities:node article,page.validateBundles()validator - hooked topathauto:aliases-delete, it:getBundles()getBundles()helper - resolves the alias type's derivative entity type ID and returns bundle info fromEntityTypeBundleInfoInterfaceComment #12
mably commentedGlobal summary
Allow users to delete URL aliases for specific entity bundles rather than wiping all aliases of an entire entity type.
Problem
The "Delete aliases" form and the
drush pathauto:aliases-deletecommand only allowed selecting entire entity types (e.g. all nodes). On sites with many content types, there was no way to delete aliases for just one bundle (e.g. only articles) without affecting other bundles (e.g. pages). This forced administrators to either delete everything or resort to manual database cleanup.Changes
EntityTypeManagerInterfaceandConnectionservices. The form now renders per-bundle checkboxes (with alias counts) under each entity type that has bundles, shown/hidden via#states. On submit, when any bundle subset is selected (or custom aliases are being kept), the batch path is used with the bundle filter. Added helper methodscountAliasesByBundle()andgetSelectedBundles().AliasStorageHelperInterface. ThebatchDelete()method now reads$context['results']['bundles']and applies anINcondition on the bundle key when set. It also respects akeep_customflag — when FALSE, it deletes all matching aliases (including manual ones) viaAliasStorageHelper::deleteMultiple()instead ofPathautoState::bulkDelete().bundlesargument todrush pathauto:aliases-delete(comma-separated, valid only with a single alias type). Includes avalidateBundles()validator hook that checks the bundles exist and enforces the single-type constraint. InjectedEntityTypeBundleInfoInterfacefor bundle discovery.testBundleFilteredDelete()— creates 5 article and 5 page nodes, deletes only article aliases via bundle checkbox, then asserts article aliases are gone while page aliases remain.Comment #13
mably commented