Recreate
1. Install Drupal 8 with Standard profile, but not yet the pathauto module.
2. Create a node of the content type page (example, but any content type will reproduce the error).
3. Install Pathauto, Ctools and Token modules.
4. Create a pattern for the page content type, e.g. "page/[node:title]".
5. Open the admin/content page, check the created node, select "Update URL-Alias" at "With Selection" and hit the button.
Evidence
1. The path alias is now created as you can see on the admin/config/search/path page or in the node/edit form tab "URL-Alias".
2. When hovering (e.g. on Firefox) with the mouse icon over the node title on the admin/content page, you still see the node/ link (correct would be the URL-Alias "page/").
3. Use the workaround of 'drush cr' on the commandline, if installed, or clear cache on page "admin/config/development/performance".
4. When now hovering over the node title it correctly displays the path-alias.
Conclusion
Apparently the cache is not updated to reflect the new URL alias.
The cache is updated by other means like entering the URL alias by the node/edit form (handled by the core path module) so I consider the evidence a bug in pathauto.
Additionally
The same problem in the other direction appears when you delete the path alias on the page admin/config/search/path using the operations' Delete button: although the URL alias is deleted, the alias is still used in the admin/content listing as link for the node (title) and clicking on it leads to a page not found error.
Thanks for the maintainers' efforts on this module.
Issue fork pathauto-2662044
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
wim leersThanks for reporting this. We already have an issue for this at #2480077: Using the URL alias UI to change aliases doesn't do necessary invalidations: path aliases don't have cache tags.
Comment #3
berdir(Kind of crossposting, keeping this open, as I think a fix/workaround in pathauto is a lot more likely/easier than fixing the core issue)
That's certainly an interesting one. There are core issues, since we really just us an API but I believe it will be hard if not impossible to fully address this in core. As aliases and system paths are everywhere and we'd need dozens if not hundreds of cache tags on some pages.
I think we can fix this by explicitly clearing the cache tags (Cache::invalidateTags(getCacheTagsToInvalidate())) of an entity when we generate an alias, probably only when doing so through bulk methods that don't involve saving the node.
Shouldn't be too hard to start working on that, we should also make sure we have a test for this. We can possibly extend our existing tests by going to admin/content or so between the steps of the e.g. the bulk delete + generate tests and asserting the results there.
Comment #4
wim leersGreat point!
Plan sounds good too. But AFAIR you will also have to implement the "when rendering" part of #2480077-12: Using the URL alias UI to change aliases doesn't do necessary invalidations: path aliases don't have cache tags.
Comment #5
mpp commentedNot sure if this is on topic and if it's a core or a pathauto issue but when performing migrations with pathauto enabled, performance degrades horribly.
Take a migration of 50 000 nodes which takes less than 2h to finish. It takes twice as long (4h+) with pathauto enabled.
As performance degrades gradually it might indicate a schema/index issue or the cache invalidation overhead becoming larger, I'll have to dig into the issue deeper to find the bottleneck. I already noted a similar degrading performance with migration+pathauto in Drupal 7.
So to make it on topic: when implementing cache invalidations, please keep migrations in mind.
Comment #6
berdirSee #2765729: PathautoPattern->applies() exponentially slows down operations with large numbers of nodes on that topic.
Comment #9
mably commentedComment #10
mably commentedSummary
Bulk alias operations (generate, update, delete) did not invalidate render caches, causing pages to continue showing stale aliases until caches expired naturally.
Problem
When aliases were created, updated or deleted in bulk (via the admin UI or Drush), Drupal's render cache was not invalidated. This meant anonymous visitors (and any page behind
page_cache/dynamic_page_cache) would still see the old aliases — or broken links — until the cache was manually cleared or expired on its own.Changes
batchDelete(), after deleting aliases the entity cache tags (node:123, etc.) are now invalidated for every affected entity. InbulkUpdate(), cache tags from entities whose aliases were actually changed are collected and invalidated at the end of the batch chunk.deleteAll()method (fast path that truncates tables) now invalidates therenderedcache tag, since there are no individual entity IDs to target when wiping everything.renderedcache tag after deleting aliases by source prefix.page_cacheanddynamic_page_cacheenabled. Covers four scenarios — bulk update, batch delete (keep custom), delete all (fast path), and per-type delete (fast path) — each priming the page cache, running the operation, then asserting the next anonymous visit is a cache MISS.Comment #11
berdirA few minor comments. Fine to merge after this I think.
This only handle bulk generation and deletions, I'd suggest we adjust the issue title to better explain what it does.
> The cache is updated by other means like entering the URL alias by the node/edit form (handled by the core path module) so I consider the evidence a bug in pathauto.
FWIW, this statement from the original issue isn't correct. the path module doesn't do that. Saving the node is what invalidates the node and therefore anything cached with that using that. If you'd use the path UI to manually create an alias that doesn't invalidate anything. But that's not our concern, that's what the core issue is about which will likely never be resolved, as the cost is far bigger than the possible gains. In practice, most sites use redirect module which handles outdated/missing aliases through redirects, so this is all pretty minor.
Similarly, there are going to be cases that use the link without the node cache tag, I don't think linkit or the new core feature for that adds that for example. So those would not be invalidated. But again, not our concern and not a big issue.
Comment #12
mably commentedComment #14
mably commented