Skip to content

Commit d59db90

Browse files
committed
Merge branch 'master' of https://git.php.net/repository/php-src
* 'master' of https://git.php.net/repository/php-src: Fix bug #64782: SplFileObject constructor make $context optional Prepare pdo_firebird for a pecl release also Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime Fix bug #65548: Comparison for DateTimeImmutable doesn't work
2 parents c10d8a4 + 64ee0cd commit d59db90

File tree

7 files changed

+92
-32
lines changed

7 files changed

+92
-32
lines changed

ext/date/php_date.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ const zend_function_entry date_funcs_immutable[] = {
480480
PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
481481
PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC)
482482
PHP_ME(DateTimeImmutable, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483-
PHP_ME_MAPPING(createFromFormat, date_create_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483+
PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
484484
PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
485485
PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0)
486486
PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0)
@@ -2142,27 +2142,21 @@ static zval* date_clone_immutable(zval *object TSRMLS_DC)
21422142

21432143
static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
21442144
{
2145-
if (Z_TYPE_P(d1) == IS_OBJECT && Z_TYPE_P(d2) == IS_OBJECT &&
2146-
instanceof_function(Z_OBJCE_P(d1), date_ce_date TSRMLS_CC) &&
2147-
instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) {
2148-
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
2149-
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
2145+
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
2146+
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
21502147

2151-
if (!o1->time || !o2->time) {
2152-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime object");
2153-
return 1;
2154-
}
2155-
if (!o1->time->sse_uptodate) {
2156-
timelib_update_ts(o1->time, o1->time->tz_info);
2157-
}
2158-
if (!o2->time->sse_uptodate) {
2159-
timelib_update_ts(o2->time, o2->time->tz_info);
2160-
}
2161-
2162-
return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
2148+
if (!o1->time || !o2->time) {
2149+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime or DateTimeImmutable object");
2150+
return 1;
2151+
}
2152+
if (!o1->time->sse_uptodate) {
2153+
timelib_update_ts(o1->time, o1->time->tz_info);
2154+
}
2155+
if (!o2->time->sse_uptodate) {
2156+
timelib_update_ts(o2->time, o2->time->tz_info);
21632157
}
21642158

2165-
return 1;
2159+
return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
21662160
}
21672161

21682162
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)

ext/date/tests/bug65502.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Test for bug #65502: DateTimeImmutable::createFromFormat returns DateTime
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
echo get_class(DateTimeImmutable::createFromFormat('j-M-Y', '12-Sep-2013'));
10+
?>
11+
--EXPECT--
12+
DateTimeImmutable

ext/date/tests/bug65548.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Test for bug #65548: Comparison for DateTimeImmutable doesn't work
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
$iToday = new DateTimeImmutable('today');
10+
$iTomorrow = new DateTimeImmutable('tomorrow');
11+
12+
$mToday = new DateTime('today');
13+
$mTomorrow = new DateTime('tomorrow');
14+
15+
var_dump($iToday < $iTomorrow);
16+
var_dump($iToday == $iTomorrow);
17+
var_dump($iToday > $iTomorrow);
18+
19+
var_dump($iToday == $mToday);
20+
var_dump($iToday === $mToday);
21+
22+
var_dump($iToday < $mTomorrow);
23+
var_dump($iToday == $mTomorrow);
24+
var_dump($iToday > $mTomorrow);
25+
?>
26+
--EXPECT--
27+
bool(true)
28+
bool(false)
29+
bool(false)
30+
bool(true)
31+
bool(false)
32+
bool(true)
33+
bool(false)
34+
bool(false)

ext/pdo_firebird/CREDITS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Firebird/InterBase driver for PDO
1+
Firebird driver for PDO
22
Ard Biesheuvel

ext/pdo_firebird/package2.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,27 @@ http://pear.php.net/dtd/package-2.0
55
http://pear.php.net/dtd/package-2.0.xsd">
66
<name>PDO_FIREBIRD</name>
77
<channel>pecl.php.net</channel>
8-
<summary>Firebird/InterBase 6 driver for PDO</summary>
9-
<description>This extension provides a Firebird/InterBase driver for PDO. It supports
10-
all versions of Firebird and InterBase versions 6 and up.
8+
<summary>Firebird driver for PDO</summary>
9+
<description>This extension provides a Firebird driver for PDO. It supports
10+
all versions of Firebird 2.1 and up.
1111
</description>
1212
<lead>
1313
<name>Ard Biesheuvel</name>
1414
<user>abies</user>
1515
<email>abies@php.net</email>
1616
<active>yes</active>
1717
</lead>
18-
<date>2006-05-01</date>
18+
<date>2013-09-01</date>
1919
<version>
20-
<release>0.3</release>
21-
<api>0.3</api>
20+
<release>1.0</release>
21+
<api>1.0</api>
2222
</version>
2323
<stability>
24-
<release>beta</release>
25-
<api>beta</api>
24+
<release>stable</release>
25+
<api>stable</api>
2626
</stability>
2727
<license uri="http://www.php.net/license">PHP</license>
28-
<notes>To compile and run this module, you will need to have the main PDO module and Firebird&apos;s
29-
or InterBase&apos;s client library installed on your system.
28+
<notes>To compile and run this module, you will need to have the main PDO module and Firebird&apos;s client library installed on your system.
3029
Hope it works!
3130
</notes>
3231
<contents>
@@ -49,7 +48,7 @@ Hope it works!
4948
<dependencies>
5049
<required>
5150
<php>
52-
<min>5.0.3</min>
51+
<min>5.3.27</min>
5352
</php>
5453
<pearinstaller>
5554
<min>1.4.0</min>

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ SPL_METHOD(SplFileObject, __construct)
22902290
intern->u.file.open_mode = NULL;
22912291
intern->u.file.open_mode_len = 0;
22922292

2293-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr",
2293+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr!",
22942294
&intern->file_name, &intern->file_name_len,
22952295
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
22962296
&use_include_path, &intern->u.file.zcontext) == FAILURE) {

ext/spl/tests/bug64782.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #64782: SplFileObject constructor make $context optional / give it a default value
3+
--FILE--
4+
<?php
5+
6+
var_dump(new SplFileObject(__FILE__, "r", false, null));
7+
8+
?>
9+
--EXPECTF--
10+
object(SplFileObject)#1 (%d) {
11+
["pathName":"SplFileInfo":private]=>
12+
string(50) "%s/bug64782.php"
13+
["fileName":"SplFileInfo":private]=>
14+
string(12) "bug64782.php"
15+
["openMode":"SplFileObject":private]=>
16+
string(1) "r"
17+
["delimiter":"SplFileObject":private]=>
18+
string(1) ","
19+
["enclosure":"SplFileObject":private]=>
20+
string(1) """
21+
}

0 commit comments

Comments
 (0)