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

laurajeans created an issue. See original summary.

berdir’s picture

I 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.

laurajeans’s picture

Hi 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.

laurajeans’s picture

Status: Active » Closed (cannot reproduce)
berdir’s picture

Yes, *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.

laurajeans’s picture

Hi 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.

pathauto_entity_delete($node);
pathauto_entity_insert($node);

Please let me know if you can think of anything I should look at knowing this latest info. Thank you for your help.

kimjanssens’s picture

Experiencing 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.

JvE’s picture

Status: Closed (cannot reproduce) » Active

I can reproduce on simplytest.me:

  • Go to /admin/config/search/path/patterns/add and set up a pattern for article content.
  • Go to /admin/structure/types/manage/article/form-display and disable the URL-alias field
  • Go to /node/add/article and create a new article with an uploaded picture

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.

berdir’s picture

Ok, interesting, so it only happens when the pathauto widget is hidden?

There are other issues about problems when the widget is hidden.

mably’s picture

Status: Active » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.