I spent the entire day trying to understand why my install of auto_nodetitle would return the famous 'ant' no matter what I do when set to 'Automatically generate the title and hide the title field'

I used several snippets, specially the one described here : http://drupal.org/node/283830 (which works great normally and on on my local install)
and the one included int the readme : ?php return "Author: $node->name"; ?

What's more bugging is that I put some debug markers 'print_r($node->title);' in the following module functions :

- auto_nodetitle_set_title : print_r($node->title) shows it sets the title correctly when the if (trim($pattern)) condition is accepted
- auto_nodetitle_nodeapi : print_r($node) also shows the title is set correctly

Then, for some reason, the title gets changed back to 'ant'

if anyone has any idea why the title would get set back to 'ant' after being set correctly, I would greatly appreciate the help.
Thanks

(note : I did a local install, and it works perfectly, I tried to make both dev and online versions as similar as possible)

Comments

poloparis’s picture

a few more specific that could help debug :

in function 'auto_nodetitle_set_title' I get a correct title after the call to '_auto_nodetitle_patternprocessor'

a print_r of $node in the hook_nodeapi function 'auto_nodetitle_nodeapi' gives me also a correct title. It returns this :

stdClass Object ( [nid] => [vid] => [uid] => 1 [created] => 1238160953 [type] => story [language] => [changed] => 1238160953 [title] => this is a test body content for the ant bug... [teaser_js] => [teaser_include] => 1 [body] => this is a test body content for the ant bug i'm getting and that should be enough. [format] => 1 [revision] => 0 [log] => [name] => secret [date] => [status] => 1 [promote] => 1 [sticky] => 0 [op] => Save [submit] => Save [preview] => Preview [form_build_id] => form-2f0d73da0cd334b5e39329cf2f6764bf [form_token] => 36b74d66ef29e1c577408952e31af63d [form_id] => story_node_form [comment] => 2 [menu] => Array ( [mlid] => 0 [module] => menu [hidden] => 0 [has_children] => 0 [customized] => 0 [options] => Array ( ) [expanded] => 0 [parent_depth_limit] => 8 [link_title] => [parent] => primary-links:0 [weight] => 0 [plid] => 0 [menu_name] => primary-links ) [path] => [pathauto_perform_alias] => 1 [nodesubscribe] => 0 [teaser] => this is a test body content for the ant bug i'm getting and that should be enough. [validated] => 1 [auto_nodetitle_applied] => 1 )

So again, the title is set correctly. Why does it revert back to 'ant' ?

poloparis’s picture

Version: 6.x-1.0 works perfectly with php snippets

am I the only one who gets this bug of the title reverting back to 'ant' after being changed correctly with Version 6.x-1.1?

Hazlitt’s picture

I am having exactly the same problem. No matter what I set the 'Pattern for the title' to when I enable 'Automatically generate the title and hide the title field' the title of the node always gets set to 'ant'.

I have researched this problem and tried a number of different settings to try and solve it but I have not found any answers.

I also would be grateful of help if anyone knows how to solve this.

poloparis’s picture

I had to revert to version 6.x-1.0 which works perfectly
6.x-1.1 works locally but bugs online
if anyone has any idea, that would be great, even just out of curiosity.

Hazlitt’s picture

Yes that works for me to. I downloaded the 6.x.1.0 version and it is working fine and correctly replacing tokens.

Now I have come up against a new problem! Tokens for CCK Computed fields are not being replaced. Other tokens are working fine.

francoud’s picture

I had the same problem: working on test site, not working on production site. Difference is that on the (working) test site we run php 5; on the production site, we run php4. Some compatibility problem?

Denys Babenko’s picture

A (temporary) straightforward solution would be to check $node->title=="ant"

here is an example of such snippet

if((empty($node->title)) or ($node->title=="ant")){
  $random1 = rand(100000000, 999999999);
  $random2 = rand(100000000, 999999999);
  $total = round(($random1 + $random2) / 2);
  echo $total;
} else {
  echo $node->title;
}

Let me know if it has any bugs because use it :)

benkallos’s picture

Version: 6.x-1.1 » 6.x-1.2

#4 is the way to go.

This problem is not repaired as of Version 6.x-1.2.

The best bet remains version 6.x-1.0 which still works perfectly.

The patch offered for Drupal 6 at http://drupal.org/node/171249#comment-1363276 had a Hunk Failure

% patch -b < ant_preserve_option.patch
patching file auto_nodetitle.module
Hunk #2 FAILED at 28.
Hunk #3 succeeded at 88 with fuzz 1 (offset 10 lines).
Hunk #4 succeeded at 167 (offset -2 lines).
1 out of 4 hunks FAILED -- saving rejects to file auto_nodetitle.module.rej

Todd Young’s picture

6.x-1.0 did *not* work for me, using tokens nor php snippets.

u4yk’s picture

I was having a problem with this, too; however, it turned out that it was a conflict with the Workflow Fields module. After uninstalling both modules (along with the Workflow module), running "delete from system where name = 'auto_nodetitle';" and reinstalling all modules, this problem was then fixed. FYI.

loominade’s picture

subscribe

aaronbauman’s picture

This (naïve) patch seems to work for me:

Index: auto_nodetitle.module
===================================================================
--- auto_nodetitle.module	(revision 479)
+++ auto_nodetitle.module	(working copy)
@@ -71,7 +71,10 @@
  * Returns whether the auto nodetitle has to be set.
  */
 function auto_nodetitle_is_needed($node) {
-  return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title));
+  $setting = auto_nodetitle_get_setting($node->type);
+  return
+    (($setting == AUTO_NODETITLE_ENABLED)
+    || ($setting == AUTO_NODETITLE_OPTIONAL && empty($node->title)));
 }
 
 /**

edit: fixed original patch suggestion

jvieille’s picture

sub

Jorenm’s picture

Your patch doesn't do anything for me. No matter what I put in the pattern field I get out "ant".

brpubs’s picture

sub

clivesj’s picture

As mentioned in the comments that patch was no good, it ios replaced by http://drupal.org/node/171249#comment-4033072

But be carefull there are some patches agains dev and some against last stable!

I would suggest using the latest dev.

shaneonabike’s picture

Yeah I also experienced this and I'm using workflow as well.

Now what's interesting is that in the end I am getting the final title correct but when I try to process it during a Trigger action it's messed up showing 'ant'

My configuration is just simply using the titles from two different node references (tokens) as the title.

[reference_1] & [reference_2]

gaurav.kapoor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)