Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ PHP NEWS
. Fixed bugs GH-17711 and GH-18022 (Infinite recursion on deprecated attribute
evaluation) and GH-18464 (Recursion protection for deprecation constants not
released on bailout). (DanielEScherzer and ilutov)
. Fixed AST printing for immediately invoked Closure. (Dmitrii Derepko)

- Curl:
. Added curl_multi_get_handles(). (timwolla)
Expand Down Expand Up @@ -183,6 +184,8 @@ PHP NEWS
- SOAP:
. Fixed bug #49169 (SoapServer calls wrong function, although "SOAP action"
header is correct). (nielsdos)
. Fix namespace handling of WSDL and XML schema in SOAP,
fixing at least GH-16320 and bug #68576. (nielsdos)

- Sockets:
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.
Expand Down
6 changes: 2 additions & 4 deletions Zend/tests/arrow_functions/007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ zend.assertions=1
--FILE--
<?php

// TODO We're missing parentheses for the direct call

try {
assert((fn() => false)());
} catch (AssertionError $e) {
Expand All @@ -21,5 +19,5 @@ try {

?>
--EXPECT--
assert(): assert(fn() => false()) failed
assert(): assert(fn&(int ...$args): ?bool => $args[0](false)) failed
assert(): assert((fn() => false)()) failed
assert(): assert((fn&(int ...$args): ?bool => $args[0])(false)) failed
4 changes: 2 additions & 2 deletions Zend/tests/enum/ast-dumper.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {

?>
--EXPECT--
assert(function () {
assert((function () {
enum Foo {
case Bar;
}
Expand All @@ -45,4 +45,4 @@ assert(function () {
}

return false;
}())
})())
18 changes: 18 additions & 0 deletions Zend/tests/functions/007.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Pretty printing for arrow functions
--INI--
zend.assertions=1
--FILE--
<?php

try {
assert((function() { return false; })());
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}

?>
--EXPECT--
assert(): assert((function () {
return false;
})()) failed
4 changes: 2 additions & 2 deletions Zend/tests/match/009_ast_export.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ assert((function () {

?>
--EXPECTF--
assert(): assert(function () {
assert(): assert((function () {
match ('foo') {
'foo', 'bar' => false,
'baz' => 'a',
default => 'b',
};
}()) failed
})()) failed
12 changes: 10 additions & 2 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,12 +2424,20 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
smart_str_appends(str, "::$");
zend_ast_export_var(str, ast->child[1], 0, indent);
break;
case ZEND_AST_CALL:
zend_ast_export_ns_name(str, ast->child[0], 0, indent);
case ZEND_AST_CALL: {
zend_ast *left = ast->child[0];
if (left->kind == ZEND_AST_ARROW_FUNC || left->kind == ZEND_AST_CLOSURE) {
smart_str_appends(str, "(");
zend_ast_export_ns_name(str, left, 0, indent);
smart_str_appends(str, ")");
} else {
zend_ast_export_ns_name(str, left, 0, indent);
}
smart_str_appendc(str, '(');
zend_ast_export_ex(str, ast->child[1], 0, indent);
smart_str_appendc(str, ')');
break;
}
case ZEND_AST_PARENT_PROPERTY_HOOK_CALL:
smart_str_append(str, Z_STR_P(zend_ast_get_zval(ast->child[0])));
smart_str_appendc(str, '(');
Expand Down
8 changes: 7 additions & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3887,8 +3887,14 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
int rc;

c = PQgetCancel(pgsql);
/* PQcancel
* The return value of PQcancel is 1 if the cancel request was successfully dispatched and 0 if not.
* If not, errbuf is filled with an explanatory error message.
* errbuf must be a char array of size errbufsize (the recommended size is 256 bytes).
* https://www.postgresql.org/docs/current/libpq-cancel.html#LIBPQ-PQCANCEL
*/
RETVAL_LONG((rc = PQcancel(c, err, sizeof(err))));
if (rc < 0) {
if (rc == 0) {
zend_error(E_WARNING, "cannot cancel the query: %s", err);
}
while ((pgsql_result = PQgetResult(pgsql))) {
Expand Down
115 changes: 52 additions & 63 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,14 @@ static void set_ns_and_type(xmlNodePtr node, encodeTypePtr type);
return zval; \
} \
if (xml->properties) { \
null = get_attribute(xml->properties, "nil"); \
null = get_attribute_ex(xml->properties, "nil", XSI_NAMESPACE); \
if (null) { \
ZVAL_NULL(zval); \
return zval; \
} \
} \
}

#define CHECK_XML_NULL(xml) \
{ \
xmlAttrPtr null; \
if (!xml) { \
ZVAL_NULL(ret); \
return ret; \
} \
if (xml->properties) { \
null = get_attribute(xml->properties, "nil"); \
if (null) { \
ZVAL_NULL(ret); \
return ret; \
} \
} \
}

#define FIND_ZVAL_NULL(zval, xml, style) \
{ \
if (!zval || Z_TYPE_P(zval) == IS_NULL) { \
Expand Down Expand Up @@ -303,13 +287,7 @@ static bool soap_check_zval_ref(zval *data, xmlNodePtr node) {
return 0;
}
if (SOAP_GLOBAL(soap_version) == SOAP_1_1) {
while (1) {
attr = get_attribute(attr, "id");
if (attr == NULL || attr->ns == NULL) {
break;
}
attr = attr->next;
}
attr = get_attribute(attr, "id");
if (attr) {
id = (char*)attr->children->content;
smart_str_appendc(&prefix, '#');
Expand Down Expand Up @@ -1134,29 +1112,27 @@ static xmlNodePtr to_xml_double(encodeTypePtr type, zval *data, int style, xmlNo

static zval *to_zval_bool(zval *ret, encodeTypePtr type, xmlNodePtr data)
{
ZVAL_NULL(ret);
FIND_XML_NULL(data, ret);

if (data && data->children) {
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
whiteSpace_collapse(data->children->content);
if (stricmp((char*)data->children->content, "true") == 0 ||
stricmp((char*)data->children->content, "t") == 0 ||
strcmp((char*)data->children->content, "1") == 0) {
ZVAL_TRUE(ret);
} else if (stricmp((char*)data->children->content, "false") == 0 ||
stricmp((char*)data->children->content, "f") == 0 ||
strcmp((char*)data->children->content, "0") == 0) {
ZVAL_FALSE(ret);
} else {
ZVAL_STRING(ret, (char*)data->children->content);
convert_to_boolean(ret);
}
} else {
soap_error0(E_ERROR, "Encoding: Violation of encoding rules");
}
} else {
if (!data->children) {
ZVAL_NULL(ret);
return ret;
}
if (data->children->type != XML_TEXT_NODE || data->children->next != NULL) {
// TODO Convert to exception?
soap_error0(E_ERROR, "Encoding: Violation of encoding rules");
}

whiteSpace_collapse(data->children->content);
if (
data->children->content[0] == '\0' /* Check for empty string */
|| strcmp((const char*)data->children->content, "0") == 0
|| stricmp((const char*)data->children->content, "f") == 0
|| stricmp((const char*)data->children->content, "false") == 0
) {
ZVAL_FALSE(ret);
} else {
ZVAL_TRUE(ret);
}
return ret;
}
Expand Down Expand Up @@ -1480,7 +1456,7 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_LIST &&
sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_UNION) {

CHECK_XML_NULL(data);
FIND_XML_NULL(data, ret);
if (soap_check_xml_ref(ret, data)) {
return ret;
}
Expand Down Expand Up @@ -1548,7 +1524,7 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z

ZEND_HASH_FOREACH_PTR(sdlType->attributes, attr) {
if (attr->name) {
xmlAttrPtr val = get_attribute(data->properties, attr->name);
xmlAttrPtr val = get_attribute_any_ns(data->properties, attr->name);
char *str_val = NULL;

if (val && val->children && val->children->content) {
Expand Down Expand Up @@ -2503,6 +2479,26 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
return xmlParam;
}

static xmlAttrPtr get_soap_1_1_enc_attribute(xmlAttrPtr props, const char *name)
{
return get_attribute_ex(props, name, SOAP_1_1_ENC_NAMESPACE);
}

static xmlAttrPtr get_soap_1_2_enc_attribute(xmlAttrPtr props, const char *name)
{
return get_attribute_ex(props, name, SOAP_1_2_ENC_NAMESPACE);
}

/* Be forgiving for BC */
static xmlAttrPtr get_soap_enc_attribute(xmlAttrPtr props, const char *name)
{
xmlAttrPtr res = get_soap_1_1_enc_attribute(props, name);
if (!res) {
res = get_soap_1_2_enc_attribute(props, name);
}
return res;
}

static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
{
xmlNodePtr trav;
Expand All @@ -2519,7 +2515,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
FIND_XML_NULL(data, ret);

if (data &&
(attr = get_attribute(data->properties,"arrayType")) &&
(attr = get_soap_enc_attribute(data->properties,"arrayType")) &&
attr->children && attr->children->content) {
const char *type;
char *end, *ns;
Expand All @@ -2539,7 +2535,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
}
if (ns) {efree(ns);}

} else if ((attr = get_attribute(data->properties,"itemType")) &&
} else if ((attr = get_soap_enc_attribute(data->properties,"itemType")) &&
attr->children &&
attr->children->content) {
const char *type;
Expand All @@ -2553,7 +2549,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
}
if (ns) {efree(ns);}

if ((attr = get_attribute(data->properties,"arraySize")) &&
if ((attr = get_soap_enc_attribute(data->properties,"arraySize")) &&
attr->children && attr->children->content) {
dimension = calc_dimension_12((char*)attr->children->content);
dims = get_position_12(dimension, (char*)attr->children->content);
Expand All @@ -2562,7 +2558,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
*dims = 0;
}

} else if ((attr = get_attribute(data->properties,"arraySize")) &&
} else if ((attr = get_soap_enc_attribute(data->properties,"arraySize")) &&
attr->children && attr->children->content) {

dimension = calc_dimension_12((char*)attr->children->content);
Expand Down Expand Up @@ -2641,7 +2637,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
pos = safe_emalloc(sizeof(int), dimension, 0);
memset(pos,0,sizeof(int)*dimension);
if (data &&
(attr = get_attribute(data->properties,"offset")) &&
(attr = get_soap_enc_attribute(data->properties,"offset")) &&
attr->children && attr->children->content) {
char* tmp = strrchr((char*)attr->children->content,'[');

Expand All @@ -2657,7 +2653,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
if (trav->type == XML_ELEMENT_NODE) {
int i;
zval tmpVal, *ar;
xmlAttrPtr position = get_attribute(trav->properties,"position");
xmlAttrPtr position = get_soap_enc_attribute(trav->properties,"position");

ZVAL_NULL(&tmpVal);
master_to_zval(&tmpVal, enc, trav);
Expand Down Expand Up @@ -2872,9 +2868,9 @@ static zval *guess_zval_convert(zval *ret, encodeTypePtr type, xmlNodePtr data)
/* Logic: has children = IS_OBJECT else IS_STRING */
xmlNodePtr trav;

if (get_attribute(data->properties, "arrayType") ||
get_attribute(data->properties, "itemType") ||
get_attribute(data->properties, "arraySize")) {
if (get_soap_enc_attribute(data->properties, "arrayType") ||
get_soap_enc_attribute(data->properties, "itemType") ||
get_soap_enc_attribute(data->properties, "arraySize")) {
enc = get_conversion(SOAP_ENC_ARRAY);
} else {
enc = get_conversion(XSD_STRING);
Expand Down Expand Up @@ -3358,14 +3354,7 @@ xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style, xmlNo
static xmlNodePtr check_and_resolve_href(xmlNodePtr data)
{
if (data && data->properties) {
xmlAttrPtr href;

href = data->properties;
while (1) {
href = get_attribute(href, "href");
if (href == NULL || href->ns == NULL) {break;}
href = href->next;
}
xmlAttrPtr href = get_attribute(data->properties, "href");
if (href) {
/* Internal href try and find node */
if (href->children->content[0] == '#') {
Expand Down
2 changes: 1 addition & 1 deletion ext/soap/php_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define SOAP_1_2_ENC_NAMESPACE "http://www.w3.org/2003/05/soap-encoding"
#define SOAP_1_2_ENC_NS_PREFIX "enc"

#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema"
#define XSD_DRAFT_2000_NAMESPACE "http://www.w3.org/2000/10/XMLSchema"
#define XSD_NAMESPACE "http://www.w3.org/2001/XMLSchema"
#define XSD_NS_PREFIX "xsd"
#define XSI_NAMESPACE "http://www.w3.org/2001/XMLSchema-instance"
Expand Down
Loading