Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When there is a node with a duplicate title the new title defaults to 'ant'.
Is there a way to avoid this? and make it xxxxxx-1 or something?
Looking forward to any guidance.
Thanks
(great module btw)
Comment | File | Size | Author |
---|---|---|---|
#20 | set_title-2592915-20.patch | 657 bytes | Harlor |
#19 | set_title-2592915-6.patch | 652 bytes | Harlor |
Comments
Comment #2
gaurav.kapoor CreditAttribution: gaurav.kapoor commentedComment #3
broonMay I ask why this won't be fixed?
I have the same problem just now in a Drupal 7 (multilingual) site. Module worked fine for many years and suddenly some of the nodes are renamed to "ant". Examining the behaviour, it only happens on nodes of type "bio" where the node title is automatically set to "[first_name] [last_name]". It works for the original node (English) but the translated versions become "ant".
Comment #4
gaurav.kapoor CreditAttribution: gaurav.kapoor commentedThe issue was marked with the D6 release and I am not maintaining D6 version, that's why i closed the issue. But since you have marked it with D7 now, I'll look into it.
Comment #5
broonI've tested some more. It may be related to the language.
When I create an English node first, the title is correct and becomes "ant" on the translated (German) node. If I just click edit and save the German node again, the title is correct again.
However, when I create the German version first, it has the title "ant" while the English translation created afterwards shows the correct title again.
Comment #6
broonOk, this is getting confusing now. My last comment is not fully true. I did some more tests and it now boils down to this:
If I create a node and choose a language different than my current interface language, then the title is set wrong ("ant"). This is both true for creating a German node on http://domain.com/node/add/bio as well as creating an English node on http://domain.com/de/node/add/bio - so it must be something language related.
Btw. we do have a custom module, that changes the interface language accordingly when editing an existing node. That's why the title get's corrected when saved again. So, if my interface language is English and I just created a German node, which I now want to edit, our custom module automatically switches to German interface language.
In addition, using the preview on existing nodes (1) shows the wrong title "ant" BUT (2) fixes the title due to the node_submit hook but by using this also (3) breaks save function on node edit form, error: "The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.".
Comment #7
manish-31 CreditAttribution: manish-31 as a volunteer commentedComment #8
broonSorry, but this is surely not outdated. We still do experience that error but are not able to find the source. The last case was just a couple of days ago. It happens about once in roughly 25 edits of "bio" nodes.
Comment #9
gaurav.kapoor CreditAttribution: gaurav.kapoor commentedHi @Paul Broon, are you still facing this issue?
Comment #10
broonSadly yes. And I still can't figure out the cause of it.
I was checking different permission for authors and editors, language settings as well as searching the error logs but there doesn't seem to be a single pattern in behaviour. So it may have multiple (independent) causes. Which is a bit annoying as it is unpredictable and causes some headaches for the editors because this happens on published nodes as well when some author updates the content (using Workbench Moderation the changes are not immediately published, though).
Further, our editors found another error: there is a replacement on nodes whose node types that aren't even using Auto Nodetitle. Sometimes a presentation or publication node's title was renamed to "Presentation 15234" or "Publication 15883" which seemed weird at first but then I found this line in ANT module:
$node->title = t('@type @node-id', array('@type' => $types[$node->type]->name, '@node-id' => $node->nid));
which produces exactly that title. Why it is invoked, though, is beyond my understanding as the content type settings' checkbox is off.
I guess, this is a rather rare case given the fact that we seem to be the only ones with this problem in D7 and it's hard to debug for me as well as my actions are limited due to it being a large productive site. The editors are not thrilled but they are keeping an extraeye on "ant" and "type nid" titles and know how to fix it and the developers are slowing starting the migration process to D8 anyways (which will probably still take another six month to complete) so it shouldn't be a problem for us next year anymore.
I'll postpone this issue therefore and give you an update if I do find anything helpful during my debugging sessions.
Comment #11
notreadbyhumans CreditAttribution: notreadbyhumans commentedWe are also experiencing this issue, where node titles are being replaced following certain events, such as changing Category Associations on the parent.
When this happens the title is changed from the the user generated one to an automatically generated one e.g. Web Page 4719. It can be manually renamed back, but then changes again the next time the triggering event occurs.
We are also seeing a growing number of Category Associations with the title 'ant' being generated automatically.
Comment #12
peterswinnen CreditAttribution: peterswinnen as a volunteer commentedOn a website I manage, the issue occurs whenever I try to update a node that uses Automatic Nodetitles.
In function auto_nodetitle_node_presave, updating of the title and replacement of the tokens takes place
if (auto_nodetitle_is_needed($node))
. This function verifiesempty($node->auto_nodetitle_applied)
, in which case the update does not take place. When I addif (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied);
before callingif (auto_nodetitle_is_needed($node))
, the title is updated correctly. Since$node->auto_nodetitle_applied
is not a standard part of$node
, and set byauto_nodetitle_set_title(&$node)
after successfully altering title, my guess is that somehow this must be cache related (I'm using Entity cache).Anyway, the following seems to solve my issue (auto_nodetitle.module line 88)
Comment #13
peterswinnen CreditAttribution: peterswinnen as a volunteer commentedVersion 7.x-2.0-alpha1
On a website I manage, the ant issue occurs whenever I try to update a node that uses Automatic Nodetitles.
In function auto_nodetitle_node_presave, updating of the title and replacement of the tokens takes place
if (auto_nodetitle_is_needed($node))
. This function verifiesempty($node->auto_nodetitle_applied)
, in which case the update does not take place. When I addif (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied);
before callingif (auto_nodetitle_is_needed($node))
, the title is updated correctly. Since$node->auto_nodetitle_applied
is not a standard part of$node
, and set byauto_nodetitle_set_title(&$node)
after successfully altering title, my guess is that somehow this must be cache related (I'm using Entity cache).Anyway, the following seems to solve my issue (auto_nodetitle.module line 88)
Comment #14
peterswinnen CreditAttribution: peterswinnen as a volunteer commentedNever mind, I found out about and switched to Automatic Entity Labels. Same basic functionality, with some valuable extensions. No trace of the 'ant' issue.
Comment #15
Rob_Feature CreditAttribution: Rob_Feature commentedFor me, it wasn't even a 'duplicate entry' causing this. On many of my auto node title nodes I was getting this 'ant' title problem. I added the patch shown in #13 and that fixed things for me. I'm running the latest dev....
Comment #16
Rob_Feature CreditAttribution: Rob_Feature commentedand...marking this as active again since I'm seeing it and that patch gives some indication of whatever the problem is...
Comment #17
gaurav.kapoor CreditAttribution: gaurav.kapoor commented@Rob_Feature do you have any patch for this, so that we can close this issue?
Comment #18
troybthompson CreditAttribution: troybthompson commentedI started noticing this recently. I don't use other languages. I recently upgraded to PHP 7.2 if that matters. Patch #13 got rid of the problem.
Comment #19
Harlor CreditAttribution: Harlor commentedI believe the actual problem is that title is not set in the auto_nodetitle_node_submit. A coresponding notice occurred already in https://www.drupal.org/node/2954873.
Can we just set the title?
Comment #20
Harlor CreditAttribution: Harlor commentedAh this would cause https://www.drupal.org/node/1910016 again. But this should work.
Comment #21
Gribnif CreditAttribution: Gribnif commentedI think the fixes so far have ignored one fundamental flaw in this module. Consider this code:
The update to node_revision means that any time this code runs, it updates all titles and timestamps of all revisions of a node. This is very bad, in my opinion, because it destroys the revision history. Instead, the node_revision update should be:
Comment #22
broon@Gribnif Good catch! I was scratching my head why whenever this error happens, all revision titles are changed, too (making it impossible to set it back by just looking at the history).
Comment #23
aitala CreditAttribution: aitala commentedI'm really getting confused... I have run into this issue when trying to fix this >> https://www.drupal.org/project/auto_nodetitle/issues/2789079
Does anyone have a means to get Automatic Nodetitles and Inline Entity Form playing nice together? This is a show stopper for me, until I can fix it I'm dead in the water.
Thanks,
Eric
Comment #24
noopal CreditAttribution: noopal commentedHi,
I had this problem, it was due to the Token I was using.
When I tried [node:nid] the nid showed.
When I used [node:field] it showed ant as the field token wasn't working.
When I changed to a different token it worked again.
If you have the problem double check what your output is actually returning.