case 'update': 
      if ($node->moderate && user_access('access submission queue')) { 
        print theme('box', t('Post queued'), t('The post is queued for approval. 
        You can check the votes in the <a href="/%queue">submission 
        queue</a>.', array('%queue' => url('queue')))); 
      } 
      elseif ($node->moderate) { 
        print theme('box', t('Post queued'), t('The post is queued for approval. 
        The editors will decide whether it should be published.')); 
      } 
      else { 
        print theme('box', t('Post published'), t('The post is published.')); 
      } 
      break; 

The above code is listed under hook_nodeapi on drupaldocs. But when one attempts to print in a similar fashion using the update case from within a module calling the nodeapi hook, you get a "cannot modify header information..." error.

Upon closer examination, the doc is at fault. The above code proposes methods that are impossible in 4.6.3. It should be changed to drupal_set_message.

Comments

drewish’s picture

I was going to roll a patch for this but I Just wanted to make sure I understand this. The problem is that print theme('box', ...) is sending output too early (before a redirect?) and should be replaced by drupal_set_message()?

fool2’s picture

The problem is in the documentation. http://drupaldocs.org/api/4.6/function/hook_nodeapi

Under "code" there is bad code, essentially. Using that code in your own modules will yield the error I described. Instead of print theme('box'....) it should be drupal_set_message which will not output anything until the appropriate time. (The update hook executes before the headers are sent, so this will yield an error if you output at that time)

beginner’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)