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)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Feet created an issue. See original summary.

gaurav.kapoor’s picture

Status: Active » Closed (won't fix)
broon’s picture

Version: 6.x-1.2 » 7.x-1.x-dev
Status: Closed (won't fix) » Active

May 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".

gaurav.kapoor’s picture

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

broon’s picture

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

broon’s picture

Ok, 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.".

manish-31’s picture

Status: Active » Closed (outdated)
broon’s picture

Status: Closed (outdated) » Active

Sorry, 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.

gaurav.kapoor’s picture

Hi @Paul Broon, are you still facing this issue?

broon’s picture

Status: Active » Postponed

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

notreadbyhumans’s picture

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

peterswinnen’s picture

On 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 verifies empty($node->auto_nodetitle_applied), in which case the update does not take place. When I add if (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied); before calling if (auto_nodetitle_is_needed($node)), the title is updated correctly. Since $node->auto_nodetitle_applied is not a standard part of $node, and set by auto_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)

function auto_nodetitle_node_presave($node) {
+ if (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied);
  // If not yet done, generate the title now.
  if (auto_nodetitle_is_needed($node)) {
    auto_nodetitle_set_title($node);
  }
}
peterswinnen’s picture

Version 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 verifies empty($node->auto_nodetitle_applied), in which case the update does not take place. When I add if (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied); before calling if (auto_nodetitle_is_needed($node)), the title is updated correctly. Since $node->auto_nodetitle_applied is not a standard part of $node, and set by auto_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)

function auto_nodetitle_node_presave($node) {
+ if (!empty($node->auto_nodetitle_applied)) unset($node->auto_nodetitle_applied);
  // If not yet done, generate the title now.
  if (auto_nodetitle_is_needed($node)) {
    auto_nodetitle_set_title($node);
  }
}
peterswinnen’s picture

Never mind, I found out about and switched to Automatic Entity Labels. Same basic functionality, with some valuable extensions. No trace of the 'ant' issue.

Rob_Feature’s picture

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

Rob_Feature’s picture

Status: Postponed » Active

and...marking this as active again since I'm seeing it and that patch gives some indication of whatever the problem is...

gaurav.kapoor’s picture

@Rob_Feature do you have any patch for this, so that we can close this issue?

troybthompson’s picture

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

Harlor’s picture

Status: Active » Needs review
FileSize
652 bytes

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

Harlor’s picture

FileSize
657 bytes

Ah this would cause https://www.drupal.org/node/1910016 again. But this should work.

Gribnif’s picture

I think the fixes so far have ignored one fundamental flaw in this module. Consider this code:

function _auto_nodetitle_save_title() {
  $nodes = node_get_recent(1);
  foreach ($nodes as $node) {
    auto_nodetitle_set_title($node);
    db_update('node')
      ->fields(array('title' => $node->title, 'changed' => REQUEST_TIME))
      ->condition('nid', $node->nid)
      ->execute();
    db_update('node_revision')
      ->fields(array('title' => $node->title, 'timestamp' => REQUEST_TIME))
      ->condition('nid', $node->nid)
      ->execute();
  }
}

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:

    db_update('node_revision')
      ->fields(array('title' => $node->title, 'timestamp' => REQUEST_TIME))
      ->condition('vid', $node->vid)
      ->execute();
broon’s picture

@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).

aitala’s picture

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

noopal’s picture

Hi,

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.