Hello !

I'm not sure my problem is pathauto-specific, but I managed to solve it by modifying the pathauto module.

Context : I am writing a module which copies a CCK node using this methd :

$new_node = node_load($nid);
unset($new_node->nid);
node_save($new_node);

Doing so seems to work, but I get warnings :

warning: Illegal offset type in isset or empty in /var/www/html/modules/taxonomy/taxonomy.module on line 1150.
warning: Illegal offset type in /var/www/html/modules/taxonomy/taxonomy.module on line 1151.
warning: Illegal offset type in /var/www/html/modules/taxonomy/taxonomy.module on line 1154.

I discovered that these warnings where triggered by the pathauto module, in the node_get_placeholders() function.
The $first_term_id gets filled with an object such as :

stdClass Object ( [tid] => 44 [vid] => 1 [name] => My term [description] => [weight] => -2 [language] => [trid] => 0 )

I therefore modified the node_get_placeholders() function to add detection a such an object :

       elseif (is_array($value)) {
         $temptid = array_shift($value);
         if ($temptid) {
           $first_term_id = $temptid;
           break;
         }
       }
+       elseif (isset($value->tid))
+       { 
+         $first_term_id = $value->tid;
+           break;
+       }
       elseif ($value) {
         $first_term_id = $value;
           break;

This solved my problem, but i'm still not sure it's really related to the pathauto module. What do you think about it ?

Comments

mwander’s picture

I'm seeing the same errors with in a slightly different scenario. (I think this is related.)

I create nodes using a script - including populating taxonomy and scheduler. Then, if I go in and change the unpublish date, then run cron to make it take effect, I see those same errors the first time I view a page with the changes.

Does this help in any way? Do you think it might be related?

Same version of pathauto.

Thank you.

greggles’s picture

perhaps you could try out the patches in this issue: http://drupal.org/node/123001

It seems similar to your situation if not exactly the same.

deelight’s picture

Thanks for the link, the patch given seems to be the same as mine, so I guess it's ok :)

greggles’s picture

Status: Active » Closed (duplicate)

That's good to hear.

Can you clarify what kinds of situations you use your site for? Are you only building nodes in the manners described below or are you also creating them in the normal (manual) manner?

My concern is that this new code will work for your scenario but not the old one.

Thanks!

deelight’s picture

I also create nodes the normal way.

My module only duplicates a bunch of CCK nodes, once a year. All these nodes are associated with taxonomy terms, and automagically get a friendly url thanks to pathauto. The duplication code in my module is really simple, it basically does :

// form submit process
function node_duplication_submit($form_id, $form_values) {
  $result = db_query("
    SELECT nid
    FROM {content_type_mynodetype}
    WHERE field_bogus_value='%s'", $form_values['bogus']);
  while ($source_node = db_fetch_array($result))
  {
    $new_node = node_load($source_node['nid']);
    unset($new_node->nid);
    $new_node->title = $new_node->title.' - '.t('new');
    node_save($new_node);
  }
  drupal_set_message(t('Copy done.));
}
mwander’s picture

Per your request, done. #31 at the URL you listed. Resolved. Thank you!