Looked but did not see a duplicate issue.
drupal/core 8.5.1
drupal/token 1.1.0
drupal/ctools 3.0.0
drupal/pathauto 1.1.0
The problem: Upon saving a node, an alias auto generates (e.g. order/[nid]) just fine with the exception of when the user uploads an image (using the core image field). If the user tries to access the node via the alias they get a "Page not found" error.
Images are uploading without issue to a private folder location. If I later run bulk generate for un-alised paths, it picks up and generates the alias just fine. So the issue seems to only appear when an image entity is being created during the same node insert.
Issue predates recent core upgrade (i.e. same with ^8.4.3 and pathauto ^1.0).
Any help / ideas appreciated.
Comments
Comment #2
berdirI think I've seen something similar reported once before.
Can you reproduce this with a clean D8 install, e.g. the article node type? If so, please provide step-by-step instructions, so we can turn that into an automated test.
Comment #3
laurajeans commentedHi Berdir, sorry to be slow getting back to this. I did a fresh install and could not reproduce the issue.
My site has a custom module with use of the hook_ENTITY_TYPE_insert which redirects the user. I tried removing and reinstalling the custom module and that seems to have fixed it.
I will close this ticket.
Comment #4
laurajeans commentedComment #5
berdirYes, *never* redirect users away in hooks, this is exactly what will happen. Use a form-level submit callback so you can set the redirect on $form_state.
Comment #6
laurajeans commentedHi Berdir, I thought I'd report back my findings. I moved my redirect into a submit callback and set the redirect on $form_state and the issue still happens, so I'm less inclined to think that was the issue.
On my site, I thought the issue was fixed but it still happens intermittently. I tested a few cases and noticed that if I quickly hit save (before the ajax on the page says the image is loaded), the alias is creates just fine. If I wait and let the image fully load, and then hit save, the path alias doesn't build. When I have time, I'll add the same theme (bootstrap) to my fresh install and see if perhaps the theme is causing the issue.
For now, I've added two method calls to my submit handler to ensure new paths are being built and this seems to solve the issue for me.
Please let me know if you can think of anything I should look at knowing this latest info. Thank you for your help.
Comment #7
kimjanssens commentedExperiencing same issue, problem only occurs when saving in combination with an image upload. After node is created and I edit/save node again, url alias is created successfully.
Comment #8
JvE commentedI can reproduce on simplytest.me:
Now, if you save the article, the alias will not be created until you edit and re-save the article.
If you create an article with anything except an image, you will get an alias right away.
Comment #9
berdirOk, interesting, so it only happens when the pathauto widget is hidden?
There are other issues about problems when the widget is hidden.
Comment #10
JvE commentedThat would be #2946273: Alias is not generated when Pathauto widget is hidden and the patch from there (https://www.drupal.org/project/pathauto/issues/2946273#comment-12564307) solves the issue for us.
Comment #11
mably commented