[PHP-CVS] com php-src: Make DatePeriod support DateTimeImmutable as well.: ext/date/php_date.c ext/date/php_date.h ext/date/tests/date_period-immutable.phpt

2012-12-20 Thread Derick Rethans
Commit:042ddf371e84fbb7ba1326e7bd45888e63fb30ef
Author:Derick Rethans git...@derickrethans.nl Thu, 20 Dec 2012 
13:22:18 +
Parents:   b1c68330161f7ccf4fdb4786ac1b0b28778d3f55
Branches:  immutable-date

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=042ddf371e84fbb7ba1326e7bd45888e63fb30ef

Log:
Make DatePeriod support DateTimeImmutable as well.

If the start element is a DateTimeImmutable object, then all returned objects
are also DateTimeImmutable objects. If the start element is a DateTime object,
then all returned objects are DateTime objects.

Changed paths:
  M  ext/date/php_date.c
  M  ext/date/php_date.h
  A  ext/date/tests/date_period-immutable.phpt


Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 08a473d..d60cc42 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1820,7 +1820,7 @@ static void 
date_period_it_current_data(zend_object_iterator *iter, zval ***data
 
/* Create new object */
MAKE_STD_ZVAL(iterator-current);
-   php_date_instantiate(date_ce_date, iterator-current TSRMLS_CC);
+   php_date_instantiate(object-start_ce, iterator-current TSRMLS_CC);
newdateobj = (php_date_obj *) 
zend_object_store_get_object(iterator-current TSRMLS_CC);
newdateobj-time = timelib_time_ctor();
*newdateobj-time = *it_time;
@@ -4151,6 +4151,7 @@ PHP_METHOD(DatePeriod, __construct)
if (dpobj-end) {
timelib_update_ts(dpobj-end, NULL);
}
+   dpobj-start_ce = date_ce_date;
} else {
/* init */
intobj  = (php_interval_obj *) 
zend_object_store_get_object(interval TSRMLS_CC);
@@ -4166,6 +4167,7 @@ PHP_METHOD(DatePeriod, __construct)
clone-tz_info = dateobj-time-tz_info;
}
dpobj-start = clone;
+   dpobj-start_ce = Z_OBJCE_P(start);
 
/* interval */
dpobj-interval = timelib_rel_time_clone(intobj-diff);
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index fb12dbc..8c4ca00 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -154,6 +154,7 @@ struct _php_interval_obj {
 struct _php_period_obj {
zend_object   std;
timelib_time *start;
+   zend_class_entry *start_ce;
timelib_time *current;
timelib_time *end;
timelib_rel_time *interval;
diff --git a/ext/date/tests/date_period-immutable.phpt 
b/ext/date/tests/date_period-immutable.phpt
new file mode 100644
index 000..0ec4b4a
--- /dev/null
+++ b/ext/date/tests/date_period-immutable.phpt
@@ -0,0 +1,56 @@
+--TEST--
+DatePeriod
+--FILE--
+?php
+date_default_timezone_set('UTC');
+$db1 = new DateTimeImmutable( '2008-01-01' );
+$db2 = new DateTime( '2008-01-01' );
+$de = new DateTime( '2008-03-31' );
+$di = DateInterval::createFromDateString( 'first day of next month' );
+
+foreach ( new DatePeriod( $db1, $di, $de ) as $dt )
+{
+   echo get_class( $dt ), \n;
+   echo $dt-format( l Y-m-d\n );
+echo $dt-modify( 3 tuesday )-format( l Y-m-d\n );
+   echo $dt-format( l Y-m-d\n\n );
+}
+
+foreach ( new DatePeriod( $db2, $di, $de ) as $dt )
+{
+   echo get_class( $dt ), \n;
+   echo $dt-format( l Y-m-d\n );
+echo $dt-modify( 3 tuesday )-format( l Y-m-d\n );
+   echo $dt-format( l Y-m-d\n\n );
+}
+?
+--EXPECT--
+DateTimeImmutable
+Tuesday 2008-01-01
+Tuesday 2008-01-15
+Tuesday 2008-01-01
+
+DateTimeImmutable
+Friday 2008-02-01
+Tuesday 2008-02-19
+Friday 2008-02-01
+
+DateTimeImmutable
+Saturday 2008-03-01
+Tuesday 2008-03-18
+Saturday 2008-03-01
+
+DateTime
+Tuesday 2008-01-01
+Tuesday 2008-01-15
+Tuesday 2008-01-15
+
+DateTime
+Friday 2008-02-01
+Tuesday 2008-02-19
+Tuesday 2008-02-19
+
+DateTime
+Saturday 2008-03-01
+Tuesday 2008-03-18
+Tuesday 2008-03-18


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Do not add a ref to EX(object) on generator clone: Zend/tests/generators/clone_after_object_call.phpt Zend/zend_generators.c

2012-12-20 Thread Nikita Popov
Commit:3e78c6ad25fdf07259bfaaa3e2e33fb0914e5e61
Author:Nikita Popov ni...@php.net Thu, 20 Dec 2012 20:33:18 +0100
Parents:   d5fe89670ee76baeb50664f5460991892ee77d8c
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=3e78c6ad25fdf07259bfaaa3e2e33fb0914e5e61

Log:
Do not add a ref to EX(object) on generator clone

If a ref has to be added it will be already added while walking the call
slots.

Changed paths:
  A  Zend/tests/generators/clone_after_object_call.phpt
  M  Zend/zend_generators.c


Diff:
diff --git a/Zend/tests/generators/clone_after_object_call.phpt 
b/Zend/tests/generators/clone_after_object_call.phpt
new file mode 100644
index 000..0a42426
--- /dev/null
+++ b/Zend/tests/generators/clone_after_object_call.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Cloning a generator after an object method was called
+--FILE--
+?php
+
+class A { public function b() { } }
+
+function gen() {
+$a = new A;
+$a-b();
+yield;
+}
+
+$g1 = gen();
+$g1-rewind();
+$g2 = clone $g1; 
+
+echo Done;
+--EXPECT--
+Done
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index d4254e0..a191741 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -223,6 +223,7 @@ static void zend_generator_clone_storage(zend_generator 
*orig, zend_generator **
/* copy */
clone-execute_data-opline = execute_data-opline;
clone-execute_data-function_state = 
execute_data-function_state;
+   clone-execute_data-object = execute_data-object;
clone-execute_data-current_scope = 
execute_data-current_scope;
clone-execute_data-current_called_scope = 
execute_data-current_called_scope;
clone-execute_data-fast_ret = execute_data-fast_ret;
@@ -326,11 +327,6 @@ static void zend_generator_clone_storage(zend_generator 
*orig, zend_generator **
clone-execute_data-current_this = 
execute_data-current_this;
Z_ADDREF_P(execute_data-current_this);
}
-
-   if (execute_data-object) {
-   clone-execute_data-object = execute_data-object;
-   Z_ADDREF_P(execute_data-object);
-   }
}
 
/* The value and key are known not to be references, so simply add refs 
*/


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: - Fixed typo on SKIPIF (causing make test to abort on some systems): tests/output/bug63377.phpt

2012-12-20 Thread Felipe Pena
Commit:56d9edbbb93a2a338211b2e7c05cf52347a963ce
Author:Felipe Pena felipe...@gmail.com Thu, 20 Dec 2012 22:35:05 
-0200
Parents:   c46e1cdcae70254cfc0b7d5781f2c71162a3734d
Branches:  PHP-5.3

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=56d9edbbb93a2a338211b2e7c05cf52347a963ce

Log:
- Fixed typo on SKIPIF (causing make test to abort on some systems)

Changed paths:
  M  tests/output/bug63377.phpt


Diff:
diff --git a/tests/output/bug63377.phpt b/tests/output/bug63377.phpt
index 82d4189..4757d4e 100644
--- a/tests/output/bug63377.phpt
+++ b/tests/output/bug63377.phpt
@@ -1,6 +1,6 @@
 --TEST--
 Bug #63377 (Segfault on output buffer  2GB)
---SKIPF--
+--SKIPIF--
 ?php
 if (PHP_INT_SIZE == 4) {
   die('skip Not for 32-bits OS');


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Merge branch 'PHP-5.5': Zend/zend_vm_def.h Zend/zend_vm_execute.h

2012-12-20 Thread Nikita Popov
Commit:4509016309402b58bd7228bb215537c7ae70c0dc
Author:Nikita Popov ni...@php.net Fri, 21 Dec 2012 01:58:29 +0100
Parents:   68730388ae9f76a4a168da8c5b5a52c36b5a 
ffb848b275a085917413c171a79cbfdb1d0159d2
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=4509016309402b58bd7228bb215537c7ae70c0dc

Log:
Merge branch 'PHP-5.5'

Changed paths:
  MM  Zend/zend_vm_def.h
  MM  Zend/zend_vm_execute.h


Diff:



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Fix bug #63822: Crash when using closures with ArrayAccess: NEWS Zend/zend_vm_def.h Zend/zend_vm_execute.h

2012-12-20 Thread Nikita Popov
Commit:ffb848b275a085917413c171a79cbfdb1d0159d2
Author:Nikita Popov ni...@php.net Fri, 21 Dec 2012 01:56:37 +0100
Parents:   3e78c6ad25fdf07259bfaaa3e2e33fb0914e5e61
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=ffb848b275a085917413c171a79cbfdb1d0159d2

Log:
Fix bug #63822: Crash when using closures with ArrayAccess

op_array-T was used after the closure's op_array was already freed. This just
swaps the freeing order.

Bugs:
https://bugs.php.net/63822

Changed paths:
  M  NEWS
  M  Zend/zend_vm_def.h
  M  Zend/zend_vm_execute.h


Diff:
diff --git a/NEWS b/NEWS
index d63858d..019513a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP 
   NEWS
 |||
 ?? ??? 201?, PHP 5.5.0 Alpha 3
 
+- General improvements:
+  . Fixed bug #63822 (Crash when using closures with ArrayAccess).
+(Nikita Popov)
 
 18 Dec 2012, PHP 5.5.0 Alpha 2
 
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index c933a48..2c17182 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -1843,7 +1843,7 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
 
 ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
 {
-   zend_bool nested;
+   zend_bool nested = EX(nested);
zend_op_array *op_array = EX(op_array);
 
EG(current_execute_data) = EX(prev_execute_data);
@@ -1852,14 +1852,12 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
i_free_compiled_variables(execute_data);
}
 
+   zend_vm_stack_free((char*)execute_data - 
(ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array-T) TSRMLS_CC);
+
if ((op_array-fn_flags  ZEND_ACC_CLOSURE)  op_array-prototype) {
zval_ptr_dtor((zval**)op_array-prototype);
}
 
-   nested = EX(nested);
-
-   zend_vm_stack_free((char*)execute_data - 
(ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array-T) TSRMLS_CC);
-
if (nested) {
execute_data = EG(current_execute_data);
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index dab0df3..c51df01 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -383,7 +383,7 @@ ZEND_API void zend_execute(zend_op_array *op_array 
TSRMLS_DC)
 
 static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
 {
-   zend_bool nested;
+   zend_bool nested = EX(nested);
zend_op_array *op_array = EX(op_array);
 
EG(current_execute_data) = EX(prev_execute_data);
@@ -392,14 +392,12 @@ static int ZEND_FASTCALL 
zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
i_free_compiled_variables(execute_data);
}
 
+   zend_vm_stack_free((char*)execute_data - 
(ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array-T) TSRMLS_CC);
+
if ((op_array-fn_flags  ZEND_ACC_CLOSURE)  op_array-prototype) {
zval_ptr_dtor((zval**)op_array-prototype);
}
 
-   nested = EX(nested);
-
-   zend_vm_stack_free((char*)execute_data - 
(ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array-T) TSRMLS_CC);
-
if (nested) {
execute_data = EG(current_execute_data);
}


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php