node_get_placeholders

$node->taxonomy array may contain different type of values.
* Just tids
* tags (string with names of terms)
* arrays of tids from some vocabulary
*!!! or object describing term (this happens just after node_load)

node_get_placeholders not take care about last case. This cause errors while saving node which previously was loaded with node_load changed some fields (not taxonomy) and saved with node_save.

Following patch for node_get_placeholders fixes this issue.

       // It's not freetagging
       // When editing a node, a multiselect vocabulary with nothing selected will have  "zero"
       // term IDs. Ignore them...
       elseif (is_array($value)) {
         $temptid = array_shift($value);
         if ($temptid) {
           $first_term_id = $temptid;
           break;
         }
       }
       elseif ($value) {
         $first_term_id = $value;
           break;
      }

Should be changed to

       // It's not freetagging
       // When editing a node, a multiselect vocabulary with nothing selected will have  "zero"
       // term IDs. Ignore them...
       elseif (is_array($value)) {
         $temptid = array_shift($value);
         if ($temptid) {
           $first_term_id = $temptid;
           break;
         }
       }
       //+++++++++++
       elseif (is_object($value)){
         if ($value->tid){
           $first_term_id = $value->tid;
           break;
         }
       }
       //+++++++++++
       elseif ($value) {
         $first_term_id = $value;
           break;
      }

At pathauto_node.inc near line 201

Comments

greggles’s picture

Status: Needs review » Active

Could you create a patch for this: http://drupal.org/patch/create

I believe the "is_object" is implied in the else case already. Perhaps what we need is just the "if ($value->tid){" inside of the else case and another else case for the final situation.

Thanks.

greggles’s picture

Status: Active » Closed (duplicate)

This seems like a duplicate of http://drupal.org/node/186674