Using latest code from CVS; steps to replicate:

1) administer -> content -> configure (tab) -> content types (tab)
2) story -> configure
3) de-select all "Default options": Published, In Moderation Queue, Promoted..., Sticky..., Create new revision
4) Save Configuration
5) create content -> story

I receive 4 in_array() errors at lines 1318,1319,1320,1321 of node.module

warning: in_array(): Wrong datatype for second argument in modules/node.module on line 1318.

Is variable_get() expected to return an array?

I added a quick line in node.module to get past the problem for now, but I'm sure it is not the preferred solution:

if(!is_array($node_options) ) $node_options = array();

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

samo’s picture

The use of a default in variable_get() calls seems dangerous when we expect nothing back.

Line 1254:

variable_get('node_options_'. $edit->type, array('status', 'promote'));

What if the variable "node_options_story" is empty? status and promote are applied despite explicitly denying them when configuring content types.

samo’s picture

Shouldn't line 1254 of node.module use $node->type instead of $edit->type?

samo’s picture

I beg of someone, anyone: is line 1254 of node.module correct?

The object $edit is not referenced anywhere in that function. I believe $edit->type should be replaced with $node->type.

robertDouglass’s picture

Priority: Normal » Critical

Changing status to critical. I have reproduced this error and am investigating why in node_validate, there is a dead reference to $edit:

  if (user_access('administer nodes')) {
    ...  
  }
  else {
    // Validate for normal users:
    $node->uid = $user->uid ? $user->uid : 0;
    // Force defaults in case people modify the form:

    // this line can never succeed: $edit is a dead reference.
    $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote'));
    $node->status = in_array('status', $node_options);
    $node->moderate = in_array('moderate', $node_options);
    $node->promote = in_array('promote', $node_options);
    $node->sticky = in_array('sticky', $node_options);
    $node->revision = in_array('revision', $node_options);
    unset($node->created);
  }

robertDouglass’s picture

should this be $node instead of $edit?

$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));

moshe weitzman’s picture

Priority: Critical » Normal
pfaocle’s picture

I was able to recreate this problem, and it seems that changing that instance of 'edit' to 'node' seems to do the trick. Not sure why tho, could someone check this patch?

chx’s picture

asimmonds’s picture

The bug that samo originally mentioned at the top of this issue is still valid, just confirmed it in current HEAD.

The problem is, with all the workflow checkboxes cleared, the form variable for the checkboxes is set to the string '0' which is then stored in the node_options_* variable. When this is read back and unserialized, it's a string not a array. The string '0' comes from the form_hidden($name, 0) in form_checkboxes().

chx’s picture

http://drupal.org/node/18663

Not exact duplicate, but that fixes in a more general sense.