return result;
}
-static int php_head_parse_cookie_options_array(zval *options, zend_long *expires, zend_string **path, zend_string **domain, zend_bool *secure, zend_bool *httponly, zend_string **samesite) {
+static void php_head_parse_cookie_options_array(zval *options, zend_long *expires, zend_string **path, zend_string **domain, zend_bool *secure, zend_bool *httponly, zend_string **samesite) {
int found = 0;
zend_string *key;
zval *value;
- if (*path) {
- *path = NULL;
- php_error_docref(NULL, E_WARNING, "Cannot pass arguments after the options array");
- return 0;
- }
-
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(options), key, value) {
if (key) {
if (zend_string_equals_literal_ci(key, "expires")) {
if (found == 0 && zend_hash_num_elements(Z_ARRVAL_P(options)) > 0) {
php_error_docref(NULL, E_WARNING, "No valid options were found in the given array");
}
-
- return 1;
}
/* {{{ proto bool setcookie(string name [, string value [, int expires [, string path [, string domain [, bool secure[, bool httponly]]]]]])
if (expires_or_options) {
if (Z_TYPE_P(expires_or_options) == IS_ARRAY) {
- if (!php_head_parse_cookie_options_array(expires_or_options, &expires, &path, &domain, &secure, &httponly, &samesite)) {
- RETVAL_FALSE;
- goto cleanup;
+ if (UNEXPECTED(ZEND_NUM_ARGS() > 3)) {
+ php_error_docref(NULL, E_WARNING, "Cannot pass arguments after the options array");
+ RETURN_FALSE;
}
+ php_head_parse_cookie_options_array(expires_or_options, &expires, &path, &domain, &secure, &httponly, &samesite);
} else {
expires = zval_get_long(expires_or_options);
}
RETVAL_FALSE;
}
-cleanup:
if (expires_or_options && Z_TYPE_P(expires_or_options) == IS_ARRAY) {
if (path) {
zend_string_release(path);
zval *expires_or_options = NULL;
zend_string *name, *value = NULL, *path = NULL, *domain = NULL, *samesite = NULL;
zend_long expires = 0;
- zend_bool secure = 0, httponly = 0, options_array = 0;
+ zend_bool secure = 0, httponly = 0;
ZEND_PARSE_PARAMETERS_START(1, 7)
Z_PARAM_STR(name)
if (expires_or_options) {
if (Z_TYPE_P(expires_or_options) == IS_ARRAY) {
- options_array = 1;
- if (!php_head_parse_cookie_options_array(expires_or_options, &expires, &path, &domain, &secure, &httponly, &samesite)) {
- RETVAL_FALSE;
- goto cleanup;
+ if (UNEXPECTED(ZEND_NUM_ARGS() > 3)) {
+ php_error_docref(NULL, E_WARNING, "Cannot pass arguments after the options array");
+ RETURN_FALSE;
}
+ php_head_parse_cookie_options_array(expires_or_options, &expires, &path, &domain, &secure, &httponly, &samesite);
} else {
expires = Z_LVAL_P(expires_or_options);
}
RETVAL_FALSE;
}
-cleanup:
- if (options_array) {
+ if (expires_or_options && Z_TYPE_P(expires_or_options) == IS_ARRAY) {
if (path) {
zend_string_release(path);
}