When updating: Fatal error: Cannot use object of type stdClass as array in (...)/sites/all/modules/send/send.install on line 530

Ryan Palmer - October 22, 2009 - 19:15
Project:Send
Version:HEAD
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

When updating to HEAD version, I get the following error:

An error occurred. (...)/update.php?id=10&op=do <br /> <b>Fatal error</b>: Cannot use object of type stdClass as array in <b>(...)/sites/all/modules/send/send.install</b> on line <b>530</b><br />

<?php
  $templates
= array();
  while (
$row = db_fetch_object($res)) {
   
$format = send_value('template_format', $row->module, $row->nodetype, $row->nid);

   
// Don't create a bunch of duplicate entries.
   
$hash = md5($row->body . $format);
    if (!isset(
$templates[$hash])) {
     
$template = (object) array(
       
'name' => '',
       
'status' => 1,
       
'body' => $row->value,
       
'format' => $format,
       
'rows' => array(),
      );
     
$templates[$hash] = $template; // note 1
   
}

   
$templates[$hash]['rows'][] = $row; // note 2
?>

At note 1 it's assumed $templates[$hash] is an array of objects, but at note 2 $template['$hash'] is an array of arrays. Note 2, and once more below it, should instead be:

<?php
$templates
[$hash]->rows[] = $row;
?>

Patch attached.

AttachmentSize
send-install-object-array-error-rp.20091022.patch907 bytes

#1

Ryan Palmer - October 22, 2009 - 19:17

This patch is contributed by TP1 Internet 360, a Montreal-based Drupal web studio.

 
 

Drupal is a registered trademark of Dries Buytaert.