Error Message "Object of class stdClass could not be converted to string" when using PHP 5.2
| Project: | Filemanager |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Using PHP 5.2 a bug in filemanager.module's function filemanager_get_area_info() will be triggered: The sizelimit of the current area will be determined by calling the API function variable_get() with the string "filemanager_area_limit_" . $area as parameter. Alas the $area variable at this point is set to the resulting object of the former database query and does not longer contain the area name (usually the name of the calling module like acidfree). Actually this never worked because up to PHP 5.1 the $area object when used as string just contained the string "Object" (a PHP fallback). So sizelimit was every time looked up for ''filemanager_area_limit_Object'' but never found and set to the default: -1.
Since PHP 5.2 this fallback does not exist and PHP will just throw the error ''Object of class stdClass could not be converted to string'' (see http://us3.php.net/UPDATE_5_2.txt).
The attached patch will fix this.
| Attachment | Size |
|---|---|
| filemanager_for_php52.patch | 589 bytes |

#1
man, that's got to be the best bug report i've read in a while. easy to understand, identifies the problem and includes a patch.
thanks! this has been applied to HEAD and 4.7.
#2
You are welcome :)
I enjoy using the ease of Drupal and its modules. Moreover the way the Drupal community works is a big pleasure too!
#3
#4
How do I appy the patch? I am having this problem.. And ended here, but I don't know how to apply the patch. any help will be highly appreciated. thanks.
I am not using Drupal or anything, just came up with the problem today
#5
I am adding a record and get the "Object of class UserInbox could not be converted to string"
Please help.
<?php
require_once('Zend/Date.php');
// this class fetches the private messages from the t_inbox table
class UserInbox extends Zend_Db_Table
{
protected $_name = 't_inbox';
// get all the messages in the zone
public function getPrivateMessages($receiverId)
{
//TODO query
$db = $this->getAdapter();
$logger = Zend_Registry::get(YoConstants::REGKEY_LOGGER);
$sql = 'select * from t_inbox i where i.receiver_id = '.$receiverId;
return $db->fetchAll($sql);
}
// add private messages for the receiver
public function postPrivateMessage($senderId, $receiverId, $zoneId, $sub, $msg, $msgType)
{
$logger = Zend_Registry::get(YoConstants::REGKEY_LOGGER);
$logger->debug('SUBJECT IS ' . $sub);
$date = Zend_Date::now();
$data = array(
'sender_id' => $senderId,
'receiver_id' => $receiverId,
'zone_id' => $zoneId,
'msgDate' => $date->toString,
'message_type' => $msgType,
'message_text' => $msg,
'subject' => $sub,
'msg_read' => 'no',
'status' => '0'
);
$table = new UserInbox();
$logger->debug('DATE IS ' . $date);
$table->insert($data);
$logger->debug('DATE IS ' . $date);
}
}
?>