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();
Comment | File | Size | Author |
---|---|---|---|
#7 | node.module_fix_empty_node_options.patch | 1.04 KB | pfaocle |
Comments
Comment #1
samo CreditAttribution: samo commentedThe 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.
Comment #2
samo CreditAttribution: samo commentedShouldn't line 1254 of node.module use $node->type instead of $edit->type?
Comment #3
samo CreditAttribution: samo commentedI 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.
Comment #4
robertDouglass CreditAttribution: robertDouglass commentedChanging status to critical. I have reproduced this error and am investigating why in node_validate, there is a dead reference to $edit:
Comment #5
robertDouglass CreditAttribution: robertDouglass commentedshould this be $node instead of $edit?
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedComment #7
pfaocleI 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?
Comment #8
chx CreditAttribution: chx commentedThis was fixed on Mar 4:
http://cvs.drupal.org/viewcvs/drupal/drupal/modules/node.module?r1=1.472...
http://drupal.org/node/18226
Comment #9
asimmonds CreditAttribution: asimmonds commentedThe 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().
Comment #10
chx CreditAttribution: chx commentedhttp://drupal.org/node/18663
Not exact duplicate, but that fixes in a more general sense.