?
Referenced as Pull Request for: # 10453
avatar paulgv
paulgv
13 May 2016

Steps to reproduce the issue

This started happening when saving existing articles. The issue does not occur on article creation.
I don't really know what triggered the issue but dumping $tz value in libraries/joomla/date/date.php returns int -5

Expected result

Article successfully saved.

Actual result

DateTime::__construct() expects parameter 2 to be DateTimeZone, integer given

System information (as much as possible)

Call stack
# Function Location
1 JApplicationCms->execute() /public_html/administrator/index.php:51
2 JApplicationAdministrator->doExecute() /public_html/libraries/cms/application/cms.php:257
3 JApplicationAdministrator->dispatch() /public_html/libraries/cms/application/administrator.php:152
4 JComponentHelper::renderComponent() /public_html/libraries/cms/application/administrator.php:98
5 JComponentHelper::executeComponent() /public_html/libraries/cms/component/helper.php:380
6 require_once() /public_html/libraries/cms/component/helper.php:405
7 JControllerLegacy->execute() /public_html/administrator/components/com_content/content.php:21
8 JControllerForm->save() /public_html/libraries/legacy/controller/legacy.php:728
9 JModelForm->validate() /public_html/libraries/legacy/controller/form.php:696
10 JForm->filter() /public_html/libraries/legacy/model/form.php:305
11 JForm->filterField() /public_html/libraries/joomla/form/form.php:229
12 JFactory::getDate() /public_html/libraries/joomla/form/form.php:1297
13 JDate->__construct() /public_html/libraries/joomla/factory.php:530
14 DateTime->__construct() /public_html/libraries/joomla/date/date.php:109

Additional comments

In libraries/joomla/date/date.php line 92 to 102, why not add an else clause to make sure the final $tz actually is a DateTimeZone object before constructing the DateTime ?

// If the time zone object is not set, attempt to build it.
if (!($tz instanceof DateTimeZone))
{
    if ($tz === null)
    {
        $tz = self::$gmt;
    }
    elseif (is_string($tz))
    {
        $tz = new DateTimeZone($tz);
    }
    else {
        $tz = self::$gmt;
    }
}
avatar paulgv paulgv - open - 13 May 2016
avatar brianteeman brianteeman - change - 13 May 2016
Category Libraries
avatar brianteeman brianteeman - change - 13 May 2016
Labels Added: ?
avatar ggppdk
ggppdk - comment - 14 May 2016

It sounds like

  • either the current editor (user) has an integer timezones saved into its user record in the users DB table (how could this happen ? maybe some user-related plugin that you have installed did this ?, i don't know)
  • or during run-time, some plugin is modifying the object of the current user and is setting an integer as user's timezone (this maybe a core extension or 3rd party ? i don't know)

For fixing the first case, try this:

  • go to user manager, find the user, edit it, and save it

For the 2nd case

  • the plugin is bogus and it should be fixed
  • about silently ignoring the bad value parameter, and avoiding the EXCEPTION error in such cases, maybe i don't know if it is desirable
avatar brianteeman
brianteeman - comment - 14 May 2016

Closed as we have a PR #10453

avatar brianteeman brianteeman - change - 14 May 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-05-14 08:50:58
Closed_By brianteeman
avatar brianteeman brianteeman - close - 14 May 2016

Add a Comment

Login with GitHub to post a comment