com php-src: Fixed double ZEND_TICKS opcode generation for declare(): Zend/tests/declare_005.phpt Zend/zend_compile.c

From: Date: Tue, 07 Jul 2015 12:56:05 +0000
Subject: com php-src: Fixed double ZEND_TICKS opcode generation for declare(): Zend/tests/declare_005.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87783@lists.php.net to get a copy of this message
Commit: c22da81b71abe8c41a94fdea4e95a2bca8ec926d Author: Julien Pauli <jpauli@php.net> Mon, 6 Jul 2015 15:46:48 +0200 Parents: 022068342b5da0b97be1b5f3bb7b018263bd6437 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c22da81b71abe8c41a94fdea4e95a2bca8ec926d Log: Fixed double ZEND_TICKS opcode generation for declare() Changed paths: A Zend/tests/declare_005.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/declare_005.phpt b/Zend/tests/declare_005.phpt new file mode 100644 index 0000000..8f5adcf --- /dev/null +++ b/Zend/tests/declare_005.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing declare statement with ticks +--SKIPIF-- +--FILE-- +<?php +register_tick_function(function () { echo "tick\n"; }); +function foo() { } + +declare(ticks=1) { + +$statement; +foo(); + +} +?> +--EXPECTF-- +tick +tick diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index d2f9fbc..278ac4e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6827,6 +6827,11 @@ void zend_do_extended_fcall_end(TSRMLS_D) /* {{{ */ void zend_do_ticks(TSRMLS_D) /* {{{ */ { + /* This prevents a double TICK generated by the parser statement of "declare()" */ + if (CG(active_op_array)->last && CG(active_op_array)->opcodes[CG(active_op_array)->last - 1].opcode == ZEND_TICKS) { + return; + } + zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_TICKS;

« previous php.cvs (#87783) next »