php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67179 On invalid datetime, $this not set in overloaded DateTime::__construct
Submitted: 2014-05-02 09:46 UTC Modified: 2014-06-07 09:03 UTC
From: arjen at react dot com Assigned: remi (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.0beta2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: arjen at react dot com
New email:
PHP Version: OS:

 

 [2014-05-02 09:46 UTC] arjen at react dot com
Description:
------------
See http://3v4l.org/aWPaq

Probably broken while fixing 66721 or 67118

I think the 5.3.0-5.3.5 behaviour is correct: $this exists but has no properties set.

Test script:
---------------
<?php

set_error_handler(function($errno, $errstr){ throw new Exception($errstr);});

class DateTimeCustom extends DateTime
{
	public function __construct($datetime, $timezone = null)
	{
		try
		{
			parent::__construct($datetime, $timezone);
		}
		catch (Exception $e)
		{
			var_dump($this);
		}
	}
}


$date = new DateTimeCustom('sunday 09 september 2001 103:46:40 CEST');

Expected result:
----------------
object(DateTimeCustom)#2 (0) {
}

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-07 09:03 UTC] remi@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: remi
 [2014-06-07 09:03 UTC] remi@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC