com php-src: Fixed wrongly const replacing on partial array: ext/opcache/Optimizer/sccp.c ext/opcache/tests/opt/sccp_0 23.phpt
| From: | Xinchen Hui | Date: | Fri, 05 Jan 2018 04:29:39 +0000 |
| Subject: | com php-src: Fixed wrongly const replacing on partial array: ext/opcache/Optimizer/sccp.c ext/opcache/tests/opt/sccp_0 23.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100798@lists.php.net to get a copy of this message | ||
Commit: 1db6c19365b3f40ebee5735fd9334f53e662398b
Author: Xinchen Hui <laruence@gmail.com> Fri, 5 Jan 2018 12:29:39 +0800
Parents: b09a3e52865cf553a58f97a5da81ec5aeb00cf0c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1db6c19365b3f40ebee5735fd9334f53e662398b
Log:
Fixed wrongly const replacing on partial array
Changed paths:
M ext/opcache/Optimizer/sccp.c
A ext/opcache/tests/opt/sccp_023.phpt
Diff:
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c
index 25b51b6..3c6c54b 100644
--- a/ext/opcache/Optimizer/sccp.c
+++ b/ext/opcache/Optimizer/sccp.c
@@ -1249,8 +1249,10 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
if (result) {
ZVAL_COPY_VALUE(&zv, result);
ZVAL_NULL(result);
- } else {
+ } else if (op1 && !IS_PARTIAL_ARRAY(op1)) {
array_init(&zv);
+ } else {
+ empty_partial_array(&zv);
}
if (op1) {
diff --git a/ext/opcache/tests/opt/sccp_023.phpt b/ext/opcache/tests/opt/sccp_023.phpt
new file mode 100644
index 0000000..edd0c39
--- /dev/null
+++ b/ext/opcache/tests/opt/sccp_023.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SCCP 023: ADD_ARRAY_ELEMENT with partial array
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=0
+opcache.opt_debug_level=0
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function a ($field_type, $allowed_values) {
+ $settings = [
+ 'list_string' => [
+ 'allowed_values' => $allowed_values,
+ ],
+ ];
+
+ return $settings[$field_type];
+}
+
+var_dump(a("list_string", ["xxx"]));
+?>
+--EXPECTF--
+array(1) {
+ ["allowed_values"]=>
+ array(1) {
+ [0]=>
+ string(3) "xxx"
+ }
+}