? Error

User tests: Successful: Unsuccessful:

avatar bembelimen
bembelimen
13 May 2015

If you call JDate->format and no timezone is set, you'll get the error:
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given‏

avatar bembelimen bembelimen - open - 13 May 2015
avatar chmst
chmst - comment - 13 May 2015

@test successful and thank you, bembelimen! Before the patch I got "Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given" when using the DatePeriod in my component.
After applying the patch, the Warning disappeared

avatar joomdonation
joomdonation - comment - 13 May 2015

Hi

What code we need to run in order to seeing the error? Look at JDate class, I see $gmt property is already initialized in contructor https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/date/date.php#L84, so I don't know when it is empty and cause the warning?

avatar zero-24 zero-24 - change - 13 May 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 13 May 2015
Category Libraries
avatar zero-24 zero-24 - change - 13 May 2015
Status New Pending
avatar bembelimen
bembelimen - comment - 19 May 2015

Hello,

don't ask me why, but the PHP class "DatePeriod" delivers a JDate object when you use the Traversable property (=> foreach ($dateperiod ...)) and the first parameter (http://php.net/manual/en/dateperiod.construct.php) is a JDate object. If you try to use ->format(...), the JDate method will be used and then this error appears...

avatar joomdonation
joomdonation - comment - 19 May 2015

Hi

As I mentioned before, the self::$gmt is initialized when a JDate object is created, so I don't know in what case it is empty. Could you provide sample code which we can run to prove this error?

avatar brianteeman brianteeman - change - 17 Jun 2015
Status Pending Information Required
avatar brianteeman
brianteeman - comment - 19 Jul 2015

After several months without further reply to the request for further information this issue is being closed. It can always be re-opened


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

avatar brianteeman brianteeman - close - 19 Jul 2015
avatar brianteeman brianteeman - change - 19 Jul 2015
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2015-07-19 17:59:24
Closed_By brianteeman
avatar brianteeman brianteeman - close - 19 Jul 2015
avatar Devportobello
Devportobello - comment - 8 Oct 2015

I can confirm issue, use this gist code

You will see something like this:

object(JDate)#341 (4) { ["tz":protected]=> NULL ["date"]=> string(26) "2015-10-08 10:00:26.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" }

Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in pathwww/libraries/joomla/date/date.php on line 321

Edit: added a fix without need to change core code (eg: JDate class); see comments in gist.

avatar chmst
chmst - comment - 8 Oct 2015

Thank you - sorry that I did not post the code which caused the warning for me, it is too much. Could you please test with bembelimen's patch? It worked for me also when I updated to 3.4.4 and solves the problem for me.

avatar Devportobello
Devportobello - comment - 8 Oct 2015

@test patch fix the notice

before:

object(JDate)#324 (4) { ["tz":protected]=> NULL ["date"]=> string(26) "2015-10-08 08:30:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" } 
Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone, null given in pathwww/libraries/joomla/date/date.php on line 321

after:

object(JDate)#324 (4) { ["tz":protected]=> NULL ["date"]=> string(26) "2015-10-08 08:30:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" } 

Just want to point out, after patch tz can be null, did this really good?

avatar zero-24 zero-24 - change - 8 Oct 2015
Status Closed New
Closed_Date 2015-07-19 17:59:24
Closed_By brianteeman
avatar zero-24 zero-24 - reopen - 8 Oct 2015
avatar zero-24 zero-24 - reopen - 8 Oct 2015
avatar Devportobello
Devportobello - comment - 9 Oct 2015

@chmst see that to a workaround: how JHtml date handle date
-> set timezone based on user config or general config

avatar chmst
chmst - comment - 10 Oct 2015

@Devportobello - thank you! I'll try this.

avatar Bloggerschmidt
Bloggerschmidt - comment - 24 Oct 2015

It works. I put the example code of the gist code and write it in index.php of the template. After saving I got [Warning: DateTime::setTimezone() expects parameter 1 to be DateTimeZone] and after patch the warning disappears.

avatar Bakual
Bakual - comment - 24 Oct 2015

Restarted Travis build to see if tests pass (I expect them to pass). Looks fine from review.

avatar Bakual Bakual - change - 24 Oct 2015
Milestone Added:
avatar matrikular matrikular - test_item - 24 Oct 2015 - Tested successfully
avatar matrikular
matrikular - comment - 24 Oct 2015

I have tested this item :white_check_mark: successfully on bc71688

Tested with the provided instructions / code - workes as described.


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

avatar zero-24 zero-24 - alter_testresult - 24 Oct 2015 - Bloggerschmidt: Tested successfully
avatar zero-24 zero-24 - change - 24 Oct 2015
Status New Ready to Commit
avatar zero-24
zero-24 - comment - 24 Oct 2015

Thanks. --> RTC for 3.4.6


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

avatar joomla-cms-bot joomla-cms-bot - change - 24 Oct 2015
Labels Added: ?
avatar zero-24
zero-24 - comment - 24 Oct 2015

Travis don't fails on this PR is fails on different :smile:

avatar rdeutz rdeutz - close - 27 Oct 2015
avatar rdeutz rdeutz - reference | 4672162 - 27 Oct 15
avatar joomla-cms-bot joomla-cms-bot - close - 27 Oct 2015
avatar rdeutz rdeutz - merge - 27 Oct 2015
avatar rdeutz rdeutz - close - 27 Oct 2015
avatar rdeutz rdeutz - change - 27 Oct 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-10-27 21:03:38
Closed_By rdeutz
avatar joomla-cms-bot joomla-cms-bot - change - 27 Oct 2015
Labels Removed: ?
avatar zero-24 zero-24 - change - 28 Oct 2015
Milestone
avatar zero-24 zero-24 - change - 28 Oct 2015
Milestone Added:
avatar zero-24 zero-24 - change - 28 Oct 2015
Milestone Added:
avatar zero-24 zero-24 - change - 28 Oct 2015
Milestone

Add a Comment

Login with GitHub to post a comment