开发者

SugarCRM: Unable to create Calls/Meetings - PHP Catchable fatal error with TimeDate::_getUserTZ()

开发者 https://www.devze.com 2023-03-12 03:31 出处:网络
Helllo, Recently I upgraded to 6.2 GA from 6.1.4 via the upgrade patch. Even since then I\'m unable to create anything that has direct relation with Date & Time, namely, Call Logs, Meetings and T

Helllo,

Recently I upgraded to 6.2 GA from 6.1.4 via the upgrade patch.

Even since then I'm unable to create anything that has direct relation with Date & Time, namely, Call Logs, Meetings and Tasks.

When I do the same using a subpanel, the entry simply vani开发者_高级运维shes and is NEVER created.

When I try from one of the respective modules under Activities, I get a HTTP 500 error upon submission.

The Apache error log reveals the following:

PHP Catchable fatal error:  Argument 1 passed to TimeDate::_getUserTZ() must be 
an instance of User, boolean given, called in /home/crm/include/TimeDate.php on 
line 849 and defined in /home/crm/include/TimeDate.php on line 259, referer: 
http://mysite/index.php?module=Leads&offset=1&stamp=1307694072083825200&return_module=Leads&action=DetailView&record=xxxxxxxxxxxx

Unfortunately, this has happened to a production server and I noticed this problem only too late.

How can I fix this? Seeking your help urgently.

Thanks, m^e

UPDATE 1

I've managed to apply a temporary patch to this and got it working... Line 849 of TimeDate.php is part of a function that looks like:

function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{

    return $this->_convert($date,
        self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
        $convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
} 

This function is in turn calling another one _getUserTZ() to which it is supposed to pass a variable of the type User. Instead it is passing null.

I used a snippet to check for empty $user and assign a value to it if needed. The code is part of another function named _getUser() found in this same file....

protected function _getUser(User $user = null)
{
    if (empty($user)) {
        $user = $this->user;
    }
    if (empty($user)) {
        $user = $GLOBALS['current_user'];
    }
    return $user;
}

I borrowed the code from this function and pasted it inside to_display_date_time(), making it look like:

function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{
    if (empty($user)) {
        $user = $this->user;
    }
    if (empty($user)) {
        $user = $GLOBALS['current_user'];
    }
    return $this->_convert($date,
        self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
        $convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
}

Now Calls / Meetings are working again.. but I still wonder what's the actual fix to this issue. My way should prove to be a quick fix for anyone who needs to rectify this in a hurry.

If anyone can get to the root of the problem and a more elegant fix, I'm willing to offer a bounty.

Cheers, m^e

0

精彩评论

暂无评论...
验证码 换一张
取 消