Closed (fixed)
Project:
Support Ticketing System
Version:
7.x-1.0-beta2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Nov 2011 at 19:25 UTC
Updated:
5 Dec 2011 at 17:50 UTC
Helo,
when trying to add new project i got error "Fatal error: Unsupported operand types in /home/unitedbytes/d7.unitedbytes.pl/sites/all/modules/support/support_pm/support_pm.admin.inc on line 544"
It seems that it happens only when i don't have any support clients.
Tracking down error leads to support_pm.admin.inc
$clients = array(
0 => t('-- All clients --'),
) + _support_clients_load();
the "+" operator works on array so it seems that _support_clients_load() does not return array.
in function _support_clients_load() we can clearly see that if there are no records from DB $clients is never defined. To fix this bug we only need $clients = array() at begining of function.
Fixed function below
function _support_clients_load($path = FALSE) {
$clients = array();
$result = db_query('SELECT clid, path, name FROM {support_client} WHERE status = :status ORDER BY name', array(':status' => 1));
foreach ($result as $client) {
if ($path) {
$clients[$client->clid] = check_plain($client->path);
}
else {
$clients[$client->clid] = check_plain($client->name);
}
}
drupal_alter('support_clients_load', $clients);
return $clients;
}
Comments
Comment #1
vallab444 commentedhit by the same problem
Comment #2
bdragon commentedAgreed.
There was an additional change needed -- support_timer was doing an isset check instead of an empty check. I also removed an is_array() check that wasn't strictly needed in the first place.
Thanks.
http://drupalcode.org/project/support.git/commit/d1e27a80faae1df841860c6...
http://drupalcode.org/project/support_timer.git/commit/9e88ab71b0034db58...