warning: Attempt to assign property of non-object in /home/crystaldawn/www/drupal/modules/privatemsg/privatemsg.module on line 1

LanceLight - August 26, 2007 - 05:08
Project:Subscriptions
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

In the newest version there seems to be an oversight in some of the $message object sanitations. When you click compose, you will be presented with these warnings:
* warning: Attempt to assign property of non-object in /home/crystaldawn/www/drupal/modules/privatemsg/privatemsg.module on line 1489.
* warning: Attempt to assign property of non-object in /home/crystaldawn/www/drupal/modules/privatemsg/privatemsg.module on line 1490.

It doesnt affect anything, but here is how to get rid of this warning. For some reason the $message object is initialized with a 0 rather than being NULL. I dont know squat about this module so this may be the wrong place to initialize the $message object, but it works just the same.

Change:

  // The first if can provide a partial message, so we fill it in to avoid
  // notices. Also we remove the message if it's a reply in a threaded view,
  // the original message will be seen anyways.
  if (!isset($message->subject) || variable_get('privatemsg_threaded_view', 0)) {
    $message->subject = '';
    $message->message = '';

TO:

  // The first if can provide a partial message, so we fill it in to avoid
  // notices. Also we remove the message if it's a reply in a threaded view,
  // the original message will be seen anyways.
  if (!isset($message->subject) || variable_get('privatemsg_threaded_view', 0)) {
    $message = NULL;
    $message->subject = '';
    $message->message = '';

#1

salvis - August 28, 2007 - 22:30
Status:patch (code needs review)» fixed

http://drupal.org/node/170519

#2

Anonymous - September 11, 2007 - 22:31
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.