[drupal-devel] [bug] De-selecting all content type options creates in_array() error

leafish_paul drupal-devel at drupal.org
Tue Mar 22 12:31:38 UTC 2005


Issue status update for http://drupal.org/node/17158

 Project:      Drupal
 Version:      cvs
 Component:    node system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  samo
 Updated by:   leafish_paul
-Status:       active
+Status:       patch
 Attachment:   http://drupal.org/files/issues/node.module_fix_empty_node_options.patch (1.04 KB)

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?


leafish_paul



Previous comments:
------------------------------------------------------------------------

February 10, 2005 - 23:34 : samo

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();


------------------------------------------------------------------------

February 11, 2005 - 15:09 : samo

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.


------------------------------------------------------------------------

February 11, 2005 - 15:19 : samo

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


------------------------------------------------------------------------

February 14, 2005 - 17:29 : samo

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.


------------------------------------------------------------------------

February 19, 2005 - 08:10 : robertDouglass

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

<?php
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);
  }
?>




------------------------------------------------------------------------

February 19, 2005 - 08:30 : robertDouglass

should this be $node instead of $edit?
$node_options = variable_get('node_options_'. $node->type,
array('status', 'promote'));





More information about the drupal-devel mailing list