? Failure
Pull Request for # 10451

User tests: Successful: Unsuccessful:

avatar paulgv
paulgv
13 May 2016

Pull Request for Issue #10451 .

Summary of Changes

Slightly modified libraries/joomla/date/date.php to prevent PHP fatal error when creating DateTime objects when $tz isn't correctly instantiated as a DateTimeZone object.

Testing Instructions

$date = new JDate('now', (int)1);

Throws PHP error :

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

avatar paulgv paulgv - open - 13 May 2016
avatar paulgv paulgv - change - 13 May 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2016
Labels Added: ?
avatar paulgv paulgv - change - 14 May 2016
Title
Make sure is an instance of DateTimeZone before attempting to create…
Make sure $tz is an instance of DateTimeZone before attempting to create…
avatar paulgv paulgv - change - 14 May 2016
Title
Make sure is an instance of DateTimeZone before attempting to create…
Make sure $tz is an instance of DateTimeZone before attempting to create…
avatar paulgv paulgv - change - 14 May 2016
Title
Make sure $tz is an instance of DateTimeZone before attempting to create
Make sure $tz is an instance of DateTimeZone before attempting to create DateTime
avatar paulgv paulgv - change - 14 May 2016
Title
Make sure $tz is an instance of DateTimeZone before attempting to create
Make sure $tz is an instance of DateTimeZone before attempting to create DateTime
avatar ggppdk
ggppdk - comment - 14 May 2016

I have not tested but it looks like, this PR will indeed suppress the exception error in cases that an integer is passed as timezone

  • the question is do we want to silently ignore the bad value passed ?
  • that exception had helped developers fix / update their exceptions, myself included (that is why i take time to answer here)

something else is bogus and what this PR suggests is suppress the error created by some other bug (possibly by 3rd party extension or maybe it is CORE code ?), this way we may hide bugs in the future
please read my answer here:
#10451

but someone can argue that it is not important to use correct timezone in such cases,
and can argue that it is preferable to continue execution, despite bad timezone being passed ... aka make it more "fault tolerant", but "fault tolerant" is for cases such as interrupted communications, not for masking out other bugs

avatar brianteeman brianteeman - change - 14 May 2016
Category Libraries
avatar brianteeman brianteeman - change - 14 May 2016
Rel_Number 0 10451
Relation Type Pull Request for
avatar bradkelleykc
bradkelleykc - comment - 9 Jan 2017

Maybe this is already known, but I have a use case that could explain how this error is coming up. Old versions of Joomla (e.g. 1.5) used non-structured text content in the params field of the user table. This also includes using integers for timezones.

Example:

admin_language=
language=
editor=
helpsite=
timezone=-6

However, newer versions (e.g. 3.x) user structured data and text-based timezone data.

Example:

{"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":""}

In my case, we had migrated users from an older 1.5 site into a newer 3.x site and somewhere along the line didn't notice this difference. Didn't get an error until one of these older users tried to make an edit. Our newer users, including myself, had no trouble.

This can be remedied by something like this:

UPDATEj3x_usersSETparams='{"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":""}';
...which sets all users to use default CMS values. This may not work for your situation if users have set other values, as you will be overwriting them.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 25 Aug 2018

If this Issue get no Response, it will be closed at 22th September 2018.

avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2018
The description was changed
Status Pending Closed
Closed_Date 2018-09-23 05:16:04 2018-09-23 05:16:06
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 23 Sep 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 23 Sep 2018
The description was changed
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-09-23 05:16:04
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2018
Status Closed Pending
avatar joomla-cms-bot
joomla-cms-bot - comment - 23 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 23 Sep 2018
avatar joomla-cms-bot joomla-cms-bot - edited - 23 Sep 2018
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 23 Sep 2018

This has been closed due to lack of response to the requests above – it can always be reopened.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/10453.

Add a Comment

Login with GitHub to post a comment