I am creating a title with php, consisting of to parts:
part 1: namestring
part 2: filestring

...
more code
...
$final_string = $result . " - " . $filename;
$final_string = str_replace("%20", " ", $final_string);

return $final_string;

After saving the node gets a correct title, but the linking is broken. System tells me, that the node <$result . " - "> was created (in fact the the node was titled like expected) and that the site "content/result . " - "" was not found.
Though the creating of the title string and titleing of the node went absolutely correctly, the linking after creating the node seems to be broken.
I am using pathauto-module and global-redirect.
This behaviour is repoducible: always

CommentFileSizeAuthor
automatic-entity-label_2.png34.11 KBAnonymous (not verified)
automatic-entity-label_1.png25.78 KBAnonymous (not verified)

Comments

Anonymous’s picture

Issue summary: View changes
Anonymous’s picture

Issue summary: View changes
bforchhammer’s picture

AEL currently saves newly created nodes a second time in order to be able to use things like the node id which is only available after it has been saved to the database.

My suspicion would be that the 2nd part of your title (the $filename) is a property which also falls into this category, i.e., which is only available after the node has been saved at least once (and after the respective file has been uploaded and properly added to the managed file database table?)

Pathauto related functionality is only executed during the first save, so if you use [node:title] in a pathauto pattern, the incomplete title will be used. Other users have experience the same problem, but I'm afraid I don't have a solution.

So, I'd look at how you compute $filename in your custom php code and check if that can be changed.

ikeigenwijs’s picture

I first tried to get around this issue with rules.
trigger -> on new content saved
action -> redirect
and a lot of variations, but that did not work.

Then i found the following module:
https://www.drupal.org/project/node_save_redirect

The functionality is enough for our use case.
Maybe AEL could teak a peak at how they do it.
Its also in hook_submit

I used debug and step by step execution.
I saw that the complete procedure of title generation is performed 2 times for 1 node. to get availability for all tokens like tose only available after the first node_save ,nid, serial and so on.

The solution i think is in resetting the redirect every time the title is changed. (Now its handled by path_auto_only after new content_save, so the new title after the second save does not get processed by path auto for the redirect , but the correct alias with the full correct title is created correctly)
I think in auto_entitylabel_field_attach_submit() should the new redirect be set with the correct complete title.

The how i don't know, this is as far as i got.

shaisamuel’s picture

I have similar issue:

  • The title is made of 3 fields.
  • The content-type url is based on the title.
  • The initial save have a field, which is missing it's value. The title get created without this field (according to the message on the screen), and the screen get redirected to the content (with the missing field title).
  • Rules with "before saving content of type" is kicked in, and the missing field gets its value.
  • The title is then builds correctly (with the new field value) and the url does as well.
  • An "Page not found" error is fired due to redirection to the wrong path.
Marcus 78’s picture

Simplest solution to this is to use the pathauto module. Since its automatically set to [node:node-title] i guess there som trouble with "first save" of the two saves that this module makes since it refers to something that isnt there.

Change the automatic path to something else like [node:nid] or anything but the title and you avoid this error.

purushotam.rai’s picture

Issue tags: +SprintWeekend2016

I guess this issue has been fixed with latest releases of these module as I'm not able to reproduce this issue anymore with current stable versions of Automatic Entity Label and Pathauto.

Everything works fine for me and hence closing this issue. Feel free to re-open if anyone encounters any such issue. It would be highly appreciated if we can have steps to reproduce as well.

Thanks

purushotam.rai’s picture

purushotam.rai’s picture

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

still issue with 1.3

my use case is using this replacement/insertion

My-Data-Record-[node:nid]

after saving it redirects to the page http://mysite.com/my-data-record-

which it doesn't find and redirects to the first node id created with this method.

In essence always redirects to http://mysite.com/my-data-record-1 even though I just saved http://mysite.com/my-data-record-2

crutch’s picture

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

Same here.. name "Marcacao - [node:nid]" , redirect to the first I created.

EDIT:
As of this, https://www.drupal.org/node/2824715 , it really is an issue with the pathauto, and having node:title token in it. Changing pathauto pattern to the one expected, solved it.

crutch’s picture

Okay great this works thank you. I used the same tokens for auto entity label and pathauto and it seems to be working well. In my case, specifically

AEL is
[node:field_select_course]-[node:nid]

Pathauto is
current-courses/[node:field_select_course]-[node:nid]

proofoftom’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.