diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index fe801d2c1b299..16aaac93a706d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -558,8 +558,9 @@ jobs: cd "amphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit || EXIT_CODE=$? - echo "::endgroup::" + vendor/bin/phpunit + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" @@ -591,8 +592,9 @@ jobs: cd "reactphp-$repository" git rev-parse HEAD php /usr/bin/composer install --no-progress --ignore-platform-req=php+ - vendor/bin/phpunit || EXIT_CODE=$? - echo "::endgroup::" + vendor/bin/phpunit + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ $[EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" @@ -620,15 +622,16 @@ jobs: php /usr/bin/composer install --no-progress --ignore-platform-req=php+ php ./phpunit install # Test causes a heap-buffer-overflow but I cannot reproduce it locally... - php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "/** @group skip */\n public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);' + php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "#[\\PHPUnit\\Framework\\Attributes\\Group('"'"'skip'"'"')]\n public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);' # Buggy FFI test in Symfony, see https://github.com/symfony/symfony/issues/47668 - php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("public function testCastNonTrailingCharPointer()", "/** @group skip */\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);' + php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("public function testCastNonTrailingCharPointer()", "#[\\PHPUnit\\Framework\\Attributes\\Group('"'"'skip'"'"')]\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);' export SYMFONY_DEPRECATIONS_HELPER=max[total]=999 X=0 for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do echo "::group::$component" - php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip || EXIT_CODE=$? - echo "::endgroup::" + php ./phpunit $component --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group transient --exclude-group skip + EXIT_CODE=$? + echo -e "\n::endgroup::" if [ ${EXIT_CODE:-0} -gt 128 ]; then X=1; echo "Failed" diff --git a/.gitignore b/.gitignore index 1e92e88fb77fa..b76b5a787caa0 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,7 @@ config.h.in /sapi/cgi/php-cgi /sapi/fpm/php-fpm /sapi/phpdbg/phpdbg +/sapi/fuzzer/php-fuzz-* /scripts/php-config /scripts/phpize php diff --git a/Zend/tests/assert/expect_012.phpt b/Zend/tests/assert/expect_012.phpt index 71e2f96e629a4..77a5e48528473 100644 --- a/Zend/tests/assert/expect_012.phpt +++ b/Zend/tests/assert/expect_012.phpt @@ -5,12 +5,12 @@ zend.assertions=1 assert.exception=1 --FILE-- diff --git a/Zend/tests/oct_overflow.phpt b/Zend/tests/oct_overflow.phpt index 512a6abf6643a..b8ce3f40fde11 100644 --- a/Zend/tests/oct_overflow.phpt +++ b/Zend/tests/oct_overflow.phpt @@ -5,7 +5,7 @@ precision=14 --FILE-- -#include "ext/standard/dl.h" #include "php_ldap.h" #ifdef PHP_WIN32 @@ -278,7 +277,7 @@ static void php_ldap_zend_string_release_from_char_pointer(char *ptr) { } /* {{{ Parse controls from and to arrays */ -static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, int request) +static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, bool request) { array_init(array); @@ -292,10 +291,10 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_PASSWORDPOLICYRESPONSE) == 0) { int expire = 0, grace = 0, rc; LDAPPasswordPolicyError pperr; - zval value; rc = ldap_parse_passwordpolicy_control(ld, ctrl, &expire, &grace, &pperr); if ( rc == LDAP_SUCCESS ) { + zval value; array_init(&value); add_assoc_long(&value, "expire", expire); add_assoc_long(&value, "grace", grace); @@ -310,7 +309,6 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, } else if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_PAGEDRESULTS) == 0) { int lestimated, rc; struct berval lcookie = { 0L, NULL }; - zval value; if (ctrl->ldctl_value.bv_len) { /* ldap_parse_pageresponse_control() allocates lcookie.bv_val */ @@ -321,6 +319,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, } if ( rc == LDAP_SUCCESS ) { + zval value; array_init(&value); add_assoc_long(&value, "size", lestimated); add_assoc_stringl(&value, "cookie", lcookie.bv_val, lcookie.bv_len); @@ -348,7 +347,6 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, add_assoc_stringl(&value, "dn", bv.bv_val, bv.bv_len); while (ber_scanf(ber, "{m" /*}*/, &bv) != LBER_ERROR) { - int i; BerVarray vals = NULL; zval tmp; @@ -358,7 +356,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, } array_init(&tmp); - for (i = 0; vals[i].bv_val != NULL; i++) { + for (int i = 0; vals[i].bv_val != NULL; i++) { add_next_index_stringl(&tmp, vals[i].bv_val, vals[i].bv_len); } add_assoc_zval(&value, bv.bv_val, &tmp); @@ -372,7 +370,6 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, ber_free(ber, 1); } } else if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_SORTRESPONSE) == 0) { - zval value; int errcode, rc; char* attribute; @@ -382,6 +379,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, rc = -1; } if ( rc == LDAP_SUCCESS ) { + zval value; array_init(&value); add_assoc_long(&value, "errcode", errcode); if (attribute) { @@ -395,7 +393,6 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, } else if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_VLVRESPONSE) == 0) { int target, count, errcode, rc; struct berval *context; - zval value; if (ctrl->ldctl_value.bv_len) { rc = ldap_parse_vlvresponse_control(ld, ctrl, &target, &count, &context, &errcode); @@ -403,6 +400,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, rc = -1; } if ( rc == LDAP_SUCCESS ) { + zval value; array_init(&value); add_assoc_long(&value, "target", target); add_assoc_long(&value, "count", count); @@ -486,12 +484,11 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT } } else if (zend_string_equals_literal(control_oid, LDAP_CONTROL_ASSERT)) { zval* tmp; - zend_string* assert; if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "filter", sizeof("filter") - 1)) == NULL) { rc = -1; zend_value_error("%s(): Control must have a \"filter\" key", get_active_function_name()); } else { - assert = zval_get_string(tmp); + zend_string* assert = zval_get_string(tmp); if (EG(exception)) { rc = -1; goto failure; @@ -544,15 +541,14 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT rc = -1; php_error_docref(NULL, E_WARNING, "Failed to allocate control value"); } else { - int num_attribs, i; zval* attr; - num_attribs = zend_hash_num_elements(Z_ARRVAL_P(tmp)); + uint32_t num_attribs = zend_hash_num_elements(Z_ARRVAL_P(tmp)); ldap_attrs = safe_emalloc((num_attribs+1), sizeof(char *), 0); tmpstrings1 = safe_emalloc(num_attribs, sizeof(zend_string*), 0); num_tmpstrings1 = 0; - for (i = 0; ilink, msgid, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res); if (rc == -1) { php_error_docref(NULL, E_WARNING, "Bind operation failed"); @@ -1270,7 +1260,7 @@ PHP_FUNCTION(ldap_bind_ext) /* return a PHP control object */ object_init_ex(return_value, ldap_result_ce); - result = Z_LDAP_RESULT_P(return_value); + ldap_resultdata *result = Z_LDAP_RESULT_P(return_value); result->result = ldap_res; } @@ -1491,7 +1481,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) LDAPControl **lserverctrls = NULL; int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1; int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1; - int ret = 1, ldap_errno, argcount = ZEND_NUM_ARGS(); + bool has_errors = false; ZEND_PARSE_PARAMETERS_START(3, 9) Z_PARAM_ZVAL(link) @@ -1507,7 +1497,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ZEND_PARSE_PARAMETERS_END(); /* Reverse -> fall through */ - switch (argcount) { + switch (ZEND_NUM_ARGS()) { case 9: case 8: ldap_deref = deref; @@ -1546,13 +1536,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ZVAL_DEREF(attribute_zv); if (Z_TYPE_P(attribute_zv) != IS_STRING) { zend_argument_type_error(4, "must be a list of strings, %s given", zend_zval_value_name(attribute_zv)); - ret = 0; + has_errors = true; goto cleanup; } zend_string *attribute = Z_STR_P(attribute_zv); if (zend_str_has_nul_byte(attribute)) { zend_argument_value_error(4, "must not contain strings with any null bytes"); - ret = 0; + has_errors = true; goto cleanup; } ldap_attrs[attribute_index++] = ZSTR_VAL(attribute); @@ -1568,12 +1558,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) uint32_t num_links = zend_hash_num_elements(Z_ARRVAL_P(link)); if (num_links == 0) { zend_argument_must_not_be_empty_error(1); - ret = 0; + has_errors = true; goto cleanup; } if (!zend_array_is_list(Z_ARRVAL_P(link))) { zend_argument_value_error(1, "must be a list"); - ret = 0; + has_errors = true; goto cleanup; } @@ -1581,19 +1571,19 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) if (base_dn_ht) { if (!zend_array_is_list(base_dn_ht)) { zend_argument_value_error(2, "must be a list"); - ret = 0; + has_errors = true; goto cleanup; } num_base_dns = zend_hash_num_elements(base_dn_ht); if (num_base_dns != num_links) { zend_argument_value_error(2, "must be the same size as argument #1"); - ret = 0; + has_errors = true; goto cleanup; } } else { if (zend_str_has_nul_byte(base_dn_str)) { zend_argument_value_error(2, "must not contain null bytes"); - ret = 0; + has_errors = true; goto cleanup; } ldap_base_dn = base_dn_str; @@ -1603,19 +1593,19 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) if (filter_ht) { if (!zend_array_is_list(filter_ht)) { zend_argument_value_error(3, "must be a list"); - ret = 0; + has_errors = true; goto cleanup; } num_filters = zend_hash_num_elements(filter_ht); if (num_filters != num_links) { zend_argument_value_error(3, "must be the same size as argument #1"); - ret = 0; + has_errors = true; goto cleanup; } } else { if (zend_str_has_nul_byte(filter_str)) { zend_argument_value_error(3, "must not contain null bytes"); - ret = 0; + has_errors = true; goto cleanup; } ldap_filter = filter_str; @@ -1632,14 +1622,14 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ZVAL_DEREF(link_zv); if (Z_TYPE_P(link_zv) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(link_zv), ldap_link_ce)) { zend_argument_value_error(1, "must be a list of LDAP\\Connection"); - ret = 0; + has_errors = true; goto cleanup_parallel; } ldap_linkdata *current_ld = Z_LDAP_LINK_P(link_zv); if (!current_ld->link) { zend_throw_error(NULL, "LDAP connection has already been closed"); - ret = 0; + has_errors = true; goto cleanup_parallel; } @@ -1649,13 +1639,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ZVAL_DEREF(base_dn_zv); if (Z_TYPE_P(base_dn_zv) != IS_STRING) { zend_argument_type_error(2, "must be a list of strings, %s given", zend_zval_value_name(base_dn_zv)); - ret = 0; + has_errors = true; goto cleanup_parallel; } ldap_base_dn = Z_STR_P(base_dn_zv); if (zend_str_has_nul_byte(ldap_base_dn)) { zend_argument_value_error(2, "must not contain null bytes"); - ret = 0; + has_errors = true; goto cleanup_parallel; } } @@ -1665,13 +1655,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ZVAL_DEREF(filter_zv); if (Z_TYPE_P(filter_zv) != IS_STRING) { zend_argument_type_error(3, "must be a list of strings, %s given", zend_zval_value_name(filter_zv)); - ret = 0; + has_errors = true; goto cleanup_parallel; } ldap_filter = Z_STR_P(filter_zv); if (zend_str_has_nul_byte(ldap_filter)) { zend_argument_value_error(3, "must not contain null bytes"); - ret = 0; + has_errors = true; goto cleanup_parallel; } } @@ -1721,26 +1711,26 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ld = Z_LDAP_LINK_P(link); if (!ld->link) { zend_throw_error(NULL, "LDAP connection has already been closed"); - ret = 0; + has_errors = true; goto cleanup; } if (!base_dn_str) { zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance"); - ret = 0; + has_errors = true; goto cleanup; } if (!filter_str) { zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP\\Connection instance"); - ret = 0; + has_errors = true; goto cleanup; } if (server_controls_ht) { lserverctrls = php_ldap_controls_from_array(ld->link, server_controls_ht, 9); if (lserverctrls == NULL) { - ret = 0; + has_errors = true; goto cleanup; } } @@ -1748,7 +1738,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref); /* Run the actual search */ - ldap_errno = ldap_search_ext_s(ld->link, ZSTR_VAL(base_dn_str), scope, ZSTR_VAL(filter_str), ldap_attrs, ldap_attrsonly, lserverctrls, NULL, NULL, ldap_sizelimit, &ldap_res); + int ldap_errno = ldap_search_ext_s(ld->link, ZSTR_VAL(base_dn_str), scope, ZSTR_VAL(filter_str), ldap_attrs, ldap_attrsonly, lserverctrls, NULL, NULL, ldap_sizelimit, &ldap_res); if (ldap_errno != LDAP_SUCCESS && ldap_errno != LDAP_SIZELIMIT_EXCEEDED @@ -1765,7 +1755,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) ldap_msgfree(ldap_res); } php_error_docref(NULL, E_WARNING, "Search: %s", ldap_err2string(ldap_errno)); - ret = 0; + has_errors = true; } else { if (ldap_errno == LDAP_SIZELIMIT_EXCEEDED) { php_error_docref(NULL, E_WARNING, "Partial search results returned: Sizelimit exceeded"); @@ -1791,8 +1781,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) if (ldap_attrs != NULL) { efree(ldap_attrs); } - if (!ret) { - RETVAL_BOOL(ret); + if (has_errors) { + RETVAL_FALSE; } if (lserverctrls) { _php_ldap_controls_free(&lserverctrls); @@ -1866,7 +1856,6 @@ PHP_FUNCTION(ldap_first_entry) { zval *link, *result; ldap_linkdata *ld; - ldap_result_entry *resultentry; ldap_resultdata *ldap_result; LDAPMessage *entry; @@ -1884,7 +1873,7 @@ PHP_FUNCTION(ldap_first_entry) RETVAL_FALSE; } else { object_init_ex(return_value, ldap_result_entry_ce); - resultentry = Z_LDAP_RESULT_ENTRY_P(return_value); + ldap_result_entry *resultentry = Z_LDAP_RESULT_ENTRY_P(return_value); ZVAL_COPY(&resultentry->res, result); resultentry->data = entry; resultentry->ber = NULL; @@ -1897,7 +1886,7 @@ PHP_FUNCTION(ldap_next_entry) { zval *link, *result_entry; ldap_linkdata *ld; - ldap_result_entry *resultentry, *resultentry_next; + ldap_result_entry *resultentry; LDAPMessage *entry_next; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) { @@ -1913,7 +1902,7 @@ PHP_FUNCTION(ldap_next_entry) RETVAL_FALSE; } else { object_init_ex(return_value, ldap_result_entry_ce); - resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value); + ldap_result_entry *resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value); ZVAL_COPY(&resultentry_next->res, &resultentry->res); resultentry_next->data = entry_next; resultentry_next->ber = NULL; @@ -1927,14 +1916,10 @@ PHP_FUNCTION(ldap_get_entries) zval *link, *result; ldap_resultdata *ldap_result; LDAPMessage *ldap_result_entry; - zval tmp1, tmp2; ldap_linkdata *ld; LDAP *ldap; - int num_entries, num_attrib, num_values, i; + int num_entries; BerElement *ber; - char *attribute; - size_t attr_len; - struct berval **ldap_value; char *dn; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) { @@ -1965,23 +1950,25 @@ PHP_FUNCTION(ldap_get_entries) num_entries = 0; while (ldap_result_entry != NULL) { + zval tmp1; array_init(&tmp1); - num_attrib = 0; - attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber); + int num_attrib = 0; + char *attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber); while (attribute != NULL) { - ldap_value = ldap_get_values_len(ldap, ldap_result_entry, attribute); - num_values = ldap_count_values_len(ldap_value); + struct berval **ldap_value = ldap_get_values_len(ldap, ldap_result_entry, attribute); + int num_values = ldap_count_values_len(ldap_value); + zval tmp2; array_init(&tmp2); add_assoc_long(&tmp2, "count", num_values); - for (i = 0; i < num_values; i++) { + for (int i = 0; i < num_values; i++) { add_index_stringl(&tmp2, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len); } ldap_value_free_len(ldap_value); - attr_len = strlen(attribute); + size_t attr_len = strlen(attribute); zend_str_tolower(attribute, attr_len); zend_hash_str_update(Z_ARRVAL(tmp1), attribute, attr_len, &tmp2); add_index_string(&tmp1, num_attrib, attribute); @@ -2093,12 +2080,10 @@ PHP_FUNCTION(ldap_next_attribute) PHP_FUNCTION(ldap_get_attributes) { zval *link, *result_entry; - zval tmp; ldap_linkdata *ld; ldap_result_entry *resultentry; char *attribute; - struct berval **ldap_value; - int i, num_values, num_attrib; + int num_attrib; BerElement *ber; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) { @@ -2115,12 +2100,13 @@ PHP_FUNCTION(ldap_get_attributes) attribute = ldap_first_attribute(ld->link, resultentry->data, &ber); while (attribute != NULL) { - ldap_value = ldap_get_values_len(ld->link, resultentry->data, attribute); - num_values = ldap_count_values_len(ldap_value); + struct berval **ldap_value = ldap_get_values_len(ld->link, resultentry->data, attribute); + int num_values = ldap_count_values_len(ldap_value); + zval tmp; array_init(&tmp); add_assoc_long(&tmp, "count", num_values); - for (i = 0; i < num_values; i++) { + for (int i = 0; i < num_values; i++) { add_index_stringl(&tmp, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len); } ldap_value_free_len(ldap_value); @@ -2152,7 +2138,7 @@ PHP_FUNCTION(ldap_get_values_len) ldap_result_entry *resultentry; char *attr; struct berval **ldap_value_len; - int i, num_values; + int num_values; size_t attr_len; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOp", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce, &attr, &attr_len) != SUCCESS) { @@ -2172,7 +2158,7 @@ PHP_FUNCTION(ldap_get_values_len) num_values = ldap_count_values_len(ldap_value_len); array_init(return_value); - for (i=0; ibv_val, ldap_value_len[i]->bv_len); } @@ -2267,7 +2253,7 @@ PHP_FUNCTION(ldap_dn2ufn) /* added to fix use of ldap_modify_add for doing an ldap_add, gerrit thomson. */ #define PHP_LD_FULL_ADD 0xff /* {{{ php_ldap_do_modify */ -static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext) +static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, bool ext) { zval *link; ldap_linkdata *ld; @@ -2279,7 +2265,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext) ldap_resultdata *result; LDAPMessage *ldap_res; size_t dn_len; - int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */ + bool is_full_add = false; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oph/|h!", &link, ldap_link_ce, &dn, &dn_len, &attributes_ht, &server_controls_ht) != SUCCESS) { RETURN_THROWS(); @@ -2301,7 +2287,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext) /* added by gerrit thomson to fix ldap_add using ldap_mod_add */ if (oper == PHP_LD_FULL_ADD) { oper = LDAP_MOD_ADD; - is_full_add = 1; + is_full_add = true; } /* end additional , gerrit thomson */ @@ -2396,7 +2382,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext) /* check flag to see if do_mod was called to perform full add , gerrit thomson */ int ldap_status_code = LDAP_SUCCESS; int msgid; - if (is_full_add == 1) { + if (is_full_add) { if (ext) { ldap_status_code = ldap_add_ext(ld->link, dn, ldap_mods, lserverctrls, NULL, &msgid); } else { @@ -2469,14 +2455,14 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext) PHP_FUNCTION(ldap_add) { /* use a newly define parameter into the do_modify so ldap_mod_add can be used the way it is supposed to be used , Gerrit THomson */ - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD, 0); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD, false); } /* }}} */ /* {{{ Add entries to LDAP directory */ PHP_FUNCTION(ldap_add_ext) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD, 1); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LD_FULL_ADD, true); } /* }}} */ @@ -2485,54 +2471,52 @@ PHP_FUNCTION(ldap_add_ext) /* {{{ Replace attribute values with new ones */ PHP_FUNCTION(ldap_mod_replace) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, 0); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, false); } /* }}} */ /* {{{ Replace attribute values with new ones */ PHP_FUNCTION(ldap_mod_replace_ext) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, 1); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE, true); } /* }}} */ /* {{{ Add attribute values to current */ PHP_FUNCTION(ldap_mod_add) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD, 0); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD, false); } /* }}} */ /* {{{ Add attribute values to current */ PHP_FUNCTION(ldap_mod_add_ext) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD, 1); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_ADD, true); } /* }}} */ /* {{{ Delete attribute values */ PHP_FUNCTION(ldap_mod_del) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE, 0); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE, false); } /* }}} */ /* {{{ Delete attribute values */ PHP_FUNCTION(ldap_mod_del_ext) { - php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE, 1); + php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE, true); } /* }}} */ /* {{{ php_ldap_do_delete */ -static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext) +static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, bool ext) { zval *link; HashTable *server_controls_ht = NULL; ldap_linkdata *ld; LDAPControl **lserverctrls = NULL; - ldap_resultdata *result; - LDAPMessage *ldap_res; char *dn; int rc, msgid; size_t dn_len; @@ -2562,6 +2546,7 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext) RETVAL_FALSE; goto cleanup; } else if (ext) { + LDAPMessage *ldap_res; rc = ldap_result(ld->link, msgid, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res); if (rc == -1) { php_error_docref(NULL, E_WARNING, "Delete operation failed"); @@ -2571,7 +2556,7 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext) /* return a PHP control object */ object_init_ex(return_value, ldap_result_ce); - result = Z_LDAP_RESULT_P(return_value); + ldap_resultdata *result = Z_LDAP_RESULT_P(return_value); result->result = ldap_res; } else { RETVAL_TRUE; @@ -2589,14 +2574,14 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext) /* {{{ Delete an entry from a directory */ PHP_FUNCTION(ldap_delete) { - php_ldap_do_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_ldap_do_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } /* }}} */ /* {{{ Delete an entry from a directory */ PHP_FUNCTION(ldap_delete_ext) { - php_ldap_do_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); + php_ldap_do_delete(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } /* }}} */ @@ -3148,7 +3133,7 @@ PHP_FUNCTION(ldap_get_option) } RETURN_FALSE; } - _php_ldap_controls_to_array(ldap, ctrls, retval, 1); + _php_ldap_controls_to_array(ldap, ctrls, retval, true); } break; /* options not implemented case LDAP_OPT_API_INFO: @@ -3342,7 +3327,6 @@ PHP_FUNCTION(ldap_set_option) case LDAP_OPT_CLIENT_CONTROLS: { LDAPControl **ctrls; - int rc; if (Z_TYPE_P(newval) != IS_ARRAY) { zend_argument_type_error(3, "must be of type array for the LDAP_OPT_CLIENT_CONTROLS option, %s given", zend_zval_value_name(newval)); @@ -3354,7 +3338,7 @@ PHP_FUNCTION(ldap_set_option) if (ctrls == NULL) { RETURN_FALSE; } else { - rc = ldap_set_option(ldap, option, ctrls); + int rc = ldap_set_option(ldap, option, ctrls); _php_ldap_controls_free(&ctrls); if (rc != LDAP_SUCCESS) { RETURN_FALSE; @@ -3377,7 +3361,7 @@ PHP_FUNCTION(ldap_parse_result) ldap_linkdata *ld; ldap_resultdata *ldap_result; LDAPControl **lserverctrls = NULL; - char **lreferrals, **refp; + char **lreferrals; char *lmatcheddn, *lerrmsg; int rc, lerrcode; @@ -3405,7 +3389,7 @@ PHP_FUNCTION(ldap_parse_result) ZEND_TRY_ASSIGN_REF_LONG(errcode, lerrcode); if (serverctrls) { - _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0); + _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, false); } if (referrals) { referrals = zend_try_array_init(referrals); @@ -3413,7 +3397,7 @@ PHP_FUNCTION(ldap_parse_result) RETURN_THROWS(); } if (lreferrals != NULL) { - refp = lreferrals; + char **refp = lreferrals; while (*refp) { add_next_index_string(referrals, *refp); refp++; @@ -3526,7 +3510,6 @@ PHP_FUNCTION(ldap_first_reference) { zval *link, *result; ldap_linkdata *ld; - ldap_result_entry *resultentry; ldap_resultdata *ldap_result; LDAPMessage *entry; @@ -3544,7 +3527,7 @@ PHP_FUNCTION(ldap_first_reference) RETVAL_FALSE; } else { object_init_ex(return_value, ldap_result_entry_ce); - resultentry = Z_LDAP_RESULT_ENTRY_P(return_value); + ldap_result_entry *resultentry = Z_LDAP_RESULT_ENTRY_P(return_value); ZVAL_COPY(&resultentry->res, result); resultentry->data = entry; resultentry->ber = NULL; @@ -3557,7 +3540,7 @@ PHP_FUNCTION(ldap_next_reference) { zval *link, *result_entry; ldap_linkdata *ld; - ldap_result_entry *resultentry, *resultentry_next; + ldap_result_entry *resultentry; LDAPMessage *entry_next; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) { @@ -3573,7 +3556,7 @@ PHP_FUNCTION(ldap_next_reference) RETVAL_FALSE; } else { object_init_ex(return_value, ldap_result_entry_ce); - resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value); + ldap_result_entry *resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value); ZVAL_COPY(&resultentry_next->res, &resultentry->res); resultentry_next->data = entry_next; resultentry_next->ber = NULL; @@ -3588,7 +3571,7 @@ PHP_FUNCTION(ldap_parse_reference) zval *link, *result_entry, *referrals; ldap_linkdata *ld; ldap_result_entry *resultentry; - char **lreferrals, **refp; + char **lreferrals; if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOz", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce, &referrals) != SUCCESS) { RETURN_THROWS(); @@ -3609,7 +3592,7 @@ PHP_FUNCTION(ldap_parse_reference) } if (lreferrals != NULL) { - refp = lreferrals; + char **refp = lreferrals; while (*refp) { add_next_index_string(referrals, *refp); refp++; @@ -3622,12 +3605,11 @@ PHP_FUNCTION(ldap_parse_reference) #endif /* {{{ php_ldap_do_rename */ -static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext) +static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, bool ext) { zval *link; ldap_linkdata *ld; LDAPControl **lserverctrls = NULL; - ldap_resultdata *result; LDAPMessage *ldap_res; int rc, msgid; char *dn, *newrdn, *newparent; @@ -3689,7 +3671,7 @@ static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext) /* return a PHP control object */ object_init_ex(return_value, ldap_result_ce); - result = Z_LDAP_RESULT_P(return_value); + ldap_resultdata *result = Z_LDAP_RESULT_P(return_value); result->result = ldap_res; } else { RETVAL_TRUE; @@ -3707,14 +3689,14 @@ static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext) /* {{{ Modify the name of an entry */ PHP_FUNCTION(ldap_rename) { - php_ldap_do_rename(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_ldap_do_rename(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } /* }}} */ /* {{{ Modify the name of an entry */ PHP_FUNCTION(ldap_rename_ext) { - php_ldap_do_rename(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); + php_ldap_do_rename(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } /* }}} */ @@ -3817,7 +3799,7 @@ PHP_FUNCTION(ldap_start_tls) #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC) /* {{{ _ldap_rebind_proc() */ -int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params) +static int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params) { ldap_linkdata *ld = NULL; int retval; @@ -3938,7 +3920,7 @@ static zend_string* php_ldap_do_escape(const bool *map, const char *value, size_ return ret; } -static void php_ldap_escape_map_set_chars(bool *map, const char *chars, const size_t charslen, char escape) +static void php_ldap_escape_map_set_chars(bool *map, const char *chars, const size_t charslen, bool escape) { size_t i = 0; while (i < charslen) { @@ -3950,7 +3932,6 @@ PHP_FUNCTION(ldap_escape) { char *value, *ignores; size_t valuelen = 0, ignoreslen = 0; - int i; zend_long flags = 0; bool map[256] = {0}, havecharlist = 0; @@ -3964,22 +3945,22 @@ PHP_FUNCTION(ldap_escape) if (flags & PHP_LDAP_ESCAPE_FILTER) { havecharlist = 1; - php_ldap_escape_map_set_chars(map, "\\*()\0", sizeof("\\*()\0") - 1, 1); + php_ldap_escape_map_set_chars(map, "\\*()\0", sizeof("\\*()\0") - 1, true); } if (flags & PHP_LDAP_ESCAPE_DN) { havecharlist = 1; - php_ldap_escape_map_set_chars(map, "\\,=+<>;\"#\r", sizeof("\\,=+<>;\"#\r") - 1, 1); + php_ldap_escape_map_set_chars(map, "\\,=+<>;\"#\r", sizeof("\\,=+<>;\"#\r") - 1, true); } if (!havecharlist) { - for (i = 0; i < 256; i++) { + for (uint16_t i = 0; i < 256; i++) { map[i] = 1; } } if (ignoreslen) { - php_ldap_escape_map_set_chars(map, ignores, ignoreslen, 0); + php_ldap_escape_map_set_chars(map, ignores, ignoreslen, false); } zend_string *result = php_ldap_do_escape(map, value, valuelen, flags); @@ -4234,7 +4215,7 @@ PHP_FUNCTION(ldap_exop_passwd) } if (serverctrls) { - _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0); + _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, false); } /* return */ diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index a4e5d5d526a77..43f8bd3e17236 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -109,6 +109,7 @@ static zend_extension opcache_extension_entry; zend_accel_globals accel_globals; #else int accel_globals_id; +size_t accel_globals_offset; #endif /* Points to the structure shared across all PHP processes */ @@ -2841,39 +2842,12 @@ static void zps_startup_failure(const char *reason, const char *api_reason, int zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb); } -static inline zend_result accel_find_sapi(void) +/* Return whether we are running a CLI (Command LIne) SAPI for which Opcache is + * disabled when `opcache.enable_cli=0` */ +static inline bool accel_sapi_is_cli(void) { - static const char *supported_sapis[] = { - "apache", - "fastcgi", - "cli-server", - "cgi-fcgi", - "fpm-fcgi", - "fpmi-fcgi", - "apache2handler", - "litespeed", - "uwsgi", - "fuzzer", - "frankenphp", - "ngx-php", - NULL - }; - const char **sapi_name; - - if (sapi_module.name) { - for (sapi_name = supported_sapis; *sapi_name; sapi_name++) { - if (strcmp(sapi_module.name, *sapi_name) == 0) { - return SUCCESS; - } - } - if (ZCG(accel_directives).enable_cli && ( - strcmp(sapi_module.name, "cli") == 0 - || strcmp(sapi_module.name, "phpdbg") == 0)) { - return SUCCESS; - } - } - - return FAILURE; + return strcmp(sapi_module.name, "cli") == 0 + || strcmp(sapi_module.name, "phpdbg") == 0; } static zend_result zend_accel_init_shm(void) @@ -3162,7 +3136,7 @@ void start_accel_extension(void) static int accel_startup(zend_extension *extension) { #ifdef ZTS - accel_globals_id = ts_allocate_id(&accel_globals_id, sizeof(zend_accel_globals), (ts_allocate_ctor) accel_globals_ctor, (ts_allocate_dtor) accel_globals_dtor); + accel_globals_id = ts_allocate_fast_id(&accel_globals_id, &accel_globals_offset, sizeof(zend_accel_globals), (ts_allocate_ctor) accel_globals_ctor, (ts_allocate_dtor) accel_globals_dtor); #else accel_globals_ctor(&accel_globals); #endif @@ -3196,15 +3170,9 @@ static int accel_startup(zend_extension *extension) } #endif - /* no supported SAPI found - disable acceleration and stop initialization */ - if (accel_find_sapi() == FAILURE) { + if (!ZCG(accel_directives).enable_cli && accel_sapi_is_cli()) { accel_startup_ok = false; - if (!ZCG(accel_directives).enable_cli && - strcmp(sapi_module.name, "cli") == 0) { - zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb); - } else { - zps_startup_failure("Opcode Caching is only supported in Apache, FPM, FastCGI, FrankenPHP, LiteSpeed and uWSGI SAPIs", NULL, accelerator_remove_cb); - } + zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb); return SUCCESS; } @@ -4877,6 +4845,8 @@ static zend_result accel_finish_startup_preload(bool in_child) bool old_reset_signals = SIGG(reset); #endif + ZCG(preloading) = true; + sapi_module.activate = NULL; sapi_module.deactivate = NULL; sapi_module.register_server_variables = NULL; @@ -4958,6 +4928,8 @@ static zend_result accel_finish_startup_preload(bool in_child) sapi_module.ub_write = orig_ub_write; sapi_module.flush = orig_flush; + ZCG(preloading) = false; + sapi_activate(); return ret; diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index e103b7efee7e2..524a6f5e12139 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -220,6 +220,7 @@ typedef struct _zend_accel_globals { #endif void *preloaded_internal_run_time_cache; size_t preloaded_internal_run_time_cache_size; + bool preloading; /* preallocated shared-memory block to save current script */ void *mem; zend_persistent_script *current_persistent_script; @@ -300,8 +301,9 @@ extern zend_accel_shared_globals *accel_shared_globals; #define ZCSG(element) (accel_shared_globals->element) #ifdef ZTS -# define ZCG(v) ZEND_TSRMG(accel_globals_id, zend_accel_globals *, v) +# define ZCG(v) ZEND_TSRMG_FAST(accel_globals_offset, zend_accel_globals *, v) extern int accel_globals_id; +extern size_t accel_globals_offset; #else # define ZCG(v) (accel_globals.v) extern zend_accel_globals accel_globals; diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index e9ce51bbd227b..67df53d90d507 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -325,6 +325,7 @@ PHP_NEW_EXTENSION([opcache], m4_normalize([ shared_alloc_mmap.c shared_alloc_posix.c shared_alloc_shm.c + zend_accelerator_api.c zend_accelerator_blacklist.c zend_accelerator_debug.c zend_accelerator_hash.c @@ -361,3 +362,5 @@ AS_VAR_IF([PHP_OPCACHE_JIT], [yes], [ ]) PHP_ADD_MAKEFILE_FRAGMENT([$ext_srcdir/jit/Makefile.frag]) ]) + +PHP_INSTALL_HEADERS([ext/opcache], [zend_accelerator_api.h]) diff --git a/ext/opcache/config.w32 b/ext/opcache/config.w32 index 93c5319894bd9..9b8f2a7e5107a 100644 --- a/ext/opcache/config.w32 +++ b/ext/opcache/config.w32 @@ -4,6 +4,7 @@ PHP_OPCACHE="yes"; ZEND_EXTENSION('opcache', "\ ZendAccelerator.c \ + zend_accelerator_api.c \ zend_accelerator_blacklist.c \ zend_accelerator_debug.c \ zend_accelerator_hash.c \ @@ -68,3 +69,5 @@ if (PHP_OPCACHE_JIT == "yes") { } ADD_FLAG('CFLAGS_OPCACHE', "/I " + configure_module_dirname); + +PHP_INSTALL_HEADERS("ext/opcache", "zend_accelerator_api.h"); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index e743532a69337..5e3909a1ce239 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -48,6 +48,7 @@ #ifdef ZTS int jit_globals_id; +size_t jit_globals_offset; #else zend_jit_globals jit_globals; #endif @@ -3700,7 +3701,7 @@ int zend_jit_debug_config(zend_long old_val, zend_long new_val, int stage) void zend_jit_init(void) { #ifdef ZTS - jit_globals_id = ts_allocate_id(&jit_globals_id, sizeof(zend_jit_globals), (ts_allocate_ctor) zend_jit_globals_ctor, (ts_allocate_dtor) zend_jit_globals_dtor); + jit_globals_id = ts_allocate_fast_id(&jit_globals_id, &jit_globals_offset, sizeof(zend_jit_globals), (ts_allocate_ctor) zend_jit_globals_ctor, (ts_allocate_dtor) zend_jit_globals_dtor); #else zend_jit_globals_ctor(&jit_globals); #endif diff --git a/ext/opcache/jit/zend_jit.h b/ext/opcache/jit/zend_jit.h index 9178d340a0ede..5e6b225676aa2 100644 --- a/ext/opcache/jit/zend_jit.h +++ b/ext/opcache/jit/zend_jit.h @@ -145,8 +145,9 @@ typedef struct _zend_jit_globals { } zend_jit_globals; #ifdef ZTS -# define JIT_G(v) ZEND_TSRMG(jit_globals_id, zend_jit_globals *, v) +# define JIT_G(v) ZEND_TSRMG_FAST(jit_globals_offset, zend_jit_globals *, v) extern int jit_globals_id; +extern size_t jit_globals_offset; #else # define JIT_G(v) (jit_globals.v) extern zend_jit_globals jit_globals; diff --git a/ext/opcache/tests/api/opcache_preloading.inc b/ext/opcache/tests/api/opcache_preloading.inc new file mode 100644 index 0000000000000..0466028a3709b --- /dev/null +++ b/ext/opcache/tests/api/opcache_preloading.inc @@ -0,0 +1,3 @@ + diff --git a/ext/opcache/tests/api/opcache_preloading_001.phpt b/ext/opcache/tests/api/opcache_preloading_001.phpt new file mode 100644 index 0000000000000..4ecbc3b929d98 --- /dev/null +++ b/ext/opcache/tests/api/opcache_preloading_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +opcache_preloading() api 001 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.preload={PWD}/opcache_preloading.inc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%sopcache_preloading.inc: 1 +%sopcache_preloading_001.php: 0 diff --git a/ext/opcache/tests/api/opcache_preloading_002.phpt b/ext/opcache/tests/api/opcache_preloading_002.phpt new file mode 100644 index 0000000000000..a664b0d9233fa --- /dev/null +++ b/ext/opcache/tests/api/opcache_preloading_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +opcache_preloading() api 002 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.preload={PWD}/opcache_preloading.inc +opcache.preload_user={ENV:TEST_NON_ROOT_USER} +--EXTENSIONS-- +posix +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%sopcache_preloading.inc: 1 +%sopcache_preloading_002.php: 0 diff --git a/ext/opcache/zend_accelerator_api.c b/ext/opcache/zend_accelerator_api.c new file mode 100644 index 0000000000000..27267e8791ab3 --- /dev/null +++ b/ext/opcache/zend_accelerator_api.c @@ -0,0 +1,23 @@ +/* + +----------------------------------------------------------------------+ + | Zend OPcache | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ +*/ + +#include "zend_accelerator_api.h" +#include "ZendAccelerator.h" + +ZEND_API bool opcache_preloading(void) +{ + return ZCG(preloading); +} diff --git a/ext/opcache/zend_accelerator_api.h b/ext/opcache/zend_accelerator_api.h new file mode 100644 index 0000000000000..4ea42f29d174a --- /dev/null +++ b/ext/opcache/zend_accelerator_api.h @@ -0,0 +1,29 @@ +/* + +----------------------------------------------------------------------+ + | Zend OPcache | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ +*/ + +#ifndef ZEND_ACCELERATOR_API_H +#define ZEND_ACCELERATOR_API_H + +#include "Zend/zend_portability.h" + +BEGIN_EXTERN_C() + +/* Returns true during preloading */ +ZEND_API bool opcache_preloading(void); + +END_EXTERN_C() + +#endif /* ZEND_ACCELERATOR_API_H */ diff --git a/ext/pdo_mysql/tests/pdo_mysql_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_types.phpt index 462a542c24c17..7c7926a8cb9f2 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_types.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_types.phpt @@ -105,7 +105,7 @@ MySQLPDOTest::skip(); test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215'); test_type($db, 100, 'INT', -2147483648, - ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (double)-2147483648) : '-2147483648', + ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (float)-2147483648) : '-2147483648', NULL, ($is_mysqlnd) ? 'integer' : NULL); test_type($db, 110, 'INT UNSIGNED', 4294967295, ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? 4294967295 : '4294967295') : '4294967295'); diff --git a/ext/phar/shortarc.php b/ext/phar/shortarc.php index 2d0d37d0dcc56..0e88198a87a4f 100644 --- a/ext/phar/shortarc.php +++ b/ext/phar/shortarc.php @@ -114,15 +114,15 @@ static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); - $L = unpack('V', $a = (binary)fread($fp, 4)); - $m = (binary)''; + $L = unpack('V', $a = (string)fread($fp, 4)); + $m = ''; do { $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } - $last = (binary)fread($fp, $read); + $last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -268,7 +268,7 @@ static function extractFile($path, $entry, $fp) $entry[0] . ")"); } - if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) { + if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { die("Invalid internal .phar file (checksum error)"); } diff --git a/ext/phar/tests/cache_list/files/phar_test.inc b/ext/phar/tests/cache_list/files/phar_test.inc index bae9415aac4a3..b30b2f2fce39d 100644 --- a/ext/phar/tests/cache_list/files/phar_test.inc +++ b/ext/phar/tests/cache_list/files/phar_test.inc @@ -2,7 +2,7 @@ date_default_timezone_set('UTC'); -$manifest = (binary)''; +$manifest = ''; $glags = 0; foreach($files as $name => $cont) @@ -34,12 +34,12 @@ foreach($files as $name => $cont) if (empty($comp)) $comp = $cont; if (empty($ulen)) $ulen = strlen($cont); if (empty($clen)) $clen = strlen($comp); - if (empty($crc32))$crc32= crc32((binary)$cont); + if (empty($crc32))$crc32= crc32($cont); if (isset($meta)) $meta = serialize($meta); // write manifest entry - $manifest .= pack('V', strlen($name)) . (binary)$name; - $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta; + $manifest .= pack('V', strlen($name)) . $name; + $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta; // globals $gflags |= $flags; @@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio'; if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = ''; -$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest; -$file = (binary)$file; +$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest; +$file = $file; $file .= pack('V', strlen($manifest)) . $manifest; foreach($files as $cont) { - $file .= (binary)$cont; + $file .= $cont; } file_put_contents($fname, $file); diff --git a/ext/phar/tests/files/phar_oo_test.inc b/ext/phar/tests/files/phar_oo_test.inc index a6f4cee5ee657..b935346bc8efd 100644 --- a/ext/phar/tests/files/phar_oo_test.inc +++ b/ext/phar/tests/files/phar_oo_test.inc @@ -5,7 +5,7 @@ ini_set('date.timezone', 'GMT'); $tname = basename(current(get_included_files()), ".php"); $fname = dirname(__FILE__) . "/$tname.phar.php"; $pname = 'phar://' . $fname; -$file = (binary)''; +$file = ''; $files = array(); diff --git a/ext/phar/tests/files/phar_test.inc b/ext/phar/tests/files/phar_test.inc index 277271ef4c63b..caf220d0b37b8 100644 --- a/ext/phar/tests/files/phar_test.inc +++ b/ext/phar/tests/files/phar_test.inc @@ -2,7 +2,7 @@ date_default_timezone_set('UTC'); -$manifest = (binary)''; +$manifest = ''; $gflags = 0; foreach($files as $name => $cont) @@ -34,12 +34,12 @@ foreach($files as $name => $cont) if (empty($comp)) $comp = $cont; if (empty($ulen)) $ulen = strlen($cont); if (empty($clen)) $clen = strlen($comp); - if (empty($crc32))$crc32= crc32((binary)$cont); + if (empty($crc32))$crc32= crc32($cont); $meta = isset($meta) ? serialize($meta) : ""; // write manifest entry - $manifest .= pack('V', strlen($name)) . (binary)$name; - $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta; + $manifest .= pack('V', strlen($name)) . $name; + $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta; // globals $gflags |= $flags; @@ -50,13 +50,13 @@ if (!isset($alias)) $alias = 'hio'; if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = ''; -$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest; -$file = (binary)$file; +$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest; +$file = $file; $file .= pack('V', strlen($manifest)) . $manifest; foreach($files as $cont) { - $file .= (binary)$cont; + $file .= $cont; } file_put_contents($fname, $file); diff --git a/ext/phar/tests/tar/files/make.dangerous.tar.php.inc b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc index 641dda56f595f..ff9c20ccf9b7d 100644 --- a/ext/phar/tests/tar/files/make.dangerous.tar.php.inc +++ b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc @@ -108,16 +108,16 @@ class danger_tarmaker $checksum = pack('a8', sprintf('%6s ', decoct($checksum))); - fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512); + fwrite($this->tmp, $block . $checksum . $blockend, 512); if (is_resource($fileOrStream)) { stream_copy_to_stream($fileOrStream, $this->tmp); if ($stat['size'] % 512) { - fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512)); + fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512)); } } else { - fwrite($this->tmp, (binary)$fileOrStream); + fwrite($this->tmp, $fileOrStream); if (strlen($fileOrStream) % 512) { - fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512)); + fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512)); } } } diff --git a/ext/phar/tests/tar/files/make_invalid_tar.php.inc b/ext/phar/tests/tar/files/make_invalid_tar.php.inc index 2ccdf00201c02..cf9034bc30769 100644 --- a/ext/phar/tests/tar/files/make_invalid_tar.php.inc +++ b/ext/phar/tests/tar/files/make_invalid_tar.php.inc @@ -3,7 +3,7 @@ include dirname(__FILE__) . '/tarmaker.php.inc'; class corrupter extends tarmaker { function close() { - fwrite($this->tmp, (binary)'oopsie'); + fwrite($this->tmp, 'oopsie'); fclose($this->tmp); } } diff --git a/ext/phar/tests/tar/files/tarmaker.php.inc b/ext/phar/tests/tar/files/tarmaker.php.inc index 5860bf84d314f..ce0bd249b51df 100644 --- a/ext/phar/tests/tar/files/tarmaker.php.inc +++ b/ext/phar/tests/tar/files/tarmaker.php.inc @@ -107,16 +107,16 @@ class tarmaker $checksum = pack('a8', sprintf('%6s ', decoct($checksum))); - fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512); + fwrite($this->tmp, $block . $checksum . $blockend, 512); if (is_resource($fileOrStream)) { stream_copy_to_stream($fileOrStream, $this->tmp); if ($stat['size'] % 512) { - fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512)); + fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512)); } } else { - fwrite($this->tmp, (binary)$fileOrStream); + fwrite($this->tmp, $fileOrStream); if (strlen($fileOrStream) % 512) { - fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512)); + fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512)); } } } diff --git a/ext/simplexml/tests/033.phpt b/ext/simplexml/tests/033.phpt index 6fd52750ee0bd..6d681d7695ca4 100644 --- a/ext/simplexml/tests/033.phpt +++ b/ext/simplexml/tests/033.phpt @@ -25,8 +25,8 @@ var_dump((bool)$foo); var_dump((bool)$people); var_dump((int)$foo); var_dump((int)$people); -var_dump((double)$foo); -var_dump((double)$people); +var_dump((float)$foo); +var_dump((float)$people); var_dump((string)$foo); var_dump((string)$people); var_dump((array)$foo); diff --git a/ext/simplexml/tests/bug54973.phpt b/ext/simplexml/tests/bug54973.phpt index 5c9f6ffaca229..ad8a986ff5678 100644 --- a/ext/simplexml/tests/bug54973.phpt +++ b/ext/simplexml/tests/bug54973.phpt @@ -11,8 +11,8 @@ var_dump($xml->number); $int = $xml->number / 1024 / 1024 / 1024; var_dump($int); -$double = (double) $xml->number / 1024 / 1024 / 1024; -var_dump($double); +$float = (float) $xml->number / 1024 / 1024 / 1024; +var_dump($float); ?> --EXPECT-- object(SimpleXMLElement)#2 (1) { diff --git a/ext/spl/tests/recursive_tree_iterator_005.phpt b/ext/spl/tests/recursive_tree_iterator_005.phpt deleted file mode 100644 index a63b26685c561..0000000000000 --- a/ext/spl/tests/recursive_tree_iterator_005.phpt +++ /dev/null @@ -1,114 +0,0 @@ ---TEST-- -SPL: RecursiveTreeIterator and binary vs unicode (PHP 6.0+) ---INI-- -error_reporting=E_ALL&~E_NOTICE ---FILE-- - array( - (binary) "binary", - "abc2", - 1, - ), - (binary) "binary" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "4abc" => array( - 4, - "c", - ), - ), -); - -$it = new RecursiveTreeIterator(new RecursiveArrayIterator($ary), 0); -foreach($it as $k => $v) { - var_dump($v); -} -echo "\n----------------\n\n"; -foreach($it as $k => $v) { - var_dump($k); -} -echo "\n----------------\n\n"; -echo "key, getEntry, current:\n"; -foreach($it as $k => $v) { - var_dump($it->key(), $it->getEntry(), $it->current()); -} -?> ---EXPECT-- -string(7) "|-Array" -string(10) "| |-binary" -string(8) "| |-abc2" -string(5) "| \-1" -string(7) "\-Array" -string(5) " |-2" -string(5) " |-b" -string(9) " |-Array" -string(7) " | |-4" -string(7) " | \-c" -string(9) " \-Array" -string(7) " |-4" -string(7) " \-c" - ----------------- - -string(3) "|-0" -string(5) "| |-0" -string(5) "| |-1" -string(5) "| \-2" -string(8) "\-binary" -string(5) " |-0" -string(5) " |-1" -string(5) " |-3" -string(7) " | |-0" -string(7) " | \-1" -string(8) " \-4abc" -string(7) " |-0" -string(7) " \-1" - ----------------- - -key, getEntry, current: -string(3) "|-0" -string(5) "Array" -string(7) "|-Array" -string(5) "| |-0" -string(6) "binary" -string(10) "| |-binary" -string(5) "| |-1" -string(4) "abc2" -string(8) "| |-abc2" -string(5) "| \-2" -string(1) "1" -string(5) "| \-1" -string(8) "\-binary" -string(5) "Array" -string(7) "\-Array" -string(5) " |-0" -string(1) "2" -string(5) " |-2" -string(5) " |-1" -string(1) "b" -string(5) " |-b" -string(5) " |-3" -string(5) "Array" -string(9) " |-Array" -string(7) " | |-0" -string(1) "4" -string(7) " | |-4" -string(7) " | \-1" -string(1) "c" -string(7) " | \-c" -string(8) " \-4abc" -string(5) "Array" -string(9) " \-Array" -string(7) " |-0" -string(1) "4" -string(7) " |-4" -string(7) " \-1" -string(1) "c" -string(7) " \-c" diff --git a/ext/standard/tests/array/array_diff_assoc_variation1.phpt b/ext/standard/tests/array/array_diff_assoc_variation1.phpt deleted file mode 100644 index b16baa300f575..0000000000000 --- a/ext/standard/tests/array/array_diff_assoc_variation1.phpt +++ /dev/null @@ -1,179 +0,0 @@ ---TEST-- -Test array_diff_assoc() function : usage variations - unexpected values for 'array1' argument ---FILE-- -getMessage(), "\n"; - } - $iterator++; -}; -fclose($fp); -echo "Done"; -?> ---EXPECT-- -*** Testing array_diff_assoc() : usage variations *** - --- Iteration 1 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, int given - --- Iteration 2 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, int given - --- Iteration 3 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, int given - --- Iteration 4 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, int given - --- Iteration 5 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, float given - --- Iteration 6 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, float given - --- Iteration 7 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, float given - --- Iteration 8 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, float given - --- Iteration 9 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, float given - --- Iteration 10 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, null given - --- Iteration 11 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, null given - --- Iteration 12 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, true given - --- Iteration 13 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, false given - --- Iteration 14 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, true given - --- Iteration 15 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, false given - --- Iteration 16 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 17 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 18 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 19 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 20 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 21 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 22 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, string given - --- Iteration 23 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, classA given - --- Iteration 24 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, null given - --- Iteration 25 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, null given - --- Iteration 26 -- -array_diff_assoc(): Argument #1 ($array) must be of type array, resource given -Done diff --git a/ext/standard/tests/array/array_diff_assoc_variation2.phpt b/ext/standard/tests/array/array_diff_assoc_variation2.phpt deleted file mode 100644 index a0b1bac329d9a..0000000000000 --- a/ext/standard/tests/array/array_diff_assoc_variation2.phpt +++ /dev/null @@ -1,179 +0,0 @@ ---TEST-- -Test array_diff_assoc() function : usage variations - unexpected values for 'array1' argument ---FILE-- -getMessage(), "\n"; - } - $iterator++; -}; -fclose($fp); -echo "Done"; -?> ---EXPECT-- -*** Testing array_diff_assoc() : usage variations *** - --- Iteration 1 -- -array_diff_assoc(): Argument #2 must be of type array, int given - --- Iteration 2 -- -array_diff_assoc(): Argument #2 must be of type array, int given - --- Iteration 3 -- -array_diff_assoc(): Argument #2 must be of type array, int given - --- Iteration 4 -- -array_diff_assoc(): Argument #2 must be of type array, int given - --- Iteration 5 -- -array_diff_assoc(): Argument #2 must be of type array, float given - --- Iteration 6 -- -array_diff_assoc(): Argument #2 must be of type array, float given - --- Iteration 7 -- -array_diff_assoc(): Argument #2 must be of type array, float given - --- Iteration 8 -- -array_diff_assoc(): Argument #2 must be of type array, float given - --- Iteration 9 -- -array_diff_assoc(): Argument #2 must be of type array, float given - --- Iteration 10 -- -array_diff_assoc(): Argument #2 must be of type array, null given - --- Iteration 11 -- -array_diff_assoc(): Argument #2 must be of type array, null given - --- Iteration 12 -- -array_diff_assoc(): Argument #2 must be of type array, true given - --- Iteration 13 -- -array_diff_assoc(): Argument #2 must be of type array, false given - --- Iteration 14 -- -array_diff_assoc(): Argument #2 must be of type array, true given - --- Iteration 15 -- -array_diff_assoc(): Argument #2 must be of type array, false given - --- Iteration 16 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 17 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 18 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 19 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 20 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 21 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 22 -- -array_diff_assoc(): Argument #2 must be of type array, string given - --- Iteration 23 -- -array_diff_assoc(): Argument #2 must be of type array, classA given - --- Iteration 24 -- -array_diff_assoc(): Argument #2 must be of type array, null given - --- Iteration 25 -- -array_diff_assoc(): Argument #2 must be of type array, null given - --- Iteration 26 -- -array_diff_assoc(): Argument #2 must be of type array, resource given -Done diff --git a/ext/standard/tests/array/array_diff_assoc_variation3.phpt b/ext/standard/tests/array/array_diff_assoc_variation3.phpt index b32e484fd1903..4833725ffe4eb 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation3.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation3.phpt @@ -10,10 +10,6 @@ echo "\n*** Testing array_diff_assoc() : usage variations ***\n"; $array = array(1, 2, 3); -//get an unset variable -$unset_var = 10; -unset ($unset_var); - // get a class class classA { @@ -22,11 +18,6 @@ class classA } } -// heredoc string -$heredoc = << array( - NULL, null), // boolean data /*4*/ 'bool' => array( true, - false, - TRUE, - FALSE), + false), // empty data /*5*/ 'empty' => array( - "", ''), // string data /*6*/ 'string' => array( - "string", - 'string', - $heredoc), - - // binary data -/*7*/ -'binary' => array( - b"binary", - (binary)"binary"), + 'string'), // object data /*8*/ 'object' => array( new classA()), - - // undefined data -/*9*/ -'undefined' => array( - @$undefined_var), - - // unset data -/*10*/ -'unset' => array( - @$unset_var), ); // loop through each element of $inputs to check the behavior of array_diff_assoc @@ -135,65 +104,33 @@ array(5) { } -- Iteration 3 -- -array(2) { +array(1) { [0]=> NULL - [1]=> - NULL } -- Iteration 4 -- -array(3) { +array(1) { [1]=> bool(false) - [2]=> - bool(true) - [3]=> - bool(false) } -- Iteration 5 -- -array(2) { +array(1) { [0]=> string(0) "" - [1]=> - string(0) "" } -- Iteration 6 -- -array(3) { +array(1) { [0]=> string(6) "string" - [1]=> - string(6) "string" - [2]=> - string(11) "hello world" } -- Iteration 7 -- -array(2) { - [0]=> - string(6) "binary" - [1]=> - string(6) "binary" -} - --- Iteration 8 -- array(1) { [0]=> object(classA)#%d (0) { } } - --- Iteration 9 -- -array(1) { - [0]=> - NULL -} - --- Iteration 10 -- -array(1) { - [0]=> - NULL -} Done diff --git a/ext/standard/tests/array/array_diff_assoc_variation4.phpt b/ext/standard/tests/array/array_diff_assoc_variation4.phpt index 65b76dd9ebf90..794a367368eec 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation4.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation4.phpt @@ -11,15 +11,6 @@ echo "\n*** Testing array_diff_assoc() : usage variations ***\n"; $array = array(1, 2, 3); -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -// heredoc string -$heredoc = << 'positive', -2345 => 'negative'), - // null data -/*3*/ -'null' => array( - NULL => 'null 1', - null => 'null 2'), - - // boolean data -/*4*/ -'bool' => array( - true => 'boolt', - false => 'boolf', - TRUE => 'boolT', - FALSE => 'boolF'), - // empty data /*5*/ 'empty' => array( - "" => 'emptyd', - '' => 'emptys'), + '' => 'empty'), // string data /*6*/ 'string' => array( - "string" => 'stringd', - 'string' => 'strings', - $heredoc => 'stringh'), - - // binary data -/*7*/ -'binary' => array( - b"binary1" => 'binary 1', - (binary)"binary2" => 'binary 2'), - - // undefined data -/*8*/ -'undefined' => array( - @$undefined_var => 'undefined'), - - // unset data -/*9*/ -'unset' => array( - @$unset_var => 'unset'), + 'string' => 'strings'), ); @@ -104,48 +62,12 @@ array(4) { -- Iteration 2 -- array(1) { [""]=> - string(6) "null 2" + string(5) "empty" } -- Iteration 3 -- -array(2) { - [1]=> - string(5) "boolT" - [0]=> - string(5) "boolF" -} - --- Iteration 4 -- array(1) { - [""]=> - string(6) "emptys" -} - --- Iteration 5 -- -array(2) { ["string"]=> string(7) "strings" - ["hello world"]=> - string(7) "stringh" -} - --- Iteration 6 -- -array(2) { - ["binary1"]=> - string(8) "binary 1" - ["binary2"]=> - string(8) "binary 2" -} - --- Iteration 7 -- -array(1) { - [""]=> - string(9) "undefined" -} - --- Iteration 8 -- -array(1) { - [""]=> - string(5) "unset" } Done diff --git a/ext/standard/tests/array/array_diff_variation1.phpt b/ext/standard/tests/array/array_diff_variation1.phpt deleted file mode 100644 index 1031b6f947e0c..0000000000000 --- a/ext/standard/tests/array/array_diff_variation1.phpt +++ /dev/null @@ -1,154 +0,0 @@ ---TEST-- -Test array_diff() function : usage variations - unexpected values for 'array1' argument ---FILE-- -getMessage(), "\n"; - } - $iterator++; -}; - -fclose($fp); -echo "Done"; -?> ---EXPECT-- -*** Testing array_diff() : usage variations *** - --- Iteration 1 --array_diff(): Argument #1 ($array) must be of type array, int given - --- Iteration 2 --array_diff(): Argument #1 ($array) must be of type array, int given - --- Iteration 3 --array_diff(): Argument #1 ($array) must be of type array, int given - --- Iteration 4 --array_diff(): Argument #1 ($array) must be of type array, int given - --- Iteration 5 --array_diff(): Argument #1 ($array) must be of type array, float given - --- Iteration 6 --array_diff(): Argument #1 ($array) must be of type array, float given - --- Iteration 7 --array_diff(): Argument #1 ($array) must be of type array, float given - --- Iteration 8 --array_diff(): Argument #1 ($array) must be of type array, float given - --- Iteration 9 --array_diff(): Argument #1 ($array) must be of type array, float given - --- Iteration 10 --array_diff(): Argument #1 ($array) must be of type array, null given - --- Iteration 11 --array_diff(): Argument #1 ($array) must be of type array, null given - --- Iteration 12 --array_diff(): Argument #1 ($array) must be of type array, true given - --- Iteration 13 --array_diff(): Argument #1 ($array) must be of type array, false given - --- Iteration 14 --array_diff(): Argument #1 ($array) must be of type array, true given - --- Iteration 15 --array_diff(): Argument #1 ($array) must be of type array, false given - --- Iteration 16 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 17 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 18 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 19 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 20 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 21 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 22 --array_diff(): Argument #1 ($array) must be of type array, string given - --- Iteration 23 --array_diff(): Argument #1 ($array) must be of type array, classA given - --- Iteration 24 --array_diff(): Argument #1 ($array) must be of type array, null given - --- Iteration 25 --array_diff(): Argument #1 ($array) must be of type array, null given - --- Iteration 26 --array_diff(): Argument #1 ($array) must be of type array, resource given -Done diff --git a/ext/standard/tests/array/array_diff_variation2.phpt b/ext/standard/tests/array/array_diff_variation2.phpt deleted file mode 100644 index 2b03f22513695..0000000000000 --- a/ext/standard/tests/array/array_diff_variation2.phpt +++ /dev/null @@ -1,153 +0,0 @@ ---TEST-- -Test array_diff() function : usage variations - unexpected values for 'array2' argument ---FILE-- -getMessage(), "\n"; - } - $iterator++; -}; -fclose($fp); -echo "Done"; -?> ---EXPECT-- -*** Testing array_diff() : usage variations *** - --- Iteration 1 --array_diff(): Argument #2 must be of type array, int given - --- Iteration 2 --array_diff(): Argument #2 must be of type array, int given - --- Iteration 3 --array_diff(): Argument #2 must be of type array, int given - --- Iteration 4 --array_diff(): Argument #2 must be of type array, int given - --- Iteration 5 --array_diff(): Argument #2 must be of type array, float given - --- Iteration 6 --array_diff(): Argument #2 must be of type array, float given - --- Iteration 7 --array_diff(): Argument #2 must be of type array, float given - --- Iteration 8 --array_diff(): Argument #2 must be of type array, float given - --- Iteration 9 --array_diff(): Argument #2 must be of type array, float given - --- Iteration 10 --array_diff(): Argument #2 must be of type array, null given - --- Iteration 11 --array_diff(): Argument #2 must be of type array, null given - --- Iteration 12 --array_diff(): Argument #2 must be of type array, true given - --- Iteration 13 --array_diff(): Argument #2 must be of type array, false given - --- Iteration 14 --array_diff(): Argument #2 must be of type array, true given - --- Iteration 15 --array_diff(): Argument #2 must be of type array, false given - --- Iteration 16 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 17 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 18 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 19 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 20 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 21 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 22 --array_diff(): Argument #2 must be of type array, string given - --- Iteration 23 --array_diff(): Argument #2 must be of type array, classA given - --- Iteration 24 --array_diff(): Argument #2 must be of type array, null given - --- Iteration 25 --array_diff(): Argument #2 must be of type array, null given - --- Iteration 26 --array_diff(): Argument #2 must be of type array, resource given -Done diff --git a/ext/standard/tests/array/array_diff_variation3.phpt b/ext/standard/tests/array/array_diff_variation3.phpt index 37b295b0bd69c..649dcb5c92abb 100644 --- a/ext/standard/tests/array/array_diff_variation3.phpt +++ b/ext/standard/tests/array/array_diff_variation3.phpt @@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n"; // Initialise function arguments not being substituted (if any) $array = array(1, 2); -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -//get heredoc -$heredoc = << array( // null data - NULL, null), /*5*/ "boolean" => array( // boolean data true, - false, - TRUE, - FALSE), + false), /*6*/ -"empty" => array( - // empty data - "", - ''), +"empty" => array(''), /*7*/ -"string" => array( - // string data - "string", - 'string', - $heredoc), - -/*8*/ -"binary" => array( - // binary data - b"binary", - (binary)"binary"), - -/*9*/ -"undefined" => array( - // undefined data - @$undefined_var), - -/*10*/ -"unset" => array( - // unset data - @$unset_var) +"string" => array('string'), ); // loop through each element of the array for arr1 $iterator = 1; foreach($values as $value) { - echo "\n Iteration: $iterator \n"; + echo "Iteration: $iterator\n"; var_dump( array_diff($value, $array) ); $iterator++; }; @@ -99,12 +64,10 @@ echo "Done"; ?> --EXPECT-- *** Testing array_diff() : usage variations *** - - Iteration: 1 +Iteration: 1 array(0) { } - - Iteration: 2 +Iteration: 2 array(3) { [0]=> int(0) @@ -113,8 +76,7 @@ array(3) { [3]=> int(-2345) } - - Iteration: 3 +Iteration: 3 array(5) { [0]=> float(10.5) @@ -127,58 +89,24 @@ array(5) { [4]=> float(0.5) } - - Iteration: 4 -array(2) { +Iteration: 4 +array(1) { [0]=> NULL - [1]=> - NULL } - - Iteration: 5 -array(2) { +Iteration: 5 +array(1) { [1]=> bool(false) - [3]=> - bool(false) -} - - Iteration: 6 -array(2) { - [0]=> - string(0) "" - [1]=> - string(0) "" -} - - Iteration: 7 -array(3) { - [0]=> - string(6) "string" - [1]=> - string(6) "string" - [2]=> - string(17) "This is a heredoc" } - - Iteration: 8 -array(2) { - [0]=> - string(6) "binary" - [1]=> - string(6) "binary" -} - - Iteration: 9 +Iteration: 6 array(1) { [0]=> - NULL + string(0) "" } - - Iteration: 10 +Iteration: 7 array(1) { [0]=> - NULL + string(6) "string" } Done diff --git a/ext/standard/tests/array/array_diff_variation4.phpt b/ext/standard/tests/array/array_diff_variation4.phpt index 090f162bc7d9f..301280bcea510 100644 --- a/ext/standard/tests/array/array_diff_variation4.phpt +++ b/ext/standard/tests/array/array_diff_variation4.phpt @@ -12,15 +12,6 @@ echo "*** Testing array_diff() : usage variations ***\n"; // Initialise function arguments not being substituted (if any) $array = array(1, 2); -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -//get heredoc -$heredoc = << array( // null data - NULL, null), /*5*/ "boolean" => array( // boolean data true, - false, - TRUE, - FALSE), + false), /*6*/ "empty" => array( // empty data - "", ''), /*7*/ "string" => array( // string data - "string", - 'string', - $heredoc), - -/*8*/ -"binary" => array( - // binary data - b"binary", - (binary)"binary"), - -/*9*/ -"undefined" => array( - // undefined data - @$undefined_var), - -/*10*/ -"unset" => array( - // unset data - @$unset_var) + 'string'), ); // loop through each element of the array for $arr2 @@ -151,28 +120,4 @@ array(2) { [1]=> int(2) } - - Iteration: 8 -array(2) { - [0]=> - int(1) - [1]=> - int(2) -} - - Iteration: 9 -array(2) { - [0]=> - int(1) - [1]=> - int(2) -} - - Iteration: 10 -array(2) { - [0]=> - int(1) - [1]=> - int(2) -} Done diff --git a/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt b/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt index 7bb4c1be02c77..b0a28055893ab 100644 --- a/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt +++ b/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt @@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%'); $file_handle = popen("$sysroot/system32/sort", "w"); $newline = "\n"; foreach($arr as $str) { - fwrite($file_handle, (binary)$str); - fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline); + fwrite($file_handle, $str); + fwrite($file_handle, $newline); } pclose($file_handle); diff --git a/ext/standard/tests/file/popen_pclose_basic-win32.phpt b/ext/standard/tests/file/popen_pclose_basic-win32.phpt index 61f2fa302bf98..e5f155be32993 100644 --- a/ext/standard/tests/file/popen_pclose_basic-win32.phpt +++ b/ext/standard/tests/file/popen_pclose_basic-win32.phpt @@ -35,8 +35,8 @@ $sysroot = exec('echo %SYSTEMROOT%'); $file_handle = popen("$sysroot/system32/sort", "w"); $newline = "\n"; foreach($arr as $str) { - fwrite($file_handle, (binary)$str); - fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline); + fwrite($file_handle, $str); + fwrite($file_handle, $newline); } pclose($file_handle); diff --git a/ext/tidy/tests/025.phpt b/ext/tidy/tests/025.phpt index eda79a9885178..d641993491109 100644 --- a/ext/tidy/tests/025.phpt +++ b/ext/tidy/tests/025.phpt @@ -19,7 +19,7 @@ $n = $tidy->Root()->child[0]->child[1]->child[0]; var_dump($n->isComment()); var_dump((string)$n); var_dump((bool)$n); -var_dump((double)$n); +var_dump((float)$n); var_dump((int)$n); var_dump($tidy->Root()->child[0]->child[0]->hasSiblings()); diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index bbf9d68fb211c..255b0a7f99443 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -14,6 +14,8 @@ +----------------------------------------------------------------------+ */ +#include "ext/opcache/zend_accelerator_api.h" +#include "zend_API.h" #include "zend_modules.h" #include "zend_types.h" #ifdef HAVE_CONFIG_H @@ -1645,3 +1647,10 @@ static PHP_FUNCTION(zend_test_gh18756) zend_mm_gc(heap); zend_mm_shutdown(heap, true, false); } + +static PHP_FUNCTION(zend_test_opcache_preloading) +{ + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_BOOL(opcache_preloading()); +} diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 88ef73786cdc0..200ab22e79435 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -338,6 +338,8 @@ function zend_test_log_err_debug(string $str): void {} function zend_test_compile_to_ast(string $str): string {} function zend_test_gh18756(): void {} + + function zend_test_opcache_preloading(): bool {} } namespace ZendTestNS { diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index ac04ba209505e..bf3d626088f53 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 073039fa0d9c41eb842f6944eb4acfc9217103cf */ + * Stub hash: 781677c7ada9095af9c964cf86ce6ba63a52a930 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -185,6 +185,8 @@ ZEND_END_ARG_INFO() #define arginfo_zend_test_gh18756 arginfo_zend_test_void_return +#define arginfo_zend_test_opcache_preloading arginfo_zend_test_is_pcre_bundled + #define arginfo_ZendTestNS2_namespaced_func arginfo_zend_test_is_pcre_bundled #define arginfo_ZendTestNS2_namespaced_deprecated_func arginfo_zend_test_void_return @@ -325,6 +327,7 @@ static ZEND_FUNCTION(zend_test_is_zend_ptr); static ZEND_FUNCTION(zend_test_log_err_debug); static ZEND_FUNCTION(zend_test_compile_to_ast); static ZEND_FUNCTION(zend_test_gh18756); +static ZEND_FUNCTION(zend_test_opcache_preloading); static ZEND_FUNCTION(ZendTestNS2_namespaced_func); static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func); static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func); @@ -452,6 +455,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_test_log_err_debug, arginfo_zend_test_log_err_debug) ZEND_FE(zend_test_compile_to_ast, arginfo_zend_test_compile_to_ast) ZEND_FE(zend_test_gh18756, arginfo_zend_test_gh18756) + ZEND_FE(zend_test_opcache_preloading, arginfo_zend_test_opcache_preloading) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY(ZEND_NS_NAME("ZendTestNS2", "namespaced_func"), zif_ZendTestNS2_namespaced_func, arginfo_ZendTestNS2_namespaced_func, 0, NULL, NULL) #else diff --git a/main/main.c b/main/main.c index be03d9a70fda6..0736c2d736059 100644 --- a/main/main.c +++ b/main/main.c @@ -51,6 +51,8 @@ #include "ext/date/php_date.h" #include "ext/random/php_random_csprng.h" #include "ext/random/php_random_zend_utils.h" +#include "ext/opcache/ZendAccelerator.h" +#include "ext/opcache/jit/zend_jit.h" #include "php_variables.h" #include "ext/standard/credits.h" #ifdef PHP_WIN32 @@ -2803,7 +2805,9 @@ PHPAPI void php_reserve_tsrm_memory(void) TSRM_ALIGNED_SIZE(zend_mm_globals_size()) + TSRM_ALIGNED_SIZE(zend_gc_globals_size()) + TSRM_ALIGNED_SIZE(sizeof(php_core_globals)) + - TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct)) + TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct)) + + TSRM_ALIGNED_SIZE(sizeof(zend_accel_globals)) + + TSRM_ALIGNED_SIZE(sizeof(zend_jit_globals)) ); } /* }}} */