Line 545 Cannot use object of type stdClass as array

dgtlmoon - July 19, 2007 - 00:58
Project:Subscription
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I have a view trying to pull recent comments from all node types

However im getting this error from the subscriptions module

Debug Error: modules/subscriptions/subscriptions.module line 545 - Cannot use object of type stdClass as array

// $Id: subscriptions.module,v 1.38.2.3.2.17 2006/11/05 15:05:44 c0c0c0 Exp $

Looks like is_null is failing becuase you're referencing a member of an object, use is_object instead

--- subscriptions.module        2007-07-19 10:54:36.000000000 +1000
+++ subscriptions.module.fixed  2007-07-19 10:57:39.000000000 +1000
@@ -542,13 +542,14 @@
   $strsent = '!';
   // $comment can be an object or an array.
   // frankly, not sure why, but it may have to do with php version
-  $nid = is_null($comment->nid) ? $comment['nid'] : $comment->nid;
+  $nid = is_object($comment) ? $comment->nid :  $comment['nid'];
+
   if ($op == 'insert' || ($op == 'update' && $comment->status == 1)) { // ignore deactivated comments
     //  if use_cron is set, insert node actions into holding table
     if(variable_get('subscriptions_usecron', 0)){
       subscriptions_hold( $comment, 'comment' , $op, $user->uid );
     } else {  // if cron is not used
-      $cid = is_null($comment->cid) ? $comment['cid'] : $comment->cid;
+      $cid = is_object($comment) ? $comment->cid :  $comment['cid'];
       $nobj = node_load($nid);
       // send node subscriptions
       $strsent = $strsent . subscriptions_mailvars($nid, $cid, $user->uid, 'node', $strsent);

AttachmentSize
sub.patch1.03 KB

#1

patchak - August 10, 2007 - 17:39

This problem just *appeared* on my drupal 4.7 site, which is really weird, cause it never did that before and It's beel like a year since I touched that site! So you think that maybe the modification of the php version would have something to do with that??

Thanks

#2

dgtlmoon - August 31, 2007 - 14:18

yes this is definately possible as they handle the casting different

 
 

Drupal is a registered trademark of Dries Buytaert.