Needs review
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
16 Jul 2019 at 13:56 UTC
Updated:
18 Feb 2026 at 07:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jasonawantHi @DamienMcKenna!
Is this feature request related to #2870514: Disable the "Generate automatic URL alias" checkbox for entities with existing paths? As a solution to that ux issue?
Comment #3
mably commentedAs asked in related issue #3394538, it could be great to be able to filter updates by content type.
Comment #4
mably commentedAdding a related issue about bulk deletion filtered by bundles.
Probably some generic solution to be defined for all bulk processes.
Comment #6
mably commentedHere's a summary of what was implemented:
New files:
src/Form/PathautoBulkToggleStateForm.php— Admin form at/admin/config/search/path/toggle_statewith:CREATE/SKIP)tests/src/Functional/PathautoBulkToggleStateTest.php— 4 test methods covering toggle toSKIP, toggle toCREATE, bundle filtering, and safety skip logicModified files:
pathauto.routing.yml— Added pathauto.bulk.toggle_state route with administer pathauto+bulk toggle pathauto state permissionpathauto.links.task.yml— Added tab at weight 35 (between "Bulk generate" at 30 and "Delete aliases" at 40)pathauto.permissions.yml— Added bulk toggle pathauto state permissionTest results:
All 4 new tests pass (52 assertions), and the 2 existing
PathautoBulkUpdateTesttests pass with no regressions.Comment #7
mably commentedI'm wondering if we shouldn't add an option to allow complete removal of state from the key-value store...
Will try to add that.
Comment #8
mably commentedHere's a summary of the latest changes:
PathautoBulkToggleStateForm.php
const REMOVE = -1sentinel value (never persisted, only used as form/batch marker)batchStart()now initializes aremovedcounterbatchProcess()handles REMOVE by deleting key-value entries (skipping entities that already have no state)batchFinished()shows "Removed pathauto state for N entities" message, and the "No pathauto states were changed" fallback only shows when both updated and removed are zeroPathautoBulkToggleStateTest.php
testRemoveState()— sets 2 nodes to SKIP, bulk removes, asserts entries are NULL and message showntestRemoveStateSkipsNoState()— verifies entities with no stored state are skipped (only 1 of 2 removed)Comment #9
mably commentedComment #10
mably commentedCould be interesting to add 3 new individual state actions (enable, disable, remove) that could be used with VBO.
Will see what I can do based on what has been done here: #3204586: "Update URL Alias" action is only available for nodes + users and does not work with views_bulk_operations
Comment #11
mably commentedVBO-compatible actions to toggle pathauto state on individual entities
This patch adds three bulk actions for toggling the pathauto state on individually selected entities (via Views Bulk Operations or core's bulk form on /admin/content):
Architecture
Follows the same pattern as core's
PublishAction/UnpublishAction/EntityPublishedActionDeriver:EntityPathautoActionDeriver) extends core'sEntityActionDeriverBaseand generates one derivative per path-enabled entity type (node, user, taxonomy_term). Uses the same detection logic asEntityAliasTypeDeriver— canonical link template + FieldableEntityInterface +pathbase field.PathautoStateActionBase) extendsActionBaseand provides shared logic: KV store access, access check viabulk toggle pathauto statepermission, andcalculateDependencies().#[Action]attribute andexecute()method.No VBO dependency — uses only core's
ActionBaseandContainerFactoryPluginInterface. VBO discovers them automatically.Files added
src/Plugin/Action/PathautoStateActionBase.php— shared base classsrc/Plugin/Action/PathautoStateCreateAction.php— set to CREATEsrc/Plugin/Action/PathautoStateSkipAction.php— set to SKIPsrc/Plugin/Action/PathautoStateRemoveAction.php— remove stored statesrc/Plugin/Derivative/EntityPathautoActionDeriver.php— deriver for path-enabled entity typesconfig/optional/system.action.pathauto_state_create_node.yml(+ user, taxonomy_term)config/optional/system.action.pathauto_state_skip_node.yml(+ user, taxonomy_term)config/optional/system.action.pathauto_state_remove_node.yml(+ user, taxonomy_term)tests/src/Kernel/PathautoStateActionTest.php— 8 kernel testsFiles modified
config/schema/pathauto.schema.yml— added schema for the three action plugin IDsTest coverage
Kernel test covers: deriver discovery (present for node, absent for non-path types), skip action, create action (including with existing alias), remove action (with/without existing state), idempotency, and access permission check.
Existing
PathautoBulkToggleStateTest(6 tests, 74 assertions) continues to pass.Comment #14
mably commentedMandatory screenshot (Tugboat):
Comment #15
mably commentedI'll work on the above issue once this one has been merged.
Most code can be reused there.
Comment #16
anybodyGreat work @mably! Code LGTM, I'm just not totally sure about the wording of the actions, but I think this is very close to RTBC. Let's see what @berdir says. #3204586: "Update URL Alias" action is only available for nodes + users and does not work with views_bulk_operations is definitely important as a closely related follow-up that should get fixed afterwards soon. :)