Skip to content

Commit 4997f81

Browse files
committed
opcache optimizer: optimize some more functions on compile time
- don't optimize basename(), version_compare(string, string, string)
1 parent f1e43b7 commit 4997f81

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,7 @@ static inline int ct_eval_func_call(
844844
|| zend_string_equals_literal(name, "urldecode")
845845
|| zend_string_equals_literal(name, "rawurlencode")
846846
|| zend_string_equals_literal(name, "rawurldecode")
847-
|| zend_string_equals_literal(name, "strtoupper")
848-
|| zend_string_equals_literal(name, "strtolower")
847+
|| zend_string_equals_literal(name, "php_uname")
849848
|| zend_string_equals_literal(name, "dirname")
850849
|| zend_string_equals_literal(name, "crc32")) {
851850
if (Z_TYPE_P(args[0]) != IS_STRING) {
@@ -872,7 +871,7 @@ static inline int ct_eval_func_call(
872871
} ZEND_HASH_FOREACH_END();
873872
/* pass */
874873
} else if (zend_string_equals_literal(name, "implode")
875-
|| zend_string_equals_literal(name, "array_unique")) {
874+
|| zend_string_equals_literal(name, "array_unique")) {
876875
zval *entry;
877876

878877
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
@@ -916,6 +915,11 @@ static inline int ct_eval_func_call(
916915
|| (Z_TYPE_P(args[1]) != IS_LONG)) {
917916
return FAILURE;
918917
}
918+
if (Z_LVAL_P(args[1]) < 1) {
919+
// levels must be >= 1, else we get a ValueError
920+
return FAILURE;
921+
}
922+
919923
/* pass */
920924
} else if (zend_string_equals_literal(name, "trim")
921925
|| zend_string_equals_literal(name, "rtrim")
@@ -1015,6 +1019,7 @@ static inline int ct_eval_func_call(
10151019
}
10161020
}
10171021
/* pass */
1022+
// todo: version_compare with 3 arguments got removed, as we should add a proper check for the comperator, else we hide a ValueError
10181023
} else if (zend_string_equals_literal(name, "str_replace")) {
10191024
if (Z_TYPE_P(args[0]) != IS_STRING
10201025
|| Z_TYPE_P(args[1]) != IS_STRING

0 commit comments

Comments
 (0)