Undefined Index Errors

ngmaloney - July 9, 2009 - 15:25
Project:Publish Content
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Installed module on latest D6 release. On a view page that listed nodes I received the following error:

notice: Undefined index: type in publishcontent/publishcontent.module on line 158.
notice: Undefined index: #value in in publishcontent/publishcontent.module on line 158.

I needed this working ASAP so I added the following code which seems to have resolved it:

Added the following to publishcontent.module, line 153:  

#Fix for Undefined index error
  if(!isset($form['type']) || !isset($form['type']['#value'])) {
    return FALSE;
  }

// Below is the full function with the code added.

/**
* Implementation of hook_form_alter()
*
* allow to use the 'Publishing options' on the edit/add page
*/
function publishcontent_form_alter(&$form, $form_state, $form_id) {
  #Fix for Undefined index error
  if(!isset($form['type']) || !isset($form['type']['#value'])) {
    return FALSE;
  }
  if (!user_access('administer nodes')
      && $form['type']['#value'] .'_node_form' == $form_id
      && (_publishcontent_unpublish_access($form['#node']) ||
          _publishcontent_publish_access($form['#node']))) {
    $form['options']['#access'] = TRUE;
    unset($form['options']['promote']);
    unset($form['options']['sticky']);
    unset($form['options']['revision']);
  }
}

If others experience this bug, I would be happy to submit patch.

#1

malaussene - July 17, 2009 - 23:27

Hi ngmaloney,

which form/url generate this notice?

#2

ngmaloney - July 20, 2009 - 19:15

It was on any node edit page.

 
 

Drupal is a registered trademark of Dries Buytaert.