From 4fadf647d27118e34cc83fc98fcd4ead436c23cb Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 00:47:40 +0200 Subject: [PATCH 01/62] Refactor dom_nnodemap_objects_new() - Use ecalloc() to not miss initializing any field. - Merge declarations and assignments. --- ext/dom/php_dom.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index f2c1ec2c62b8b..b1f7eca80f104 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1603,26 +1603,10 @@ void dom_nnodemap_objects_free_storage(zend_object *object) /* {{{ */ zend_object *dom_nnodemap_objects_new(zend_class_entry *class_type) { - dom_object *intern; - dom_nnodemap_object *objmap; - - intern = dom_objects_set_class(class_type); - intern->ptr = emalloc(sizeof(dom_nnodemap_object)); - objmap = (dom_nnodemap_object *)intern->ptr; - ZVAL_UNDEF(&objmap->baseobj_zv); - objmap->baseobj = NULL; - objmap->nodetype = 0; - objmap->ht = NULL; - objmap->local = NULL; - objmap->local_lower = NULL; - objmap->release_local = false; - objmap->ns = NULL; - objmap->release_ns = false; - objmap->cache_tag.modification_nr = 0; + dom_object *intern = dom_objects_set_class(class_type); + intern->ptr = ecalloc(1, sizeof(dom_nnodemap_object)); + dom_nnodemap_object *objmap = intern->ptr; objmap->cached_length = -1; - objmap->cached_obj = NULL; - objmap->cached_obj_index = 0; - objmap->dict = NULL; return &intern->std; } From ff0a2cff05ca5319fcd1367245cbebbe65042ab4 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 15:37:45 +0200 Subject: [PATCH 02/62] Refactor implementation of DOM nodelists, named maps, and iterators The code was really messy with lots of checks and inconsistencies. This splits everything up into different functions and now everything is relayed to a handler vtable. --- ext/dom/config.m4 | 1 + ext/dom/config.w32 | 2 +- ext/dom/documenttype.c | 4 +- ext/dom/dom_iterators.c | 137 +----- ext/dom/element.c | 4 +- ext/dom/namednodemap.c | 126 +----- ext/dom/node.c | 4 +- ext/dom/nodelist.c | 163 +------ ext/dom/obj_map.c | 413 ++++++++++++++++++ ext/dom/obj_map.h | 39 ++ ext/dom/parentnode/css_selectors.c | 2 +- ext/dom/php_dom.c | 24 +- ext/dom/php_dom.h | 13 +- .../spec/Document_importLegacyNode.phpt | 6 +- .../modern/spec/NamedNodeMap_dimensions.phpt | 2 +- ext/dom/xpath.c | 2 +- 16 files changed, 521 insertions(+), 421 deletions(-) create mode 100644 ext/dom/obj_map.c create mode 100644 ext/dom/obj_map.h diff --git a/ext/dom/config.m4 b/ext/dom/config.m4 index 00934ceb55966..d51b1c2ac5202 100644 --- a/ext/dom/config.m4 +++ b/ext/dom/config.m4 @@ -33,6 +33,7 @@ if test "$PHP_DOM" != "no"; then node.c nodelist.c notation.c + obj_map.c parentnode/css_selectors.c parentnode/tree.c php_dom.c diff --git a/ext/dom/config.w32 b/ext/dom/config.w32 index d9e969a3845c4..2d8f3f3519c4a 100644 --- a/ext/dom/config.w32 +++ b/ext/dom/config.w32 @@ -15,7 +15,7 @@ if (PHP_DOM == "yes") { entity.c nodelist.c html_collection.c text.c comment.c \ entityreference.c \ token_list.c \ - notation.c xpath.c dom_iterators.c \ + notation.c obj_map.c xpath.c dom_iterators.c \ namednodemap.c xpath_callbacks.c", null, "/I ext/lexbor"); ADD_EXTENSION_DEP('dom', 'lexbor'); diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c index 32bf556295161..895a34cebf650 100644 --- a/ext/dom/documenttype.c +++ b/ext/dom/documenttype.c @@ -53,7 +53,7 @@ zend_result dom_documenttype_entities_read(dom_object *obj, zval *retval) xmlHashTable *entityht = (xmlHashTable *) dtdptr->entities; dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, XML_ENTITY_NODE, intern, entityht, NULL, NULL); + dom_namednode_iter(obj, intern, entityht, NULL, NULL, &php_dom_obj_map_entities); return SUCCESS; } @@ -74,7 +74,7 @@ zend_result dom_documenttype_notations_read(dom_object *obj, zval *retval) xmlHashTable *notationht = (xmlHashTable *) dtdptr->notations; dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, XML_NOTATION_NODE, intern, notationht, NULL, NULL); + dom_namednode_iter(obj, intern, notationht, NULL, NULL, &php_dom_obj_map_notations); return SUCCESS; } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index a0797967d1e76..19c4ea41adadb 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -68,7 +68,7 @@ xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const } /* }}} */ -static xmlNode *php_dom_libxml_hash_iter_ex(xmlHashTable *ht, int index) +xmlNodePtr php_dom_libxml_hash_iter(xmlHashTable *ht, int index) { int htsize; @@ -84,18 +84,6 @@ static xmlNode *php_dom_libxml_hash_iter_ex(xmlHashTable *ht, int index) } } -xmlNode *php_dom_libxml_hash_iter(dom_nnodemap_object *objmap, int index) -{ - xmlNode *curnode = php_dom_libxml_hash_iter_ex(objmap->ht, index); - - if (curnode != NULL && objmap->nodetype != XML_ENTITY_NODE) { - xmlNotation *notation = (xmlNotation *) curnode; - curnode = create_notation(notation->name, notation->PublicID, notation->SystemID); - } - - return curnode; -} - static void php_dom_iterator_dtor(zend_object_iterator *iter) /* {{{ */ { php_dom_iterator *iterator = (php_dom_iterator *)iter; @@ -109,7 +97,7 @@ static zend_result php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */ { php_dom_iterator *iterator = (php_dom_iterator *)iter; - if (Z_TYPE(iterator->curobj) != IS_UNDEF) { + if (!Z_ISNULL(iterator->curobj)) { return SUCCESS; } else { return FAILURE; @@ -120,7 +108,7 @@ static zend_result php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */ zval *php_dom_iterator_current_data(zend_object_iterator *iter) /* {{{ */ { php_dom_iterator *iterator = (php_dom_iterator *)iter; - return Z_ISUNDEF(iterator->curobj) ? NULL : &iterator->curobj; + return Z_ISNULL(iterator->curobj) ? NULL : &iterator->curobj; } /* }}} */ @@ -131,14 +119,14 @@ static void php_dom_iterator_current_key(zend_object_iterator *iter, zval *key) /* Only dtd named node maps, i.e. the ones based on a libxml hash table or attribute collections, * are keyed by the name because in that case the name is unique. */ - if (!objmap->ht && objmap->nodetype != XML_ATTRIBUTE_NODE) { + if (objmap->handler->nameless) { ZVAL_LONG(key, iterator->index); } else { dom_object *intern = Z_DOMOBJ_P(&iterator->curobj); - if (intern != NULL && intern->ptr != NULL) { + if (intern->ptr != NULL) { xmlNodePtr curnode = ((php_libxml_node_ptr *)intern->ptr)->node; - if (objmap->nodetype == XML_ATTRIBUTE_NODE && php_dom_follow_spec_intern(intern)) { + if (curnode->type == XML_ATTRIBUTE_NODE && php_dom_follow_spec_intern(intern)) { ZVAL_NEW_STR(key, dom_node_get_node_name_attribute_or_element(curnode, false)); } else { ZVAL_STRINGL(key, (const char *) curnode->name, xmlStrlen(curnode->name)); @@ -150,99 +138,36 @@ static void php_dom_iterator_current_key(zend_object_iterator *iter, zval *key) } /* }}} */ -static xmlNodePtr dom_fetch_first_iteration_item(dom_nnodemap_object *objmap) -{ - xmlNodePtr basep = dom_object_get_node(objmap->baseobj); - if (!basep) { - return NULL; - } - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - if (objmap->nodetype == XML_ATTRIBUTE_NODE) { - return (xmlNodePtr) basep->properties; - } else { - return dom_nodelist_iter_start_first_child(basep); - } - } else { - zend_long curindex = 0; - xmlNodePtr nodep = php_dom_first_child_of_container_node(basep); - return dom_get_elements_by_tag_name_ns_raw( - basep, nodep, objmap->ns, objmap->local, objmap->local_lower, &curindex, 0); - } -} - static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */ { - xmlNodePtr curnode = NULL; - php_dom_iterator *iterator = (php_dom_iterator *)iter; - if (Z_ISUNDEF(iterator->curobj)) { + if (Z_ISNULL(iterator->curobj)) { return; } iterator->index++; + zval garbage; + ZVAL_COPY_VALUE(&garbage, &iterator->curobj); + ZVAL_NULL(&iterator->curobj); dom_object *intern = Z_DOMOBJ_P(&iterator->curobj); dom_nnodemap_object *objmap = php_dom_iterator_get_nnmap(iterator); - if (intern != NULL && intern->ptr != NULL) { - if (objmap->nodetype != XML_ENTITY_NODE && - objmap->nodetype != XML_NOTATION_NODE) { - if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); - zval *entry = zend_hash_index_find(nodeht, iterator->index); - if (entry) { - zval_ptr_dtor(&iterator->curobj); - ZVAL_COPY(&iterator->curobj, entry); - return; - } - } else { - if (objmap->nodetype == XML_ATTRIBUTE_NODE || - objmap->nodetype == XML_ELEMENT_NODE) { - - /* Note: keep legacy behaviour for non-spec mode. */ - if (php_dom_follow_spec_intern(intern) && php_dom_is_cache_tag_stale_from_doc_ptr(&iterator->cache_tag, intern->document)) { - php_dom_mark_cache_tag_up_to_date_from_doc_ref(&iterator->cache_tag, intern->document); - curnode = dom_fetch_first_iteration_item(objmap); - zend_ulong index = 0; - while (curnode != NULL && index++ < iterator->index) { - curnode = curnode->next; - } - } else { - curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; - curnode = curnode->next; - } - } else { - /* The collection is live, we nav the tree from the base object if we cannot - * use the cache to restart from the last point. */ - xmlNodePtr basenode = dom_object_get_node(objmap->baseobj); - - /* We have a strong reference to the base node via baseobj_zv, this cannot become NULL */ - ZEND_ASSERT(basenode != NULL); - - zend_long previndex; - if (php_dom_is_cache_tag_stale_from_node(&iterator->cache_tag, basenode)) { - php_dom_mark_cache_tag_up_to_date_from_node(&iterator->cache_tag, basenode); - previndex = 0; - curnode = php_dom_first_child_of_container_node(basenode); - } else { - previndex = iterator->index - 1; - curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; - } - curnode = dom_get_elements_by_tag_name_ns_raw( - basenode, curnode, objmap->ns, objmap->local, objmap->local_lower, &previndex, iterator->index); - } + if (intern->ptr != NULL) { + /* Note: keep legacy behaviour for non-spec mode. */ + /* TODO: make this prettier */ + if (!php_dom_follow_spec_intern(intern) && (objmap->handler == &php_dom_obj_map_attributes || objmap->handler == &php_dom_obj_map_child_nodes)) { + xmlNodePtr curnode = ((php_libxml_node_ptr *) intern->ptr)->node; + curnode = curnode->next; + if (curnode) { + php_dom_create_object(curnode, &iterator->curobj, objmap->baseobj); } } else { - curnode = php_dom_libxml_hash_iter(objmap, iterator->index); + objmap->handler->get_item(objmap, (zend_long) iterator->index, &iterator->curobj); } } - zval_ptr_dtor(&iterator->curobj); - ZVAL_UNDEF(&iterator->curobj); - - if (curnode) { - php_dom_create_object(curnode, &iterator->curobj, objmap->baseobj); - } + zval_ptr_dtor(&garbage); } /* }}} */ @@ -261,7 +186,6 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i { dom_object *intern; dom_nnodemap_object *objmap; - xmlNodePtr curnode=NULL; php_dom_iterator *iterator; if (by_ref) { @@ -277,26 +201,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i intern = Z_DOMOBJ_P(object); objmap = (dom_nnodemap_object *)intern->ptr; - if (objmap != NULL) { - if (objmap->nodetype != XML_ENTITY_NODE && - objmap->nodetype != XML_NOTATION_NODE) { - if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); - zval *entry = zend_hash_index_find(nodeht, 0); - if (entry) { - ZVAL_COPY(&iterator->curobj, entry); - } - } else { - curnode = dom_fetch_first_iteration_item(objmap); - } - } else { - curnode = php_dom_libxml_hash_iter(objmap, 0); - } - } - - if (curnode) { - php_dom_create_object(curnode, &iterator->curobj, objmap->baseobj); - } + objmap->handler->get_item(objmap, 0, &iterator->curobj); return &iterator->intern; } diff --git a/ext/dom/element.c b/ext/dom/element.c index 4aa56f3691b2f..d0fc0b4a4d3e2 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -825,7 +825,7 @@ static void dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAMETERS, z object_init_ex(return_value, iter_ce); namednode = Z_DOMOBJ_P(return_value); - dom_namednode_iter(intern, 0, namednode, NULL, name, NULL); + dom_namednode_iter(intern, namednode, NULL, name, NULL, &php_dom_obj_map_by_tag_name); } PHP_METHOD(DOMElement, getElementsByTagName) @@ -1257,7 +1257,7 @@ static void dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAMETERS object_init_ex(return_value, iter_ce); namednode = Z_DOMOBJ_P(return_value); - dom_namednode_iter(intern, 0, namednode, NULL, name, uri); + dom_namednode_iter(intern, namednode, NULL, name, uri, &php_dom_obj_map_by_tag_name); } PHP_METHOD(DOMElement, getElementsByTagNameNS) diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c index 73f1f09e9dae8..2f8f6d10132c2 100644 --- a/ext/dom/namednodemap.c +++ b/ext/dom/namednodemap.c @@ -33,24 +33,12 @@ zend_long php_dom_get_namednodemap_length(dom_object *obj) { - dom_nnodemap_object *objmap = (dom_nnodemap_object *) obj->ptr; + dom_nnodemap_object *objmap = obj->ptr; if (!objmap) { return 0; } - if (objmap->nodetype == XML_NOTATION_NODE || objmap->nodetype == XML_ENTITY_NODE) { - return objmap->ht ? xmlHashSize(objmap->ht) : 0; - } - - zend_long count = 0; - xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - for (xmlAttrPtr curnode = nodep->properties; curnode; curnode = curnode->next) { - count++; - } - } - - return count; + return objmap->handler->length(objmap); } /* {{{ length int @@ -66,43 +54,9 @@ zend_result dom_namednodemap_length_read(dom_object *obj, zval *retval) /* }}} */ -xmlNodePtr php_dom_named_node_map_get_named_item(dom_nnodemap_object *objmap, const zend_string *named, bool may_transform) -{ - xmlNodePtr itemnode = NULL; - if (objmap != NULL) { - if ((objmap->nodetype == XML_NOTATION_NODE) || - objmap->nodetype == XML_ENTITY_NODE) { - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, BAD_CAST ZSTR_VAL(named)); - } else { - xmlNotationPtr notep = xmlHashLookup(objmap->ht, BAD_CAST ZSTR_VAL(named)); - if (notep) { - if (may_transform) { - itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID); - } else { - itemnode = (xmlNodePtr) notep; - } - } - } - } - } else { - xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - if (php_dom_follow_spec_intern(objmap->baseobj)) { - itemnode = (xmlNodePtr) php_dom_get_attribute_node(nodep, BAD_CAST ZSTR_VAL(named), ZSTR_LEN(named)); - } else { - itemnode = (xmlNodePtr) xmlHasProp(nodep, BAD_CAST ZSTR_VAL(named)); - } - } - } - } - return itemnode; -} - -void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, zval *return_value) +void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value) { - xmlNodePtr itemnode = php_dom_named_node_map_get_named_item(objmap, named, true); + xmlNodePtr itemnode = objmap->handler->get_named_item(objmap, named, ns); if (itemnode) { DOM_RET_OBJ(itemnode, objmap->baseobj); } else { @@ -122,45 +76,10 @@ PHP_METHOD(DOMNamedNodeMap, getNamedItem) } dom_nnodemap_object *objmap = Z_DOMOBJ_P(ZEND_THIS)->ptr; - php_dom_named_node_map_get_named_item_into_zval(objmap, named, return_value); + php_dom_named_node_map_get_named_item_into_zval(objmap, named, NULL, return_value); } /* }}} end dom_namednodemap_get_named_item */ -xmlNodePtr php_dom_named_node_map_get_item(dom_nnodemap_object *objmap, zend_long index) -{ - xmlNodePtr itemnode = NULL; - if (objmap != NULL) { - if ((objmap->nodetype == XML_NOTATION_NODE) || - objmap->nodetype == XML_ENTITY_NODE) { - if (objmap->ht) { - itemnode = php_dom_libxml_hash_iter(objmap, index); - } - } else { - xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - xmlNodePtr curnode = (xmlNodePtr)nodep->properties; - zend_long count = 0; - while (count < index && curnode != NULL) { - count++; - curnode = curnode->next; - } - itemnode = curnode; - } - } - } - return itemnode; -} - -void php_dom_named_node_map_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value) -{ - xmlNodePtr itemnode = php_dom_named_node_map_get_item(objmap, index); - if (itemnode) { - DOM_RET_OBJ(itemnode, objmap->baseobj); - } else { - RETURN_NULL(); - } -} - /* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-349467F9 Since: */ @@ -177,7 +96,7 @@ PHP_METHOD(DOMNamedNodeMap, item) dom_object *intern = Z_DOMOBJ_P(ZEND_THIS); dom_nnodemap_object *objmap = intern->ptr; - php_dom_named_node_map_get_item_into_zval(objmap, index, return_value); + objmap->handler->get_item(objmap, index, return_value); } /* }}} end dom_namednodemap_item */ @@ -186,16 +105,14 @@ Since: DOM Level 2 */ PHP_METHOD(DOMNamedNodeMap, getNamedItemNS) { - size_t namedlen=0, urilen=0; + size_t urilen=0; dom_object *intern; - xmlNodePtr itemnode = NULL; - char *uri, *named; + char *uri; + zend_string *named; dom_nnodemap_object *objmap; - xmlNodePtr nodep; - xmlNotation *notep = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &urilen, &named, &namedlen) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!S", &uri, &urilen, &named) == FAILURE) { RETURN_THROWS(); } @@ -204,28 +121,7 @@ PHP_METHOD(DOMNamedNodeMap, getNamedItemNS) objmap = (dom_nnodemap_object *)intern->ptr; if (objmap != NULL) { - if ((objmap->nodetype == XML_NOTATION_NODE) || - objmap->nodetype == XML_ENTITY_NODE) { - if (objmap->ht) { - if (objmap->nodetype == XML_ENTITY_NODE) { - itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, BAD_CAST named); - } else { - notep = (xmlNotation *)xmlHashLookup(objmap->ht, BAD_CAST named); - if (notep) { - itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID); - } - } - } - } else { - nodep = dom_object_get_node(objmap->baseobj); - if (nodep) { - itemnode = (xmlNodePtr)xmlHasNsProp(nodep, BAD_CAST named, BAD_CAST uri); - } - } - } - - if (itemnode) { - DOM_RET_OBJ(itemnode, objmap->baseobj); + php_dom_named_node_map_get_named_item_into_zval(objmap, named, uri, return_value); } } /* }}} end dom_namednodemap_get_named_item_ns */ diff --git a/ext/dom/node.c b/ext/dom/node.c index c9bf45e887db8..99069d778ebfe 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -288,7 +288,7 @@ zend_result dom_node_child_nodes_read(dom_object *obj, zval *retval) object_init_ex(retval, dom_get_nodelist_ce(php_dom_follow_spec_intern(obj))); dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL); + dom_namednode_iter(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_child_nodes); return SUCCESS; } @@ -422,7 +422,7 @@ zend_result dom_node_attributes_read(dom_object *obj, zval *retval) if (nodep->type == XML_ELEMENT_NODE) { object_init_ex(retval, dom_get_namednodemap_ce(php_dom_follow_spec_intern(obj))); dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, XML_ATTRIBUTE_NODE, intern, NULL, NULL, NULL); + dom_namednode_iter(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_attributes); } else { ZVAL_NULL(retval); } diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index 819b7396b69c7..46a10a362a071 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -32,24 +32,6 @@ * Since: */ -static zend_always_inline void objmap_cache_release_cached_obj(dom_nnodemap_object *objmap) -{ - if (objmap->cached_obj) { - /* Since the DOM is a tree there can be no cycles. */ - if (GC_DELREF(&objmap->cached_obj->std) == 0) { - zend_objects_store_del(&objmap->cached_obj->std); - } - objmap->cached_obj = NULL; - objmap->cached_obj_index = 0; - } -} - -static zend_always_inline void reset_objmap_cache(dom_nnodemap_object *objmap) -{ - objmap_cache_release_cached_obj(objmap); - objmap->cached_length = -1; -} - xmlNodePtr dom_nodelist_iter_start_first_child(xmlNodePtr nodep) { if (nodep->type == XML_ENTITY_REF_NODE) { @@ -60,60 +42,6 @@ xmlNodePtr dom_nodelist_iter_start_first_child(xmlNodePtr nodep) return nodep->children; } -zend_long php_dom_get_nodelist_length(dom_object *obj) -{ - dom_nnodemap_object *objmap = (dom_nnodemap_object *) obj->ptr; - if (!objmap) { - return 0; - } - - if (objmap->ht) { - return xmlHashSize(objmap->ht); - } - - if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); - return zend_hash_num_elements(nodeht); - } - - xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); - if (!nodep) { - return 0; - } - - if (!php_dom_is_cache_tag_stale_from_node(&objmap->cache_tag, nodep)) { - if (objmap->cached_length >= 0) { - return objmap->cached_length; - } - /* Only the length is out-of-date, the cache tag is still valid. - * Therefore, only overwrite the length and keep the currently cached object. */ - } else { - php_dom_mark_cache_tag_up_to_date_from_node(&objmap->cache_tag, nodep); - reset_objmap_cache(objmap); - } - - zend_long count = 0; - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - xmlNodePtr curnode = dom_nodelist_iter_start_first_child(nodep); - if (curnode) { - count++; - while (curnode->next != NULL) { - count++; - curnode = curnode->next; - } - } - } else { - xmlNodePtr basep = nodep; - nodep = php_dom_first_child_of_container_node(basep); - dom_get_elements_by_tag_name_ns_raw( - basep, nodep, objmap->ns, objmap->local, objmap->local_lower, &count, ZEND_LONG_MAX - 1 /* because of <= */); - } - - objmap->cached_length = count; - - return count; -} - /* {{{ length int readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-203510337 @@ -137,94 +65,11 @@ PHP_METHOD(DOMNodeList, count) void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value) { - xmlNodePtr itemnode = NULL; - bool cache_itemnode = false; - if (index >= 0) { - if (objmap != NULL) { - if (objmap->ht) { - itemnode = php_dom_libxml_hash_iter(objmap, index); - } else { - if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); - zval *entry = zend_hash_index_find(nodeht, index); - if (entry) { - ZVAL_COPY(return_value, entry); - return; - } - } else if (objmap->baseobj) { - xmlNodePtr basep = dom_object_get_node(objmap->baseobj); - if (basep) { - xmlNodePtr nodep = basep; - /* For now we're only able to use cache for forward search. - * TODO: in the future we could extend the logic of the node list such that backwards searches - * are also possible. */ - bool restart = true; - zend_long relative_index = index; - if (index >= objmap->cached_obj_index && objmap->cached_obj && !php_dom_is_cache_tag_stale_from_node(&objmap->cache_tag, nodep)) { - xmlNodePtr cached_obj_xml_node = dom_object_get_node(objmap->cached_obj); - - /* The node cannot be NULL if the cache is valid. If it is NULL, then it means we - * forgot an invalidation somewhere. Take the defensive programming approach and invalidate - * it here if it's NULL (except in debug mode where we would want to catch this). */ - if (UNEXPECTED(cached_obj_xml_node == NULL)) { -#if ZEND_DEBUG - ZEND_UNREACHABLE(); -#endif - reset_objmap_cache(objmap); - } else { - restart = false; - relative_index -= objmap->cached_obj_index; - nodep = cached_obj_xml_node; - } - } - zend_long count = 0; - if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - if (restart) { - nodep = dom_nodelist_iter_start_first_child(nodep); - } - while (count < relative_index && nodep != NULL) { - count++; - nodep = nodep->next; - } - itemnode = nodep; - } else { - if (restart) { - nodep = php_dom_first_child_of_container_node(basep); - } - itemnode = dom_get_elements_by_tag_name_ns_raw(basep, nodep, objmap->ns, objmap->local, objmap->local_lower, &count, relative_index); - } - cache_itemnode = true; - } - } - } - } - - if (itemnode) { - DOM_RET_OBJ(itemnode, objmap->baseobj); - if (cache_itemnode) { - /* Hold additional reference for the cache, must happen before releasing the cache - * because we might be the last reference holder. - * Instead of storing and copying zvals, we store the object pointer directly. - * This saves us some bytes because a pointer is smaller than a zval. - * This also means we have to manually refcount the objects here, and remove the reference count - * in reset_objmap_cache() and the destructor. */ - dom_object *cached_obj = Z_DOMOBJ_P(return_value); - GC_ADDREF(&cached_obj->std); - /* If the tag is stale, all cached data is useless. Otherwise only the cached object is useless. */ - if (php_dom_is_cache_tag_stale_from_node(&objmap->cache_tag, itemnode)) { - php_dom_mark_cache_tag_up_to_date_from_node(&objmap->cache_tag, itemnode); - reset_objmap_cache(objmap); - } else { - objmap_cache_release_cached_obj(objmap); - } - objmap->cached_obj_index = index; - objmap->cached_obj = cached_obj; - } - return; - } + if (EXPECTED(objmap)) { + objmap->handler->get_item(objmap, index, return_value); + } else { + RETURN_NULL(); } - - RETVAL_NULL(); } /* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-844377136 diff --git a/ext/dom/obj_map.c b/ext/dom/obj_map.c new file mode 100644 index 0000000000000..f2a93fe3ef870 --- /dev/null +++ b/ext/dom/obj_map.c @@ -0,0 +1,413 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + | Authors: Christian Stocker | + | Rob Richards | + | Niels Dossche | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "php.h" +#if defined(HAVE_LIBXML) && defined(HAVE_DOM) +#include "php_dom.h" +#include "obj_map.h" + +static zend_always_inline void objmap_cache_release_cached_obj(dom_nnodemap_object *objmap) +{ + if (objmap->cached_obj) { + /* Since the DOM is a tree there can be no cycles. */ + if (GC_DELREF(&objmap->cached_obj->std) == 0) { + zend_objects_store_del(&objmap->cached_obj->std); + } + objmap->cached_obj = NULL; + objmap->cached_obj_index = 0; + } +} + +static zend_always_inline void reset_objmap_cache(dom_nnodemap_object *objmap) +{ + objmap_cache_release_cached_obj(objmap); + objmap->cached_length = -1; +} + +/************************** + * === Length methods === * + **************************/ + +static zend_long dom_map_get_xmlht_length(dom_nnodemap_object *map) +{ + /* Note: if there are, for example, no entities or notations then the hash table can be NULL. */ + return map->ht ? xmlHashSize(map->ht) : 0; +} + +static zend_long dom_map_get_nodeset_length(dom_nnodemap_object *map) +{ + HashTable *nodeht = Z_ARRVAL(map->baseobj_zv); + return zend_hash_num_elements(nodeht); +} + +static zend_long dom_map_get_prop_length(dom_nnodemap_object *map) +{ + zend_long count = 0; + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + if (nodep) { + for (xmlAttrPtr curnode = nodep->properties; curnode; curnode = curnode->next) { + count++; + } + } + return count; +} + +static zend_long dom_map_get_nodes_length(dom_nnodemap_object *map) +{ + zend_long count = 0; + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + if (nodep) { + for (xmlNodePtr curnode = dom_nodelist_iter_start_first_child(nodep); curnode; curnode = curnode->next) { + count++; + } + } + return count; +} + +static zend_long dom_map_get_by_tag_name_length(dom_nnodemap_object *map) +{ + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + zend_long count = 0; + if (nodep) { + xmlNodePtr basep = nodep; + nodep = php_dom_first_child_of_container_node(basep); + dom_get_elements_by_tag_name_ns_raw( + basep, nodep, map->ns, map->local, map->local_lower, &count, ZEND_LONG_MAX - 1 /* because of <= */); + } + return count; +} + +static zend_long dom_map_get_zero_length(dom_nnodemap_object *map) +{ + return 0; +} + +/************************ + * === Item lookups === * + ************************/ + +static void dom_ret_node_to_zobj(dom_nnodemap_object *map, xmlNodePtr node, zval *return_value) +{ + if (node) { + DOM_RET_OBJ(node, map->baseobj); + } else { + RETURN_NULL(); + } +} + +static void dom_map_get_entity_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + xmlNodePtr node = map->ht ? php_dom_libxml_hash_iter(map->ht, index) : NULL; + dom_ret_node_to_zobj(map, node, return_value); +} + +static void dom_map_get_notation_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + xmlNodePtr node = map->ht ? php_dom_libxml_hash_iter(map->ht, index) : NULL; + if (node) { + xmlNotation *notation = (xmlNotation *) node; + node = create_notation(notation->name, notation->PublicID, notation->SystemID); + } + dom_ret_node_to_zobj(map, node, return_value); +} + +static void dom_map_get_nodeset_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + HashTable *nodeht = Z_ARRVAL(map->baseobj_zv); + zval *entry = zend_hash_index_find(nodeht, index); + if (entry) { + RETURN_COPY(entry); + } else { + RETURN_NULL(); + } +} + +typedef struct dom_node_idx_pair { + xmlNodePtr node; + zend_long index; +} dom_node_idx_pair; + +static dom_node_idx_pair dom_obj_map_get_start_point(dom_nnodemap_object *map, xmlNodePtr basep, zend_long index) +{ + dom_node_idx_pair ret; + ZEND_ASSERT(basep != NULL); + /* For now we're only able to use cache for forward search. + * TODO: in the future we could extend the logic of the node list such that backwards searches + * are also possible. */ + bool restart = true; + zend_long relative_index = index; + if (index >= map->cached_obj_index && map->cached_obj && !php_dom_is_cache_tag_stale_from_node(&map->cache_tag, basep)) { + xmlNodePtr cached_obj_xml_node = dom_object_get_node(map->cached_obj); + + /* The node cannot be NULL if the cache is valid. If it is NULL, then it means we + * forgot an invalidation somewhere. Take the defensive programming approach and invalidate + * it here if it's NULL (except in debug mode where we would want to catch this). */ + if (UNEXPECTED(cached_obj_xml_node == NULL)) { +#if ZEND_DEBUG + ZEND_UNREACHABLE(); +#endif + reset_objmap_cache(map); + } else { + restart = false; + relative_index -= map->cached_obj_index; + basep = cached_obj_xml_node; + } + } + ret.node = restart ? NULL : basep; + ret.index = relative_index; + return ret; +} + +static void dom_map_cache_obj(dom_nnodemap_object *map, xmlNodePtr itemnode, zend_long index, zval *return_value) +{ + /* Hold additional reference for the cache, must happen before releasing the cache + * because we might be the last reference holder. + * Instead of storing and copying zvals, we store the object pointer directly. + * This saves us some bytes because a pointer is smaller than a zval. + * This also means we have to manually refcount the objects here, and remove the reference count + * in reset_objmap_cache() and the destructor. */ + dom_object *cached_obj = Z_DOMOBJ_P(return_value); + GC_ADDREF(&cached_obj->std); + /* If the tag is stale, all cached data is useless. Otherwise only the cached object is useless. */ + if (php_dom_is_cache_tag_stale_from_node(&map->cache_tag, itemnode)) { + php_dom_mark_cache_tag_up_to_date_from_node(&map->cache_tag, itemnode); + reset_objmap_cache(map); + } else { + objmap_cache_release_cached_obj(map); + } + map->cached_obj_index = index; + map->cached_obj = cached_obj; +} + +static xmlNodePtr dom_map_get_attr_start(xmlNodePtr node) +{ + ZEND_ASSERT(node->type == XML_ELEMENT_NODE); + return (xmlNodePtr) node->properties; +} + +static void dom_map_get_chain_item(dom_nnodemap_object *map, zend_long index, zval *return_value, xmlNodePtr (*get_start)(xmlNodePtr)) +{ + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + xmlNodePtr itemnode = NULL; + if (nodep && index >= 0) { + dom_node_idx_pair start_point = dom_obj_map_get_start_point(map, nodep, index); + itemnode = start_point.node ? start_point.node : get_start(nodep); + for (; start_point.index > 0 && itemnode; itemnode = itemnode->next, start_point.index--); + } + dom_ret_node_to_zobj(map, itemnode, return_value); + if (itemnode) { + dom_map_cache_obj(map, itemnode, index, return_value); + } +} + +static void dom_map_get_attributes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + dom_map_get_chain_item(map, index, return_value, dom_map_get_attr_start); +} + +static void dom_map_get_nodes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + dom_map_get_chain_item(map, index, return_value, dom_nodelist_iter_start_first_child); +} + +static void dom_map_get_by_tag_name_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + xmlNodePtr itemnode = NULL; + if (nodep && index >= 0) { + zend_long count = 0; + dom_node_idx_pair start_point = dom_obj_map_get_start_point(map, nodep, index); + itemnode = start_point.node ? start_point.node : php_dom_first_child_of_container_node(nodep); + itemnode = dom_get_elements_by_tag_name_ns_raw(nodep, itemnode, map->ns, map->local, map->local_lower, &count, start_point.index); + } + dom_ret_node_to_zobj(map, itemnode, return_value); + if (itemnode) { + dom_map_cache_obj(map, itemnode, index, return_value); + } +} + +static void dom_map_get_null_item(dom_nnodemap_object *map, zend_long index, zval *return_value) +{ + RETURN_NULL(); +} + +/*********************** + * === Common APIs === * + ***********************/ + +zend_long php_dom_get_nodelist_length(dom_object *obj) +{ + dom_nnodemap_object *objmap = obj->ptr; + if (!objmap) { + return 0; + } + + if (objmap->handler->use_cache) { + xmlNodePtr nodep = dom_object_get_node(objmap->baseobj); + if (!nodep) { + return 0; + } + + if (!php_dom_is_cache_tag_stale_from_node(&objmap->cache_tag, nodep)) { + if (objmap->cached_length >= 0) { + return objmap->cached_length; + } + /* Only the length is out-of-date, the cache tag is still valid. + * Therefore, only overwrite the length and keep the currently cached object. */ + } else { + php_dom_mark_cache_tag_up_to_date_from_node(&objmap->cache_tag, nodep); + reset_objmap_cache(objmap); + } + } + + zend_long count = objmap->handler->length(objmap); + + if (objmap->handler->use_cache) { + objmap->cached_length = count; + } + + return count; +} + +/********************** + * === Named item === * + **********************/ + +static xmlNodePtr dom_map_get_named_item_entity(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + return xmlHashLookup(map->ht, BAD_CAST ZSTR_VAL(named)); +} + +static bool dom_map_has_named_item_xmlht(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + return dom_map_get_named_item_entity(map, named, ns) != NULL; +} + +static xmlNodePtr dom_map_get_named_item_notation(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + xmlNotationPtr notation = xmlHashLookup(map->ht, BAD_CAST ZSTR_VAL(named)); + if (notation) { + return create_notation(notation->name, notation->PublicID, notation->SystemID); + } + return NULL; +} + +static xmlNodePtr dom_map_get_named_item_prop(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + if (nodep) { + if (php_dom_follow_spec_intern(map->baseobj)) { + return (xmlNodePtr) php_dom_get_attribute_node(nodep, BAD_CAST ZSTR_VAL(named), ZSTR_LEN(named)); + } else { + if (ns) { + return (xmlNodePtr) xmlHasNsProp(nodep, BAD_CAST ZSTR_VAL(named), BAD_CAST ns); + } else { + return (xmlNodePtr) xmlHasProp(nodep, BAD_CAST ZSTR_VAL(named)); + } + } + } + return NULL; +} + +static bool dom_map_has_named_item_prop(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + return dom_map_get_named_item_prop(map, named, ns) != NULL; +} + +static xmlNodePtr dom_map_get_named_item_null(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + return NULL; +} + +static bool dom_map_has_named_item_null(dom_nnodemap_object *map, const zend_string *named, const char *ns) +{ + return false; +} + +/************************** + * === Handler tables === * + **************************/ + +const php_dom_obj_map_handler php_dom_obj_map_attributes = { + .length = dom_map_get_prop_length, + .get_item = dom_map_get_attributes_item, + .get_named_item = dom_map_get_named_item_prop, + .has_named_item = dom_map_has_named_item_prop, + .use_cache = true, + .nameless = false, +}; + +const php_dom_obj_map_handler php_dom_obj_map_by_tag_name = { + .length = dom_map_get_by_tag_name_length, + .get_item = dom_map_get_by_tag_name_item, + .get_named_item = dom_map_get_named_item_null, + .has_named_item = dom_map_has_named_item_null, + .use_cache = true, + .nameless = true, +}; + +const php_dom_obj_map_handler php_dom_obj_map_child_nodes = { + .length = dom_map_get_nodes_length, + .get_item = dom_map_get_nodes_item, + .get_named_item = dom_map_get_named_item_null, + .has_named_item = dom_map_has_named_item_null, + .use_cache = true, + .nameless = true, +}; + +const php_dom_obj_map_handler php_dom_obj_map_nodeset = { + .length = dom_map_get_nodeset_length, + .get_item = dom_map_get_nodeset_item, + .get_named_item = dom_map_get_named_item_null, + .has_named_item = dom_map_has_named_item_null, + .use_cache = false, + .nameless = true, +}; + +const php_dom_obj_map_handler php_dom_obj_map_entities = { + .length = dom_map_get_xmlht_length, + .get_item = dom_map_get_entity_item, + .get_named_item = dom_map_get_named_item_entity, + .has_named_item = dom_map_has_named_item_xmlht, + .use_cache = false, + .nameless = false, +}; + +const php_dom_obj_map_handler php_dom_obj_map_notations = { + .length = dom_map_get_xmlht_length, + .get_item = dom_map_get_notation_item, + .get_named_item = dom_map_get_named_item_notation, + .has_named_item = dom_map_has_named_item_xmlht, + .use_cache = false, + .nameless = false, +}; + +const php_dom_obj_map_handler php_dom_obj_map_noop = { + .length = dom_map_get_zero_length, + .get_item = dom_map_get_null_item, + .get_named_item = dom_map_get_named_item_null, + .has_named_item = dom_map_has_named_item_null, + .use_cache = false, + .nameless = true, +}; + +#endif diff --git a/ext/dom/obj_map.h b/ext/dom/obj_map.h new file mode 100644 index 0000000000000..511b71fcc7485 --- /dev/null +++ b/ext/dom/obj_map.h @@ -0,0 +1,39 @@ +/* + +----------------------------------------------------------------------+ + | 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. | + +----------------------------------------------------------------------+ + | Authors: Niels Dossche | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_DOM_OBJ_MAP_H +#define PHP_DOM_OBJ_MAP_H + +typedef struct dom_nnodemap_object dom_nnodemap_object; + +typedef struct php_dom_obj_map_handler { + zend_long (*length)(dom_nnodemap_object *); + void (*get_item)(dom_nnodemap_object *, zend_long, zval *); + xmlNodePtr (*get_named_item)(dom_nnodemap_object *, const zend_string *, const char *); + bool (*has_named_item)(dom_nnodemap_object *, const zend_string *, const char *); + bool use_cache; + bool nameless; +} php_dom_obj_map_handler; + +extern const php_dom_obj_map_handler php_dom_obj_map_attributes; +extern const php_dom_obj_map_handler php_dom_obj_map_by_tag_name; +extern const php_dom_obj_map_handler php_dom_obj_map_child_nodes; +extern const php_dom_obj_map_handler php_dom_obj_map_nodeset; +extern const php_dom_obj_map_handler php_dom_obj_map_entities; +extern const php_dom_obj_map_handler php_dom_obj_map_notations; +extern const php_dom_obj_map_handler php_dom_obj_map_noop; + +#endif diff --git a/ext/dom/parentnode/css_selectors.c b/ext/dom/parentnode/css_selectors.c index e681d2b9073fe..10b517a248d46 100644 --- a/ext/dom/parentnode/css_selectors.c +++ b/ext/dom/parentnode/css_selectors.c @@ -249,7 +249,7 @@ void dom_parent_node_query_selector_all(xmlNodePtr thisp, dom_object *intern, zv dom_object *ret_obj = Z_DOMOBJ_P(return_value); dom_nnodemap_object *mapptr = (dom_nnodemap_object *) ret_obj->ptr; ZVAL_ARR(&mapptr->baseobj_zv, list); - mapptr->nodetype = DOM_NODESET; + mapptr->handler = &php_dom_obj_map_nodeset; } } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index b1f7eca80f104..d9ed01d2e7d6e 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1456,7 +1456,8 @@ void dom_objects_free_storage(zend_object *object) } /* }}} */ -void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns) /* {{{ */ +/* TODO: move me to obj_map.c */ +void dom_namednode_iter(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler) /* {{{ */ { dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr; @@ -1466,8 +1467,8 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml xmlDocPtr doc = basenode->document ? basenode->document->ptr : NULL; + mapptr->handler = handler; mapptr->baseobj = basenode; - mapptr->nodetype = ntype; mapptr->ht = ht; if (EXPECTED(doc != NULL)) { mapptr->dict = doc->dict; @@ -1607,6 +1608,7 @@ zend_object *dom_nnodemap_objects_new(zend_class_entry *class_type) intern->ptr = ecalloc(1, sizeof(dom_nnodemap_object)); dom_nnodemap_object *objmap = intern->ptr; objmap->cached_length = -1; + objmap->handler = &php_dom_obj_map_noop; return &intern->std; } @@ -2380,7 +2382,7 @@ static zval *dom_nodemap_read_dimension(zend_object *object, zval *offset, int t zend_long lval; if (dom_nodemap_or_nodelist_process_offset_as_named(offset, &lval)) { /* exceptional case, switch to named lookup */ - php_dom_named_node_map_get_named_item_into_zval(php_dom_obj_from_obj(object)->ptr, Z_STR_P(offset), rv); + php_dom_named_node_map_get_named_item_into_zval(php_dom_obj_from_obj(object)->ptr, Z_STR_P(offset), NULL, rv); return rv; } @@ -2390,7 +2392,8 @@ static zval *dom_nodemap_read_dimension(zend_object *object, zval *offset, int t return NULL; } - php_dom_named_node_map_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, lval, rv); + dom_nnodemap_object *map = php_dom_obj_from_obj(object)->ptr; + map->handler->get_item(map, lval, rv); return rv; } @@ -2404,7 +2407,8 @@ static int dom_nodemap_has_dimension(zend_object *object, zval *member, int chec zend_long offset; if (dom_nodemap_or_nodelist_process_offset_as_named(member, &offset)) { /* exceptional case, switch to named lookup */ - return php_dom_named_node_map_get_named_item(php_dom_obj_from_obj(object)->ptr, Z_STR_P(member), false) != NULL; + dom_nnodemap_object *map = php_dom_obj_from_obj(object)->ptr; + return map->handler->has_named_item(map, Z_STR_P(member), NULL); } return offset >= 0 && offset < php_dom_get_namednodemap_length(php_dom_obj_from_obj(object)); @@ -2423,14 +2427,14 @@ static zval *dom_modern_nodemap_read_dimension(zend_object *object, zval *offset if (Z_TYPE_P(offset) == IS_STRING) { zend_ulong lval; if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), lval)) { - php_dom_named_node_map_get_item_into_zval(map, (zend_long) lval, rv); + map->handler->get_item(map, (zend_long) lval, rv); } else { - php_dom_named_node_map_get_named_item_into_zval(map, Z_STR_P(offset), rv); + php_dom_named_node_map_get_named_item_into_zval(map, Z_STR_P(offset), NULL, rv); } } else if (Z_TYPE_P(offset) == IS_LONG) { - php_dom_named_node_map_get_item_into_zval(map, Z_LVAL_P(offset), rv); + map->handler->get_item(map, Z_LVAL_P(offset), rv); } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - php_dom_named_node_map_get_item_into_zval(map, zend_dval_to_lval_safe(Z_DVAL_P(offset)), rv); + map->handler->get_item(map, zend_dval_to_lval_safe(Z_DVAL_P(offset)), rv); } else { zend_illegal_container_offset(object->ce->name, offset, type); return NULL; @@ -2453,7 +2457,7 @@ static int dom_modern_nodemap_has_dimension(zend_object *object, zval *member, i if (ZEND_HANDLE_NUMERIC(Z_STR_P(member), lval)) { return (zend_long) lval >= 0 && (zend_long) lval < php_dom_get_namednodemap_length(obj); } else { - return php_dom_named_node_map_get_named_item(map, Z_STR_P(member), false) != NULL; + return map->handler->has_named_item(map, Z_STR_P(member), NULL); } } else if (Z_TYPE_P(member) == IS_LONG) { zend_long offset = Z_LVAL_P(member); diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index ede77f08626cc..571f99cfe2be3 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -56,13 +56,12 @@ extern zend_module_entry dom_module_entry; #include "xpath_callbacks.h" #include "zend_exceptions.h" #include "dom_ce.h" +#include "obj_map.h" /* DOM API_VERSION, please bump it up, if you change anything in the API therefore it's easier for the script-programmers to check, what's working how Can be checked with phpversion("dom"); */ #define DOM_API_VERSION "20031129" -/* Define a custom type for iterating using an unused nodetype */ -#define DOM_NODESET XML_XINCLUDE_START typedef struct dom_xpath_object { php_dom_xpath_callbacks xpath_callbacks; @@ -80,7 +79,6 @@ static inline dom_xpath_object *php_xpath_obj_from_obj(zend_object *obj) { typedef struct dom_nnodemap_object { dom_object *baseobj; zval baseobj_zv; - int nodetype; int cached_length; xmlHashTable *ht; xmlChar *local; @@ -90,6 +88,7 @@ typedef struct dom_nnodemap_object { dom_object *cached_obj; zend_long cached_obj_index; xmlDictPtr dict; + const php_dom_obj_map_handler *handler; bool release_local : 1; bool release_ns : 1; } dom_nnodemap_object; @@ -146,9 +145,9 @@ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child); bool dom_has_feature(zend_string *feature, zend_string *version); bool dom_node_is_read_only(const xmlNode *node); bool dom_node_children_valid(const xmlNode *node); -void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns); +void dom_namednode_iter(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler); xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); -xmlNode *php_dom_libxml_hash_iter(dom_nnodemap_object *objmap, int index); +xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index); zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref); void dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce); xmlNodePtr php_dom_create_fake_namespace_decl(xmlNodePtr nodep, xmlNsPtr original, zval *return_value, dom_object *parent_intern); @@ -211,10 +210,8 @@ void dom_element_closest(xmlNodePtr thisp, dom_object *intern, zval *return_valu xmlNodePtr dom_parse_fragment(dom_object *obj, xmlNodePtr context_node, const zend_string *input); /* nodemap and nodelist APIs */ -xmlNodePtr php_dom_named_node_map_get_named_item(dom_nnodemap_object *objmap, const zend_string *named, bool may_transform); -void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, zval *return_value); +void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value); xmlNodePtr php_dom_named_node_map_get_item(dom_nnodemap_object *objmap, zend_long index); -void php_dom_named_node_map_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value); zend_long php_dom_get_namednodemap_length(dom_object *obj); xmlNodePtr dom_nodelist_iter_start_first_child(xmlNodePtr nodep); diff --git a/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt b/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt index 8a6f324c3dc35..bc8c8fe050e4f 100644 --- a/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt +++ b/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt @@ -36,8 +36,8 @@ foreach ($new->getElementsByTagName('child') as $child) { echo $new->saveXml(), "\n"; ?> ---EXPECT-- -object(Dom\NamedNodeMap)#5 (1) { +--EXPECTF-- +object(Dom\NamedNodeMap)#%d (1) { ["length"]=> int(2) } @@ -47,7 +47,7 @@ namespaceURI: string(29) "http://www.w3.org/2000/xmlns/" name: string(1) "a" prefix: NULL namespaceURI: NULL -object(Dom\NamedNodeMap)#3 (1) { +object(Dom\NamedNodeMap)#%d (1) { ["length"]=> int(3) } diff --git a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt index 38e00defe6223..cf446881559bc 100644 --- a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt +++ b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt @@ -22,7 +22,7 @@ foreach ($test_values as $value) { ?> --EXPECTF-- --- -1 --- -string(1) "a" +string(3) "N/A" bool(false) bool(true) --- 0 --- diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 8707af1fa94cf..b410f7b264997 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -239,7 +239,7 @@ static void dom_xpath_iter(zval *baseobj, dom_object *intern) /* {{{ */ dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr; ZVAL_COPY_VALUE(&mapptr->baseobj_zv, baseobj); - mapptr->nodetype = DOM_NODESET; + mapptr->handler = &php_dom_obj_map_nodeset; } /* }}} */ From 0ab5f70b3cc9705873586657f9910a7dd7d466f4 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 21:57:16 +0200 Subject: [PATCH 03/62] ext/spl: Remove bool type coercions in tests --- ext/spl/tests/bug36287.phpt | 2 +- ext/spl/tests/iterator_003.phpt | 2 +- ext/spl/tests/pqueue_001.phpt | 8 ++++---- ext/spl/tests/spl_003.phpt | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/spl/tests/bug36287.phpt b/ext/spl/tests/bug36287.phpt index 0fa6e1bc1eefd..8ea9123eb8a46 100644 --- a/ext/spl/tests/bug36287.phpt +++ b/ext/spl/tests/bug36287.phpt @@ -3,7 +3,7 @@ Bug #36287 (Segfault with SplFileInfo conversion) --FILE-- students->getIterator(), true); + return new CachingIterator($this->students->getIterator()); } } diff --git a/ext/spl/tests/pqueue_001.phpt b/ext/spl/tests/pqueue_001.phpt index 2b67ad4a2a247..a318487273eb7 100644 --- a/ext/spl/tests/pqueue_001.phpt +++ b/ext/spl/tests/pqueue_001.phpt @@ -16,7 +16,7 @@ $pq->insert("b", 2); $pq->insert("c", 0); foreach ($pq as $k=>$v) { - echo "$k=>".print_r($v, 1)."\n"; + echo "$k=>".print_r($v, true)."\n"; } echo "EXTR_BOTH\n"; @@ -29,7 +29,7 @@ $pq1->insert("b", 2); $pq1->insert("c", 0); foreach ($pq1 as $k=>$v) { - echo "$k=>".print_r($v, 1)."\n"; + echo "$k=>".print_r($v, true)."\n"; } echo "EXTR_DATA\n"; @@ -42,7 +42,7 @@ $pq2->insert("b", 2); $pq2->insert("c", 0); foreach ($pq2 as $k=>$v) { - echo "$k=>".print_r($v, 1)."\n"; + echo "$k=>".print_r($v, true)."\n"; } echo "EXTR_PRIORITY\n"; @@ -55,7 +55,7 @@ $pq3->insert("b", 2); $pq3->insert("c", 0); foreach ($pq3 as $k=>$v) { - echo "$k=>".print_r($v, 1)."\n"; + echo "$k=>".print_r($v, true)."\n"; } ?> diff --git a/ext/spl/tests/spl_003.phpt b/ext/spl/tests/spl_003.phpt index a9080c7298d25..f7e70db90f421 100644 --- a/ext/spl/tests/spl_003.phpt +++ b/ext/spl/tests/spl_003.phpt @@ -16,8 +16,8 @@ var_dump(class_parents(new c), class_parents(new b), class_parents("b"), class_parents("d"), - class_parents("foo", 0), - class_parents("foo", 1) + class_parents("foo", false), + class_parents("foo", true) ); interface iface1{} @@ -26,7 +26,7 @@ class f implements iface1, iface2{} var_dump(class_implements(new a), class_implements("a"), class_implements("aaa"), - class_implements("bbb", 0) + class_implements("bbb", false) ); ?> From 091308cb3e3ac8ddb4438d1c9ae1e67ca3492b9c Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 22:01:49 +0200 Subject: [PATCH 04/62] ext/soap: Remove bool type coercions in tests --- .../tests/interop/Round4/GroupH/r4_groupH_soapfault_004w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_030w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_031w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_032w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_033w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_034w.phpt | 2 +- ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_035w.phpt | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/soap/tests/interop/Round4/GroupH/r4_groupH_soapfault_004w.phpt b/ext/soap/tests/interop/Round4/GroupH/r4_groupH_soapfault_004w.phpt index 5c50cbc840345..69ba8880ad581 100644 --- a/ext/soap/tests/interop/Round4/GroupH/r4_groupH_soapfault_004w.phpt +++ b/ext/soap/tests/interop/Round4/GroupH/r4_groupH_soapfault_004w.phpt @@ -6,7 +6,7 @@ soap soap.wsdl_cache_enabled=0 --FILE-- 1,"exceptions"=>0)); $client->__soapCall("echoVersionMismatchFault",array(), null, $hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_030w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_030w.phpt index 1812b7751190b..cc5c5e608a784 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_030w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_030w.phpt @@ -6,7 +6,7 @@ soap soap.wsdl_cache_enabled=0 --FILE-- "Hello World"), 1); +$hdr = new SoapHeader("http://soapinterop.org/","echoMeStringRequest", array("varString"=>"Hello World"), true); $client = new SoapClient(__DIR__."/round4_groupI_xsd.wsdl",array("trace"=>1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_031w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_031w.phpt index 2b89e057e99cc..d0255f1de5479 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_031w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_031w.phpt @@ -6,7 +6,7 @@ soap soap.wsdl_cache_enabled=0 --FILE-- 1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_032w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_032w.phpt index 508f3c0a32553..57b3292764c16 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_032w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_032w.phpt @@ -7,7 +7,7 @@ precision=14 soap.wsdl_cache_enabled=0 --FILE-- 34,"varString"=>"arg","varFloat"=>12.345), 1); +$hdr = new SoapHeader("http://soapinterop.org/","echoMeComplexTypeRequest", array("varInt"=>34,"varString"=>"arg","varFloat"=>12.345), true); $client = new SoapClient(__DIR__."/round4_groupI_xsd.wsdl",array("trace"=>1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_033w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_033w.phpt index c2b47eeaa6918..677641c98153e 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_033w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_033w.phpt @@ -7,7 +7,7 @@ precision=14 soap.wsdl_cache_enabled=0 --FILE-- 34,"varFloat"=>12.345), 1); +$hdr = new SoapHeader("http://soapinterop.org/","echoMeComplexTypeRequest", array("varInt"=>34,"varFloat"=>12.345), true); $client = new SoapClient(__DIR__."/round4_groupI_xsd.wsdl",array("trace"=>1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_034w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_034w.phpt index 2804699a3891c..cbb3b4ed34870 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_034w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_034w.phpt @@ -6,7 +6,7 @@ soap soap.wsdl_cache_enabled=0 --FILE-- "Hello World"), 1, SOAP_ACTOR_NEXT); +$hdr = new SoapHeader("http://soapinterop.org/","echoMeStringRequest", array("varString"=>"Hello World"), true, SOAP_ACTOR_NEXT); $client = new SoapClient(__DIR__."/round4_groupI_xsd.wsdl",array("trace"=>1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); diff --git a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_035w.phpt b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_035w.phpt index 75eb891533b34..0e2674c9bf4e8 100644 --- a/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_035w.phpt +++ b/ext/soap/tests/interop/Round4/GroupI/r4_groupI_xsd_035w.phpt @@ -7,7 +7,7 @@ precision=14 soap.wsdl_cache_enabled=0 --FILE-- 34,"varString"=>"arg","varFloat"=>12.345), 1, SOAP_ACTOR_NEXT); +$hdr = new SoapHeader("http://soapinterop.org/","echoMeComplexTypeRequest", array("varInt"=>34,"varString"=>"arg","varFloat"=>12.345), true, SOAP_ACTOR_NEXT); $client = new SoapClient(__DIR__."/round4_groupI_xsd.wsdl",array("trace"=>1,"exceptions"=>0)); $client->__soapCall("echoVoidSoapHeader",array(),null,$hdr); echo $client->__getlastrequest(); From 8316ff2b0a75cbb76f7fc4152d8f5b63f3873161 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 22:05:53 +0200 Subject: [PATCH 05/62] ext/dba: Remove bool type coercions in tests --- ext/dba/tests/dba_handlers.phpt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ext/dba/tests/dba_handlers.phpt b/ext/dba/tests/dba_handlers.phpt index b0dd54242370a..bc00d2ec6d4ce 100644 --- a/ext/dba/tests/dba_handlers.phpt +++ b/ext/dba/tests/dba_handlers.phpt @@ -37,12 +37,8 @@ echo "Test 2\n"; check(dba_handlers(false)); -echo "Test 3\n"; - -check(dba_handlers(0)); - -echo "Test 4 - full info\n"; -$h = dba_handlers(1); +echo "Test 3 - full info\n"; +$h = dba_handlers(true); foreach ($h as $key => $val) { if ($key === "flatfile") { echo "Success: flatfile enabled\n"; @@ -60,7 +56,5 @@ Test 1 Success: flatfile enabled Test 2 Success: flatfile enabled -Test 3 -Success: flatfile enabled -Test 4 - full info +Test 3 - full info Success: flatfile enabled From 5f3e10de8bb4c0171a361e6e2565fbeaad282b6f Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 22:07:16 +0200 Subject: [PATCH 06/62] ext/bz2: Remove bool type coercions in tests --- ext/bz2/tests/005.phpt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/bz2/tests/005.phpt b/ext/bz2/tests/005.phpt index d32d5b687f0f5..8a715787f31d0 100644 --- a/ext/bz2/tests/005.phpt +++ b/ext/bz2/tests/005.phpt @@ -18,12 +18,12 @@ $data2 = bzcompress($string, 1, 10); $data3 = $data2; $data3[3] = 0; -var_dump(bzdecompress(1,1)); +var_dump(bzdecompress(1, true)); var_dump(bzdecompress($data3)); -var_dump(bzdecompress($data3,1)); +var_dump(bzdecompress($data3, true)); -var_dump(bzdecompress($data, 0)); -var_dump(bzdecompress($data, 1)); +var_dump(bzdecompress($data, false)); +var_dump(bzdecompress($data, true)); var_dump(bzdecompress($data)); var_dump(bzdecompress($data2)); From fa81a231385495d440f879234c8110715cc82020 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 22:07:54 +0200 Subject: [PATCH 07/62] ext/exif: Remove bool type coercions in tests --- ext/exif/tests/bug72627.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/exif/tests/bug72627.phpt b/ext/exif/tests/bug72627.phpt index 179619ff72349..b0bc50777bba7 100644 --- a/ext/exif/tests/bug72627.phpt +++ b/ext/exif/tests/bug72627.phpt @@ -4,7 +4,7 @@ Bug #72627 (Memory Leakage In exif_process_IFD_in_TIFF) exif --FILE-- --EXPECTF-- From 37549e4563af40cf46484c3d9174403c85a94bb4 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 21 Jun 2025 22:11:42 +0200 Subject: [PATCH 08/62] ext/gmp: Remove bool type coercions in tests --- ext/gmp/tests/gmp_setbit.phpt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/gmp/tests/gmp_setbit.phpt b/ext/gmp/tests/gmp_setbit.phpt index 70b9e50694823..775042ef9737f 100644 --- a/ext/gmp/tests/gmp_setbit.phpt +++ b/ext/gmp/tests/gmp_setbit.phpt @@ -6,30 +6,30 @@ gmp getMessage() . \PHP_EOL; } var_dump(gmp_strval($n)); $n = gmp_init(5); -gmp_setbit($n, 2, 0); +gmp_setbit($n, 2, false); var_dump(gmp_strval($n)); $n = gmp_init(5); -gmp_setbit($n, 1, 1); +gmp_setbit($n, 1, true); var_dump(gmp_strval($n)); $n = gmp_init("100000000000"); -gmp_setbit($n, 23, 1); +gmp_setbit($n, 23, true); var_dump(gmp_strval($n)); -gmp_setbit($n, 23, 0); +gmp_setbit($n, 23, false); var_dump(gmp_strval($n)); gmp_setbit($n, 3); From 8526de84a504cc3fead9a1734ea663e8fd2669f3 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 22:32:11 +0200 Subject: [PATCH 09/62] Move common obj_map API functions to obj_map.c --- ext/dom/documenttype.c | 5 ++- ext/dom/dom_iterators.c | 2 +- ext/dom/element.c | 6 +-- ext/dom/html_collection.c | 3 +- ext/dom/namednodemap.c | 15 ++------ ext/dom/node.c | 5 ++- ext/dom/nodelist.c | 14 ++----- ext/dom/nodelist.h | 2 - ext/dom/obj_map.c | 61 ++++++++++++++++++++++++++++++ ext/dom/obj_map.h | 34 ++++++++++++++--- ext/dom/parentnode/css_selectors.c | 1 + ext/dom/php_dom.c | 51 ++----------------------- ext/dom/php_dom.h | 22 +---------- ext/dom/xpath.c | 2 +- 14 files changed, 114 insertions(+), 109 deletions(-) diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c index 895a34cebf650..63da0306649a9 100644 --- a/ext/dom/documenttype.c +++ b/ext/dom/documenttype.c @@ -22,6 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "dom_properties.h" #include "internal_helpers.h" @@ -53,7 +54,7 @@ zend_result dom_documenttype_entities_read(dom_object *obj, zval *retval) xmlHashTable *entityht = (xmlHashTable *) dtdptr->entities; dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, intern, entityht, NULL, NULL, &php_dom_obj_map_entities); + php_dom_create_obj_map(obj, intern, entityht, NULL, NULL, &php_dom_obj_map_entities); return SUCCESS; } @@ -74,7 +75,7 @@ zend_result dom_documenttype_notations_read(dom_object *obj, zval *retval) xmlHashTable *notationht = (xmlHashTable *) dtdptr->notations; dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, intern, notationht, NULL, NULL, &php_dom_obj_map_notations); + php_dom_create_obj_map(obj, intern, notationht, NULL, NULL, &php_dom_obj_map_notations); return SUCCESS; } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 19c4ea41adadb..90e973723f6c6 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -22,7 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" -#include "dom_ce.h" +#include "obj_map.h" typedef struct nodeIterator { int cur; diff --git a/ext/dom/element.c b/ext/dom/element.c index d0fc0b4a4d3e2..27e2845c9f0cb 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -23,8 +23,8 @@ #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "zend_enum.h" #include "php_dom.h" +#include "obj_map.h" #include "namespace_compat.h" -#include "private_data.h" #include "internal_helpers.h" #include "dom_properties.h" #include "token_list.h" @@ -825,7 +825,7 @@ static void dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAMETERS, z object_init_ex(return_value, iter_ce); namednode = Z_DOMOBJ_P(return_value); - dom_namednode_iter(intern, namednode, NULL, name, NULL, &php_dom_obj_map_by_tag_name); + php_dom_create_obj_map(intern, namednode, NULL, name, NULL, &php_dom_obj_map_by_tag_name); } PHP_METHOD(DOMElement, getElementsByTagName) @@ -1257,7 +1257,7 @@ static void dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAMETERS object_init_ex(return_value, iter_ce); namednode = Z_DOMOBJ_P(return_value); - dom_namednode_iter(intern, namednode, NULL, name, uri, &php_dom_obj_map_by_tag_name); + php_dom_create_obj_map(intern, namednode, NULL, name, uri, &php_dom_obj_map_by_tag_name); } PHP_METHOD(DOMElement, getElementsByTagNameNS) diff --git a/ext/dom/html_collection.c b/ext/dom/html_collection.c index e4c0446016685..e5dca84de75ff 100644 --- a/ext/dom/html_collection.c +++ b/ext/dom/html_collection.c @@ -21,6 +21,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "nodelist.h" #include "html_collection.h" #include "namespace_compat.h" @@ -115,7 +116,7 @@ zval *dom_html_collection_read_dimension(zend_object *object, zval *offset, int dom_html_collection_named_item_into_zval(rv, index.str, object); } else { ZEND_ASSERT(index.type == DOM_NODELIST_DIM_LONG); - php_dom_nodelist_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, index.lval, rv); + php_dom_obj_map_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, index.lval, rv); } return rv; diff --git a/ext/dom/namednodemap.c b/ext/dom/namednodemap.c index 2f8f6d10132c2..953731ad84487 100644 --- a/ext/dom/namednodemap.c +++ b/ext/dom/namednodemap.c @@ -22,6 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "zend_interfaces.h" /* @@ -54,16 +55,6 @@ zend_result dom_namednodemap_length_read(dom_object *obj, zval *retval) /* }}} */ -void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value) -{ - xmlNodePtr itemnode = objmap->handler->get_named_item(objmap, named, ns); - if (itemnode) { - DOM_RET_OBJ(itemnode, objmap->baseobj); - } else { - RETURN_NULL(); - } -} - /* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1074577549 Since: */ @@ -76,7 +67,7 @@ PHP_METHOD(DOMNamedNodeMap, getNamedItem) } dom_nnodemap_object *objmap = Z_DOMOBJ_P(ZEND_THIS)->ptr; - php_dom_named_node_map_get_named_item_into_zval(objmap, named, NULL, return_value); + php_dom_obj_map_get_named_item_into_zval(objmap, named, NULL, return_value); } /* }}} end dom_namednodemap_get_named_item */ @@ -121,7 +112,7 @@ PHP_METHOD(DOMNamedNodeMap, getNamedItemNS) objmap = (dom_nnodemap_object *)intern->ptr; if (objmap != NULL) { - php_dom_named_node_map_get_named_item_into_zval(objmap, named, uri, return_value); + php_dom_obj_map_get_named_item_into_zval(objmap, named, uri, return_value); } } /* }}} end dom_namednodemap_get_named_item_ns */ diff --git a/ext/dom/node.c b/ext/dom/node.c index 99069d778ebfe..dba4bb8db87cd 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -22,6 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "namespace_compat.h" #include "private_data.h" #include "internal_helpers.h" @@ -288,7 +289,7 @@ zend_result dom_node_child_nodes_read(dom_object *obj, zval *retval) object_init_ex(retval, dom_get_nodelist_ce(php_dom_follow_spec_intern(obj))); dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_child_nodes); + php_dom_create_obj_map(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_child_nodes); return SUCCESS; } @@ -422,7 +423,7 @@ zend_result dom_node_attributes_read(dom_object *obj, zval *retval) if (nodep->type == XML_ELEMENT_NODE) { object_init_ex(retval, dom_get_namednodemap_ce(php_dom_follow_spec_intern(obj))); dom_object *intern = Z_DOMOBJ_P(retval); - dom_namednode_iter(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_attributes); + php_dom_create_obj_map(obj, intern, NULL, NULL, NULL, &php_dom_obj_map_attributes); } else { ZVAL_NULL(retval); } diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index 46a10a362a071..5e3de728e4fae 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -22,6 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "nodelist.h" #include "zend_interfaces.h" @@ -63,15 +64,6 @@ PHP_METHOD(DOMNodeList, count) } /* }}} end dom_nodelist_count */ -void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value) -{ - if (EXPECTED(objmap)) { - objmap->handler->get_item(objmap, index, return_value); - } else { - RETURN_NULL(); - } -} - /* {{{ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-844377136 Since: */ @@ -85,7 +77,7 @@ PHP_METHOD(DOMNodeList, item) zval *id = ZEND_THIS; dom_object *intern = Z_DOMOBJ_P(id); dom_nnodemap_object *objmap = intern->ptr; - php_dom_nodelist_get_item_into_zval(objmap, index, return_value); + php_dom_obj_map_get_item_into_zval(objmap, index, return_value); } /* }}} end dom_nodelist_item */ @@ -136,7 +128,7 @@ zval *dom_modern_nodelist_read_dimension(zend_object *object, zval *offset, int return NULL; } - php_dom_nodelist_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, index.lval, rv); + php_dom_obj_map_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, index.lval, rv); return rv; } diff --git a/ext/dom/nodelist.h b/ext/dom/nodelist.h index 5ac3de1e46c44..5c5653eea6dce 100644 --- a/ext/dom/nodelist.h +++ b/ext/dom/nodelist.h @@ -31,8 +31,6 @@ typedef struct dom_nodelist_dimension_index { enum dom_nodelist_dimension_index_type type; } dom_nodelist_dimension_index; -void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value); -zend_long php_dom_get_nodelist_length(dom_object *obj); dom_nodelist_dimension_index dom_modern_nodelist_get_index(const zval *offset); zval *dom_modern_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv); int dom_modern_nodelist_has_dimension(zend_object *object, zval *member, int check_empty); diff --git a/ext/dom/obj_map.c b/ext/dom/obj_map.c index f2a93fe3ef870..c92a5834f3c9e 100644 --- a/ext/dom/obj_map.c +++ b/ext/dom/obj_map.c @@ -288,6 +288,67 @@ zend_long php_dom_get_nodelist_length(dom_object *obj) return count; } +void php_dom_create_obj_map(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler) +{ + dom_nnodemap_object *mapptr = intern->ptr; + + ZEND_ASSERT(basenode != NULL); + + ZVAL_OBJ_COPY(&mapptr->baseobj_zv, &basenode->std); + + xmlDocPtr doc = basenode->document ? basenode->document->ptr : NULL; + + mapptr->handler = handler; + mapptr->baseobj = basenode; + mapptr->ht = ht; + if (EXPECTED(doc != NULL)) { + mapptr->dict = doc->dict; + xmlDictReference(doc->dict); + } + + const xmlChar* tmp; + + if (local) { + int len = (int) ZSTR_LEN(local); + if (doc != NULL && (tmp = xmlDictExists(doc->dict, (const xmlChar *)ZSTR_VAL(local), len)) != NULL) { + mapptr->local = BAD_CAST tmp; + } else { + mapptr->local = BAD_CAST ZSTR_VAL(zend_string_copy(local)); + mapptr->release_local = true; + } + mapptr->local_lower = zend_string_tolower(local); + } + + if (ns) { + int len = (int) ZSTR_LEN(ns); + if (doc != NULL && (tmp = xmlDictExists(doc->dict, (const xmlChar *)ZSTR_VAL(ns), len)) != NULL) { + mapptr->ns = BAD_CAST tmp; + } else { + mapptr->ns = BAD_CAST ZSTR_VAL(zend_string_copy(ns)); + mapptr->release_ns = true; + } + } +} + +void php_dom_obj_map_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value) +{ + if (EXPECTED(objmap)) { + objmap->handler->get_item(objmap, index, return_value); + } else { + RETURN_NULL(); + } +} + +void php_dom_obj_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value) +{ + xmlNodePtr itemnode = objmap->handler->get_named_item(objmap, named, ns); + if (itemnode) { + DOM_RET_OBJ(itemnode, objmap->baseobj); + } else { + RETURN_NULL(); + } +} + /********************** * === Named item === * **********************/ diff --git a/ext/dom/obj_map.h b/ext/dom/obj_map.h index 511b71fcc7485..70b6fdd107b49 100644 --- a/ext/dom/obj_map.h +++ b/ext/dom/obj_map.h @@ -20,14 +20,36 @@ typedef struct dom_nnodemap_object dom_nnodemap_object; typedef struct php_dom_obj_map_handler { - zend_long (*length)(dom_nnodemap_object *); - void (*get_item)(dom_nnodemap_object *, zend_long, zval *); - xmlNodePtr (*get_named_item)(dom_nnodemap_object *, const zend_string *, const char *); - bool (*has_named_item)(dom_nnodemap_object *, const zend_string *, const char *); - bool use_cache; - bool nameless; + zend_long (*length)(dom_nnodemap_object *); + void (*get_item)(dom_nnodemap_object *, zend_long, zval *); + xmlNodePtr (*get_named_item)(dom_nnodemap_object *, const zend_string *, const char *); + bool (*has_named_item)(dom_nnodemap_object *, const zend_string *, const char *); + bool use_cache; + bool nameless; } php_dom_obj_map_handler; +typedef struct dom_nnodemap_object { + dom_object *baseobj; + zval baseobj_zv; + int cached_length; + xmlHashTable *ht; + xmlChar *local; + zend_string *local_lower; + xmlChar *ns; + php_libxml_cache_tag cache_tag; + dom_object *cached_obj; + zend_long cached_obj_index; + xmlDictPtr dict; + const php_dom_obj_map_handler *handler; + bool release_local : 1; + bool release_ns : 1; +} dom_nnodemap_object; + +void php_dom_create_obj_map(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler); +void php_dom_obj_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value); +void php_dom_obj_map_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value); +zend_long php_dom_get_nodelist_length(dom_object *obj); + extern const php_dom_obj_map_handler php_dom_obj_map_attributes; extern const php_dom_obj_map_handler php_dom_obj_map_by_tag_name; extern const php_dom_obj_map_handler php_dom_obj_map_child_nodes; diff --git a/ext/dom/parentnode/css_selectors.c b/ext/dom/parentnode/css_selectors.c index 10b517a248d46..b9d2edee723bc 100644 --- a/ext/dom/parentnode/css_selectors.c +++ b/ext/dom/parentnode/css_selectors.c @@ -21,6 +21,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "../php_dom.h" +#include "../obj_map.h" #include "ext/lexbor/lexbor/css/parser.h" #include "../lexbor/selectors-adapted/selectors.h" diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index d9ed01d2e7d6e..e71e4e259c304 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -24,6 +24,7 @@ #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "zend_enum.h" #include "php_dom.h" +#include "obj_map.h" #include "nodelist.h" #include "html_collection.h" #include "namespace_compat.h" @@ -1456,50 +1457,6 @@ void dom_objects_free_storage(zend_object *object) } /* }}} */ -/* TODO: move me to obj_map.c */ -void dom_namednode_iter(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler) /* {{{ */ -{ - dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr; - - ZEND_ASSERT(basenode != NULL); - - ZVAL_OBJ_COPY(&mapptr->baseobj_zv, &basenode->std); - - xmlDocPtr doc = basenode->document ? basenode->document->ptr : NULL; - - mapptr->handler = handler; - mapptr->baseobj = basenode; - mapptr->ht = ht; - if (EXPECTED(doc != NULL)) { - mapptr->dict = doc->dict; - xmlDictReference(doc->dict); - } - - const xmlChar* tmp; - - if (local) { - int len = (int) ZSTR_LEN(local); - if (doc != NULL && (tmp = xmlDictExists(doc->dict, (const xmlChar *)ZSTR_VAL(local), len)) != NULL) { - mapptr->local = BAD_CAST tmp; - } else { - mapptr->local = BAD_CAST ZSTR_VAL(zend_string_copy(local)); - mapptr->release_local = true; - } - mapptr->local_lower = zend_string_tolower(local); - } - - if (ns) { - int len = (int) ZSTR_LEN(ns); - if (doc != NULL && (tmp = xmlDictExists(doc->dict, (const xmlChar *)ZSTR_VAL(ns), len)) != NULL) { - mapptr->ns = BAD_CAST tmp; - } else { - mapptr->ns = BAD_CAST ZSTR_VAL(zend_string_copy(ns)); - mapptr->release_ns = true; - } - } -} -/* }}} */ - static void dom_objects_set_class_ex(zend_class_entry *class_type, dom_object *intern) { zend_class_entry *base_class = class_type; @@ -2294,7 +2251,7 @@ static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int return rv; } - php_dom_nodelist_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, lval, rv); + php_dom_obj_map_get_item_into_zval(php_dom_obj_from_obj(object)->ptr, lval, rv); return rv; } @@ -2382,7 +2339,7 @@ static zval *dom_nodemap_read_dimension(zend_object *object, zval *offset, int t zend_long lval; if (dom_nodemap_or_nodelist_process_offset_as_named(offset, &lval)) { /* exceptional case, switch to named lookup */ - php_dom_named_node_map_get_named_item_into_zval(php_dom_obj_from_obj(object)->ptr, Z_STR_P(offset), NULL, rv); + php_dom_obj_map_get_named_item_into_zval(php_dom_obj_from_obj(object)->ptr, Z_STR_P(offset), NULL, rv); return rv; } @@ -2429,7 +2386,7 @@ static zval *dom_modern_nodemap_read_dimension(zend_object *object, zval *offset if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), lval)) { map->handler->get_item(map, (zend_long) lval, rv); } else { - php_dom_named_node_map_get_named_item_into_zval(map, Z_STR_P(offset), NULL, rv); + php_dom_obj_map_get_named_item_into_zval(map, Z_STR_P(offset), NULL, rv); } } else if (Z_TYPE_P(offset) == IS_LONG) { map->handler->get_item(map, Z_LVAL_P(offset), rv); diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 571f99cfe2be3..0ff8692c4cc74 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -56,7 +56,7 @@ extern zend_module_entry dom_module_entry; #include "xpath_callbacks.h" #include "zend_exceptions.h" #include "dom_ce.h" -#include "obj_map.h" + /* DOM API_VERSION, please bump it up, if you change anything in the API therefore it's easier for the script-programmers to check, what's working how Can be checked with phpversion("dom"); @@ -76,23 +76,6 @@ static inline dom_xpath_object *php_xpath_obj_from_obj(zend_object *obj) { #define Z_XPATHOBJ_P(zv) php_xpath_obj_from_obj(Z_OBJ_P((zv))) -typedef struct dom_nnodemap_object { - dom_object *baseobj; - zval baseobj_zv; - int cached_length; - xmlHashTable *ht; - xmlChar *local; - zend_string *local_lower; - xmlChar *ns; - php_libxml_cache_tag cache_tag; - dom_object *cached_obj; - zend_long cached_obj_index; - xmlDictPtr dict; - const php_dom_obj_map_handler *handler; - bool release_local : 1; - bool release_ns : 1; -} dom_nnodemap_object; - typedef struct { zend_object_iterator intern; zval curobj; @@ -145,7 +128,6 @@ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child); bool dom_has_feature(zend_string *feature, zend_string *version); bool dom_node_is_read_only(const xmlNode *node); bool dom_node_children_valid(const xmlNode *node); -void dom_namednode_iter(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler); xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index); zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref); @@ -210,8 +192,6 @@ void dom_element_closest(xmlNodePtr thisp, dom_object *intern, zval *return_valu xmlNodePtr dom_parse_fragment(dom_object *obj, xmlNodePtr context_node, const zend_string *input); /* nodemap and nodelist APIs */ -void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value); -xmlNodePtr php_dom_named_node_map_get_item(dom_nnodemap_object *objmap, zend_long index); zend_long php_dom_get_namednodemap_length(dom_object *obj); xmlNodePtr dom_nodelist_iter_start_first_child(xmlNodePtr nodep); diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index b410f7b264997..ebf61f10e80bf 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -22,8 +22,8 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "obj_map.h" #include "namespace_compat.h" -#include "private_data.h" #include "internal_helpers.h" #define PHP_DOM_XPATH_QUERY 0 From 26aea0ed3780382490d51c7ab5859af4ae55bdd9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 22:34:23 +0200 Subject: [PATCH 10/62] Tweak sizes of some dom_nnodemap_object fields We don't have to pack the bools, and the cached index would better be a zend_long so we don't get implicit narrowing. --- ext/dom/obj_map.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/dom/obj_map.h b/ext/dom/obj_map.h index 70b6fdd107b49..b1649999fbf16 100644 --- a/ext/dom/obj_map.h +++ b/ext/dom/obj_map.h @@ -31,7 +31,7 @@ typedef struct php_dom_obj_map_handler { typedef struct dom_nnodemap_object { dom_object *baseobj; zval baseobj_zv; - int cached_length; + zend_long cached_length; xmlHashTable *ht; xmlChar *local; zend_string *local_lower; @@ -41,8 +41,8 @@ typedef struct dom_nnodemap_object { zend_long cached_obj_index; xmlDictPtr dict; const php_dom_obj_map_handler *handler; - bool release_local : 1; - bool release_ns : 1; + bool release_local; + bool release_ns; } dom_nnodemap_object; void php_dom_create_obj_map(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler); From 873634278200d6b617bc135e224f36a8379ba410 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 22:38:01 +0200 Subject: [PATCH 11/62] Pack dom_nnodemap_object fields together with a union that can't be active at the same time --- ext/dom/obj_map.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/dom/obj_map.h b/ext/dom/obj_map.h index b1649999fbf16..4935799564286 100644 --- a/ext/dom/obj_map.h +++ b/ext/dom/obj_map.h @@ -32,10 +32,14 @@ typedef struct dom_nnodemap_object { dom_object *baseobj; zval baseobj_zv; zend_long cached_length; - xmlHashTable *ht; - xmlChar *local; - zend_string *local_lower; - xmlChar *ns; + union { + xmlHashTable *ht; + struct { + xmlChar *local; + zend_string *local_lower; + xmlChar *ns; + }; + }; php_libxml_cache_tag cache_tag; dom_object *cached_obj; zend_long cached_obj_index; From 479e9be45d7ca51e7cb09663c9e36d45fcd10960 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 21 Jun 2025 23:13:04 +0200 Subject: [PATCH 12/62] Store hash table entry directly in dom_nnodemap_object Splits the purpose of the baseobj_zv: now no longer either is an array or an object. Stores the hash table pointer directly, if used. --- ext/dom/obj_map.c | 8 +++----- ext/dom/obj_map.h | 3 ++- ext/dom/parentnode/css_selectors.c | 3 ++- ext/dom/php_dom.c | 7 +++++-- ext/dom/xpath.c | 18 ++++++++---------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/ext/dom/obj_map.c b/ext/dom/obj_map.c index c92a5834f3c9e..12407a560112e 100644 --- a/ext/dom/obj_map.c +++ b/ext/dom/obj_map.c @@ -55,8 +55,7 @@ static zend_long dom_map_get_xmlht_length(dom_nnodemap_object *map) static zend_long dom_map_get_nodeset_length(dom_nnodemap_object *map) { - HashTable *nodeht = Z_ARRVAL(map->baseobj_zv); - return zend_hash_num_elements(nodeht); + return zend_hash_num_elements(map->array); } static zend_long dom_map_get_prop_length(dom_nnodemap_object *map) @@ -132,8 +131,7 @@ static void dom_map_get_notation_item(dom_nnodemap_object *map, zend_long index, static void dom_map_get_nodeset_item(dom_nnodemap_object *map, zend_long index, zval *return_value) { - HashTable *nodeht = Z_ARRVAL(map->baseobj_zv); - zval *entry = zend_hash_index_find(nodeht, index); + zval *entry = zend_hash_index_find(map->array, index); if (entry) { RETURN_COPY(entry); } else { @@ -294,7 +292,7 @@ void php_dom_create_obj_map(dom_object *basenode, dom_object *intern, xmlHashTab ZEND_ASSERT(basenode != NULL); - ZVAL_OBJ_COPY(&mapptr->baseobj_zv, &basenode->std); + GC_ADDREF(&basenode->std); xmlDocPtr doc = basenode->document ? basenode->document->ptr : NULL; diff --git a/ext/dom/obj_map.h b/ext/dom/obj_map.h index 4935799564286..e1de9addd98f2 100644 --- a/ext/dom/obj_map.h +++ b/ext/dom/obj_map.h @@ -30,10 +30,10 @@ typedef struct php_dom_obj_map_handler { typedef struct dom_nnodemap_object { dom_object *baseobj; - zval baseobj_zv; zend_long cached_length; union { xmlHashTable *ht; + HashTable *array; struct { xmlChar *local; zend_string *local_lower; @@ -47,6 +47,7 @@ typedef struct dom_nnodemap_object { const php_dom_obj_map_handler *handler; bool release_local; bool release_ns; + bool release_array; } dom_nnodemap_object; void php_dom_create_obj_map(dom_object *basenode, dom_object *intern, xmlHashTablePtr ht, zend_string *local, zend_string *ns, const php_dom_obj_map_handler *handler); diff --git a/ext/dom/parentnode/css_selectors.c b/ext/dom/parentnode/css_selectors.c index b9d2edee723bc..4f77359835ce5 100644 --- a/ext/dom/parentnode/css_selectors.c +++ b/ext/dom/parentnode/css_selectors.c @@ -249,7 +249,8 @@ void dom_parent_node_query_selector_all(xmlNodePtr thisp, dom_object *intern, zv object_init_ex(return_value, dom_modern_nodelist_class_entry); dom_object *ret_obj = Z_DOMOBJ_P(return_value); dom_nnodemap_object *mapptr = (dom_nnodemap_object *) ret_obj->ptr; - ZVAL_ARR(&mapptr->baseobj_zv, list); + mapptr->array = list; + mapptr->release_array = true; mapptr->handler = &php_dom_obj_map_nodeset; } } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index e71e4e259c304..6e85ea887e4ec 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1545,8 +1545,11 @@ void dom_nnodemap_objects_free_storage(zend_object *object) /* {{{ */ if (objmap->local_lower) { zend_string_release(objmap->local_lower); } - if (!Z_ISUNDEF(objmap->baseobj_zv)) { - zval_ptr_dtor(&objmap->baseobj_zv); + if (objmap->release_array) { + zend_array_release(objmap->array); + } + if (objmap->baseobj) { + OBJ_RELEASE(&objmap->baseobj->std); } xmlDictFree(objmap->dict); efree(objmap); diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index ebf61f10e80bf..21baa59ffed0b 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -234,15 +234,6 @@ PHP_METHOD(DOMXPath, registerNamespace) } /* }}} */ -static void dom_xpath_iter(zval *baseobj, dom_object *intern) /* {{{ */ -{ - dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr; - - ZVAL_COPY_VALUE(&mapptr->baseobj_zv, baseobj); - mapptr->handler = &php_dom_obj_map_nodeset; -} -/* }}} */ - static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type, bool modern) /* {{{ */ { zval *context = NULL; @@ -335,6 +326,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type, bool modern) { xmlNodeSetPtr nodesetp; zval retval; + bool release_array = false; if (xpathobjp->type == XPATH_NODESET && NULL != (nodesetp = xpathobjp->nodesetval) && nodesetp->nodeNr) { array_init_size(&retval, nodesetp->nodeNr); @@ -369,12 +361,18 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type, bool modern) } add_next_index_zval(&retval, &child); } + release_array = true; } else { ZVAL_EMPTY_ARRAY(&retval); } + object_init_ex(return_value, dom_get_nodelist_ce(modern)); nodeobj = Z_DOMOBJ_P(return_value); - dom_xpath_iter(&retval, nodeobj); + dom_nnodemap_object *mapptr = nodeobj->ptr; + + mapptr->array = Z_ARR(retval); + mapptr->release_array = release_array; + mapptr->handler = &php_dom_obj_map_nodeset; break; } From 9b6df109c7fbca47ef1f1744d94e31f0d4acfd02 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 12:31:06 +0200 Subject: [PATCH 13/62] Don't use the obj_map cache for attributes (#18895) --- ext/dom/obj_map.c | 28 ++++++++----------- .../common/attr_named_node_map_cache.phpt | 17 +++++++++++ 2 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 ext/dom/tests/modern/common/attr_named_node_map_cache.phpt diff --git a/ext/dom/obj_map.c b/ext/dom/obj_map.c index 12407a560112e..fe71a6f47a38a 100644 --- a/ext/dom/obj_map.c +++ b/ext/dom/obj_map.c @@ -196,19 +196,25 @@ static void dom_map_cache_obj(dom_nnodemap_object *map, xmlNodePtr itemnode, zen map->cached_obj = cached_obj; } -static xmlNodePtr dom_map_get_attr_start(xmlNodePtr node) +static void dom_map_get_attributes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) { - ZEND_ASSERT(node->type == XML_ELEMENT_NODE); - return (xmlNodePtr) node->properties; + xmlNodePtr nodep = dom_object_get_node(map->baseobj); + xmlNodePtr itemnode = NULL; + if (nodep && index >= 0) { + ZEND_ASSERT(nodep->type == XML_ELEMENT_NODE); + itemnode = (xmlNodePtr) nodep->properties; + for (; index > 0 && itemnode; itemnode = itemnode->next, index--); + } + dom_ret_node_to_zobj(map, itemnode, return_value); } -static void dom_map_get_chain_item(dom_nnodemap_object *map, zend_long index, zval *return_value, xmlNodePtr (*get_start)(xmlNodePtr)) +static void dom_map_get_nodes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) { xmlNodePtr nodep = dom_object_get_node(map->baseobj); xmlNodePtr itemnode = NULL; if (nodep && index >= 0) { dom_node_idx_pair start_point = dom_obj_map_get_start_point(map, nodep, index); - itemnode = start_point.node ? start_point.node : get_start(nodep); + itemnode = start_point.node ? start_point.node : dom_nodelist_iter_start_first_child(nodep); for (; start_point.index > 0 && itemnode; itemnode = itemnode->next, start_point.index--); } dom_ret_node_to_zobj(map, itemnode, return_value); @@ -217,16 +223,6 @@ static void dom_map_get_chain_item(dom_nnodemap_object *map, zend_long index, zv } } -static void dom_map_get_attributes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) -{ - dom_map_get_chain_item(map, index, return_value, dom_map_get_attr_start); -} - -static void dom_map_get_nodes_item(dom_nnodemap_object *map, zend_long index, zval *return_value) -{ - dom_map_get_chain_item(map, index, return_value, dom_nodelist_iter_start_first_child); -} - static void dom_map_get_by_tag_name_item(dom_nnodemap_object *map, zend_long index, zval *return_value) { xmlNodePtr nodep = dom_object_get_node(map->baseobj); @@ -411,7 +407,7 @@ const php_dom_obj_map_handler php_dom_obj_map_attributes = { .get_item = dom_map_get_attributes_item, .get_named_item = dom_map_get_named_item_prop, .has_named_item = dom_map_has_named_item_prop, - .use_cache = true, + .use_cache = false, .nameless = false, }; diff --git a/ext/dom/tests/modern/common/attr_named_node_map_cache.phpt b/ext/dom/tests/modern/common/attr_named_node_map_cache.phpt new file mode 100644 index 0000000000000..18dedaddb9a9e --- /dev/null +++ b/ext/dom/tests/modern/common/attr_named_node_map_cache.phpt @@ -0,0 +1,17 @@ +--TEST-- +Attribute named node map cache +--EXTENSIONS-- +dom +--FILE-- +'); +$attrs = $dom->documentElement->attributes; +var_dump($attrs[1]->nodeName); +$dom->documentElement->removeAttribute('b'); +var_dump($attrs[1]->nodeName); + +?> +--EXPECT-- +string(1) "b" +string(1) "c" From 2694eb9df04beaab1bc052a4da53d9adc6c29f0a Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 22 Jun 2025 08:00:08 +0100 Subject: [PATCH 14/62] Fixed GH-18902: ldap_exop/ldap_exop_sync assert triggered on empty request OID close GH-18903 --- NEWS | 4 ++++ ext/ldap/ldap.c | 7 ++++++- ext/ldap/tests/gh18902.phpt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 ext/ldap/tests/gh18902.phpt diff --git a/NEWS b/NEWS index 9881c36d4b012..25706b1efc0a0 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,10 @@ PHP NEWS . Fix memory leaks when returning refcounted value from curl callback. (nielsdos) +- LDAP: + . Fixed GH-18902 ldap_exop/ldap_exop_sync assert triggered on empty + request OID. (David Carlier) + - Streams: . Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter fatal error). (Jakub Zelenka) diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index fecb8846400a6..769e6caa277b4 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -4036,7 +4036,12 @@ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) { LDAPControl **lserverctrls = NULL; int rc, msgid; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) { + RETURN_THROWS(); + } + + if (ZSTR_LEN(reqoid) == 0) { + zend_argument_value_error(2, "must not be empty"); RETURN_THROWS(); } diff --git a/ext/ldap/tests/gh18902.phpt b/ext/ldap/tests/gh18902.phpt new file mode 100644 index 0000000000000..329cbb59c1b11 --- /dev/null +++ b/ext/ldap/tests/gh18902.phpt @@ -0,0 +1,30 @@ +--TEST-- +GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys) +--EXTENSIONS-- +ldap +--FILE-- +getMessage(), PHP_EOL; +} + +try { + ldap_exop_sync($conn,""); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +try { + ldap_exop_sync($conn,"test\0"); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +ldap_exop(): Argument #2 ($request_oid) must not contain any null bytes +ldap_exop_sync(): Argument #2 ($request_oid) must not be empty +ldap_exop_sync(): Argument #2 ($request_oid) must not contain any null bytes From a5f21ca7005f3825c47d52772ee2f66c6a81cf86 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 10:13:06 +0200 Subject: [PATCH 15/62] Fix GH-18901: integer overflow mb_split We prevent signed overflow by making the count unsigned. The actual interpretation of the count doesn't matter as it's just used to denote a limit. The test output for some limit values looks strange though, so that may need extra investigation. However, that's orthogonal to this fix. Closes GH-18906. --- NEWS | 3 ++ ext/mbstring/php_mbregex.c | 2 +- ext/mbstring/tests/gh18901.phpt | 54 +++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 ext/mbstring/tests/gh18901.phpt diff --git a/NEWS b/NEWS index 25706b1efc0a0..ea77125b205eb 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ PHP NEWS . Fixed GH-18902 ldap_exop/ldap_exop_sync assert triggered on empty request OID. (David Carlier) +- MbString: + . Fixed bug GH-18901 (integer overflow mb_split). (nielsdos) + - Streams: . Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter fatal error). (Jakub Zelenka) diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 99dc91e34dcae..86bc5f61d8543 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1184,7 +1184,7 @@ PHP_FUNCTION(mb_split) size_t string_len; int err; - zend_long count = -1; + zend_ulong count = -1; /* unsigned, it's a limit and we want to prevent signed overflow */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) { RETURN_THROWS(); diff --git a/ext/mbstring/tests/gh18901.phpt b/ext/mbstring/tests/gh18901.phpt new file mode 100644 index 0000000000000..8d862a537c3b1 --- /dev/null +++ b/ext/mbstring/tests/gh18901.phpt @@ -0,0 +1,54 @@ +--TEST-- +GH-18901 (integer overflow mb_split) +--EXTENSIONS-- +mbstring +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" +} +array(4) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" +} +array(4) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" +} +array(1) { + [0]=> + string(3) "123" +} +array(1) { + [0]=> + string(3) "123" +} From 3df665a8889d76216c80a6e21f1201ddc8eab1d9 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 22 Jun 2025 15:19:08 +0200 Subject: [PATCH 16/62] [Windows build] Remove redundant flags definitions (#18890) The /d2FuncCache1 compile option is already added by toolset_setup_common_cflags() in confutils.js to all targets. ZEND_DVAL_TO_LVAL_CAST_OK was removed in 3725717de18fd60a679a02210b3ed14517972524. --- win32/build/config.w32 | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index f509e4eae9337..403f0aa6efbfe 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -285,12 +285,6 @@ if (TARGET_ARCH == 'x64') { } ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); -if (VS_TOOLSET && VCVERS >= 1914) { - ADD_FLAG("CFLAGS_BD_ZEND", "/d2FuncCache1"); -} - -/* XXX inspect this for other toolsets */ -//AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ php_ini_builder.c php_glob.c \ @@ -299,9 +293,6 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ php_open_temporary_file.c output.c internal_functions.c \ php_syslog.c php_odbc_utils.c safe_bcmp.c"); ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); -if (VS_TOOLSET && VCVERS >= 1914) { - ADD_FLAG("CFLAGS_BD_MAIN", "/d2FuncCache1"); -} AC_DEFINE('HAVE_STRNLEN', 1); @@ -310,9 +301,6 @@ AC_DEFINE('ZEND_CHECK_STACK_LIMIT', 1) ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \ userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c"); ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); -if (VS_TOOLSET && VCVERS >= 1914) { - ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/d2FuncCache1"); -} ADD_SOURCES("win32", "dllmain.c readdir.c \ registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \ @@ -320,9 +308,6 @@ ADD_SOURCES("win32", "dllmain.c readdir.c \ fnmatch.c sockets.c console.c signal.c"); ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); -if (VS_TOOLSET && VCVERS >= 1914) { - ADD_FLAG("CFLAGS_BD_WIN32", "/d2FuncCache1"); -} PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/"); PHP_INSTALL_HEADERS("Zend/Optimizer", "zend_call_graph.h zend_cfg.h zend_dfg.h zend_dump.h zend_func_info.h zend_inference.h zend_optimizer.h zend_ssa.h zend_worklist.h"); From 4f1b005522ddbd776ea3714851219e6c517aee8f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 22 Jun 2025 16:03:55 +0200 Subject: [PATCH 17/62] Autotools: Enable tsrmls cache in hash extension on big endian (#15303) When system is detected as big endian this enables the TSRM Local Storage static cache with the ZEND_ENABLE_STATIC_TSRMLS_CACHE compilation flag. Previously it was enabled only on little endian systems. --- ext/hash/config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 1eef801a2fea8..5248786efb084 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -31,7 +31,7 @@ AS_VAR_IF([ac_cv_c_bigendian_php], [yes], [ SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-opt64.c" ]) EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c" - PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" + PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded" ]) PHP_NEW_EXTENSION([hash], m4_normalize([ @@ -58,7 +58,7 @@ PHP_NEW_EXTENSION([hash], m4_normalize([ murmur/PMurHash128.c ]), [no],, - [$PHP_HASH_CFLAGS]) + [$PHP_HASH_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_ADD_BUILD_DIR([$ext_builddir/murmur]) AS_VAR_IF([SHA3_DIR],,, [PHP_ADD_BUILD_DIR([$ext_builddir/$SHA3_DIR])]) PHP_INSTALL_HEADERS([ext/hash], m4_normalize([ From 01c3001eb76456c37753032e89c1cbc031904a85 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sun, 22 Jun 2025 19:47:36 +0100 Subject: [PATCH 18/62] ext/tidy: zend_parse_parameters_none -> ZEND_PARSE_PARAMETERS_NONE macro (#18913) --- ext/tidy/tidy.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 18fcc1bfdce68..fe2a0648af683 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -67,9 +67,7 @@ #define TIDY_FETCH_ONLY_OBJECT \ PHPTidyObj *obj; \ - if (zend_parse_parameters_none() != SUCCESS) { \ - RETURN_THROWS(); \ - } \ + ZEND_PARSE_PARAMETERS_NONE(); \ obj = Z_TIDY_P(ZEND_THIS); \ #define TIDY_SET_DEFAULT_CONFIG(_doc) \ @@ -1140,9 +1138,7 @@ PHP_FUNCTION(tidy_diagnose) /* {{{ Get release date (version) for Tidy library */ PHP_FUNCTION(tidy_get_release) { - if (zend_parse_parameters_none() != SUCCESS) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); #ifdef HAVE_TIDYRELEASEDATE RETURN_STRING((const char *)tidyReleaseDate()); From 4dfba7a2503c74db5d5337225e1406ceae1df87e Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Sun, 22 Jun 2025 12:29:26 -0700 Subject: [PATCH 19/62] [RFC] Final Property Promotion https://wiki.php.net/rfc/final_promotion --- NEWS | 2 ++ UPGRADING | 2 ++ .../property_hooks/final_prop_promoted_1.phpt | 18 ++++++++++++ .../property_hooks/final_prop_promoted_2.phpt | 18 ++++++++++++ .../property_hooks/final_prop_promoted_3.phpt | 18 ++++++++++++ .../property_hooks/final_prop_promoted_4.phpt | 18 ++++++++++++ .../property_hooks/final_prop_promoted_5.phpt | 28 +++++++++++++++++++ .../final_prop_promoted_ast.phpt | 18 ++++++++++++ Zend/zend_ast.c | 3 ++ Zend/zend_compile.c | 10 ++----- .../tests/ReflectionProperty_isFinal.phpt | 4 +++ 11 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 Zend/tests/property_hooks/final_prop_promoted_1.phpt create mode 100644 Zend/tests/property_hooks/final_prop_promoted_2.phpt create mode 100644 Zend/tests/property_hooks/final_prop_promoted_3.phpt create mode 100644 Zend/tests/property_hooks/final_prop_promoted_4.phpt create mode 100644 Zend/tests/property_hooks/final_prop_promoted_5.phpt create mode 100644 Zend/tests/property_hooks/final_prop_promoted_ast.phpt diff --git a/NEWS b/NEWS index fb117a221a37a..dfa90ed08f62c 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,8 @@ PHP NEWS . Properly handle __debugInfo() returning an array reference. (nielsdos) . Properly handle reference return value from __toString(). (nielsdos) . Added the pipe (|>) operator. (crell) + . Added support for `final` with constructor property promotion. + (DanielEScherzer) - Curl: . Added curl_multi_get_handles(). (timwolla) diff --git a/UPGRADING b/UPGRADING index 72bb5d76da936..e551f0c894260 100644 --- a/UPGRADING +++ b/UPGRADING @@ -146,6 +146,8 @@ PHP 8.5 UPGRADE NOTES RFC: https://wiki.php.net/rfc/attributes-on-constants . Added the pipe (|>) operator. RFC: https://wiki.php.net/rfc/pipe-operator-v3 + . Constructor property promotion can now be used for final properties. + RFC: https://wiki.php.net/rfc/final_promotion - Curl: . Added support for share handles that are persisted across multiple PHP diff --git a/Zend/tests/property_hooks/final_prop_promoted_1.phpt b/Zend/tests/property_hooks/final_prop_promoted_1.phpt new file mode 100644 index 0000000000000..740588d8aa2ae --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Promoted property may be marked final (hook) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot override final property A::$prop in %s on line %d diff --git a/Zend/tests/property_hooks/final_prop_promoted_2.phpt b/Zend/tests/property_hooks/final_prop_promoted_2.phpt new file mode 100644 index 0000000000000..535a7ceabd317 --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Promoted property may be marked final (normal) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot override final property A::$prop in %s on line %d diff --git a/Zend/tests/property_hooks/final_prop_promoted_3.phpt b/Zend/tests/property_hooks/final_prop_promoted_3.phpt new file mode 100644 index 0000000000000..600d18df84c9a --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_3.phpt @@ -0,0 +1,18 @@ +--TEST-- +Promoted property may be marked final (no visibility needed) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot override final property A::$prop in %s on line %d diff --git a/Zend/tests/property_hooks/final_prop_promoted_4.phpt b/Zend/tests/property_hooks/final_prop_promoted_4.phpt new file mode 100644 index 0000000000000..2b8270ff5a062 --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_4.phpt @@ -0,0 +1,18 @@ +--TEST-- +Final promoted property conflicts with non-promoted non-hooked property +--FILE-- + +--EXPECTF-- +Fatal error: Cannot override final property A::$prop in %s on line %d diff --git a/Zend/tests/property_hooks/final_prop_promoted_5.phpt b/Zend/tests/property_hooks/final_prop_promoted_5.phpt new file mode 100644 index 0000000000000..3e592f99b3416 --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_5.phpt @@ -0,0 +1,28 @@ +--TEST-- +Non-promoted constructor parameter does not conflict with final promoted property +--FILE-- + +--EXPECT-- +B::__construct(): test +A::__construct(): test diff --git a/Zend/tests/property_hooks/final_prop_promoted_ast.phpt b/Zend/tests/property_hooks/final_prop_promoted_ast.phpt new file mode 100644 index 0000000000000..32aa1f27dc323 --- /dev/null +++ b/Zend/tests/property_hooks/final_prop_promoted_ast.phpt @@ -0,0 +1,18 @@ +--TEST-- +Confirm that the AST indicates final promoted properties +--FILE-- +getMessage(), "\n"; +} +?> +--EXPECT-- +assert(false && new class { + public function __construct(public final $prop) { + } + +}) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index beecf51216a94..cdc86faa95aa3 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -2795,6 +2795,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio zend_ast_export_attributes(str, ast->child[3], indent, 0); } zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CPP); + if (ast->attr & ZEND_ACC_FINAL) { + smart_str_appends(str, "final "); + } if (ast->child[0]) { zend_ast_export_type(str, ast->child[0], indent); smart_str_appendc(str, ' '); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2bc0cf7b703d9..28bea1a21d759 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -903,13 +903,7 @@ uint32_t zend_modifier_token_to_flag(zend_modifier_target target, uint32_t token } break; case T_FINAL: - if (target == ZEND_MODIFIER_TARGET_METHOD - || target == ZEND_MODIFIER_TARGET_CONSTANT - || target == ZEND_MODIFIER_TARGET_PROPERTY - || target == ZEND_MODIFIER_TARGET_PROPERTY_HOOK) { - return ZEND_ACC_FINAL; - } - break; + return ZEND_ACC_FINAL; case T_STATIC: if (target == ZEND_MODIFIER_TARGET_PROPERTY || target == ZEND_MODIFIER_TARGET_METHOD) { return ZEND_ACC_STATIC; @@ -7681,7 +7675,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 zend_string *name = zval_make_interned_string(zend_ast_get_zval(var_ast)); bool is_ref = (param_ast->attr & ZEND_PARAM_REF) != 0; bool is_variadic = (param_ast->attr & ZEND_PARAM_VARIADIC) != 0; - uint32_t property_flags = param_ast->attr & (ZEND_ACC_PPP_MASK | ZEND_ACC_PPP_SET_MASK | ZEND_ACC_READONLY); + uint32_t property_flags = param_ast->attr & (ZEND_ACC_PPP_MASK | ZEND_ACC_PPP_SET_MASK | ZEND_ACC_READONLY | ZEND_ACC_FINAL); bool is_promoted = property_flags || hooks_ast; znode var_node, default_node; diff --git a/ext/reflection/tests/ReflectionProperty_isFinal.phpt b/ext/reflection/tests/ReflectionProperty_isFinal.phpt index 62b792fd7253f..f01835efbed25 100644 --- a/ext/reflection/tests/ReflectionProperty_isFinal.phpt +++ b/ext/reflection/tests/ReflectionProperty_isFinal.phpt @@ -12,6 +12,8 @@ class C { public protected(set) final mixed $p6; public private(set) mixed $p7; public private(set) final mixed $p8; + + public function __construct(final $p9, public $p10) {} } $rc = new ReflectionClass(C::class); @@ -30,3 +32,5 @@ p5: bool(false) p6: bool(true) p7: bool(true) p8: bool(true) +p9: bool(true) +p10: bool(false) From ddd33fd7e4e88f96fef91180b6bdf6d7af3af18e Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Sun, 22 Jun 2025 14:35:28 -0700 Subject: [PATCH 20/62] Generated arginfo headers: combine preprocessor conditional blocks (2) (#18667) When global constants' or class constants' availability is based on some preprocessor condition, the generated arginfo header files wrap the declarations in the preprocessor `#if` conditional blocks, one per declaration, even if they are in the same conditional block based on comments in the stub file. Instead of having multiple conditional blocks one after the other with the same condition, combine them into a single conditional block. --- build/gen_stub.php | 30 ++-- ext/com_dotnet/com_extension_arginfo.h | 2 - ext/curl/curl_arginfo.h | 158 ------------------ ext/dba/dba_arginfo.h | 2 - ext/gd/gd_arginfo.h | 18 -- .../listformatter/listformatter_arginfo.h | 6 - ext/intl/spoofchecker/spoofchecker_arginfo.h | 12 -- ext/intl/uchar/uchar_arginfo.h | 4 - ext/ldap/ldap_arginfo.h | 96 ----------- ext/odbc/odbc_arginfo.h | 32 ---- ext/openssl/openssl_arginfo.h | 16 -- ext/openssl/openssl_pwhash_arginfo.h | 10 -- ext/pcntl/pcntl_arginfo.h | 28 ---- ext/pdo_mysql/pdo_mysql_arginfo.h | 4 - ext/pdo_sqlite/pdo_sqlite_arginfo.h | 4 - ext/sockets/sockets_arginfo.h | 76 --------- ext/sodium/libsodium_arginfo.h | 82 --------- ext/sodium/sodium_pwhash_arginfo.h | 10 -- ext/standard/basic_functions_arginfo.h | 106 ------------ ext/standard/file_arginfo.h | 4 - ext/standard/password_arginfo.h | 10 -- ext/tidy/tidy_arginfo.h | 54 ------ ext/xsl/php_xsl_arginfo.h | 2 - ext/zip/php_zip_arginfo.h | 44 ----- main/main_arginfo.h | 20 --- 25 files changed, 13 insertions(+), 817 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index ff86106e8a2a4..fcef8213d0b55 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2749,23 +2749,15 @@ public function getDeclaration(array $allConstInfos): string throw new Exception("Constant " . $this->name->__toString() . " must have a @cvalue annotation"); } - $code = ""; - - if ($this->cond) { - $code .= "#if {$this->cond}\n"; - } + // Condition will be added by generateCodeWithConditions() if ($this->name->isClassConst()) { - $code .= $this->getClassConstDeclaration($value, $allConstInfos); + $code = $this->getClassConstDeclaration($value, $allConstInfos); } else { - $code .= $this->getGlobalConstDeclaration($value); + $code = $this->getGlobalConstDeclaration($value); } $code .= $this->getValueAssertion($value); - if ($this->cond) { - $code .= "#endif\n"; - } - return $code; } @@ -3556,9 +3548,11 @@ function (Name $item) { $code .= "\tzend_register_class_alias(\"" . str_replace("\\", "\\\\", $this->alias) . "\", class_entry);\n"; } - foreach ($this->constInfos as $const) { - $code .= $const->getDeclaration($allConstInfos); - } + $code .= generateCodeWithConditions( + $this->constInfos, + '', + static fn (ConstInfo $const): string => $const->getDeclaration($allConstInfos) + ); foreach ($this->enumCaseInfos as $enumCase) { $code .= $enumCase->getDeclaration($allConstInfos); @@ -5192,9 +5186,11 @@ static function (FuncInfo $funcInfo) use ($fileInfo, &$generatedFunctionDeclarat $code .= "\nstatic void register_{$stubFilenameWithoutExtension}_symbols(int module_number)\n"; $code .= "{\n"; - foreach ($fileInfo->constInfos as $constInfo) { - $code .= $constInfo->getDeclaration($allConstInfos); - } + $code .= generateCodeWithConditions( + $fileInfo->constInfos, + '', + static fn (ConstInfo $constInfo): string => $constInfo->getDeclaration($allConstInfos) + ); if ($attributeInitializationCode !== "" && $fileInfo->constInfos) { $code .= "\n"; diff --git a/ext/com_dotnet/com_extension_arginfo.h b/ext/com_dotnet/com_extension_arginfo.h index b5773f17fda3d..a2bcbf31c968b 100644 --- a/ext/com_dotnet/com_extension_arginfo.h +++ b/ext/com_dotnet/com_extension_arginfo.h @@ -281,8 +281,6 @@ static void register_com_extension_symbols(int module_number) REGISTER_LONG_CONSTANT("MK_E_UNAVAILABLE", PHP_MK_E_UNAVAILABLE, CONST_PERSISTENT); #if SIZEOF_ZEND_LONG == 8 REGISTER_LONG_CONSTANT("VT_UI8", VT_UI8, CONST_PERSISTENT); -#endif -#if SIZEOF_ZEND_LONG == 8 REGISTER_LONG_CONSTANT("VT_I8", VT_I8, CONST_PERSISTENT); #endif } diff --git a/ext/curl/curl_arginfo.h b/ext/curl/curl_arginfo.h index 8928da3f47453..ef267cd803ba2 100644 --- a/ext/curl/curl_arginfo.h +++ b/ext/curl/curl_arginfo.h @@ -328,11 +328,7 @@ static void register_curl_symbols(int module_number) REGISTER_LONG_CONSTANT("CURLOPT_DEBUGFUNCTION", CURLOPT_DEBUGFUNCTION, CONST_PERSISTENT); #if LIBCURL_VERSION_NUM >= 0x080d00 /* Available since 8.13.0 */ REGISTER_LONG_CONSTANT("CURLFOLLOW_ALL", CURLFOLLOW_ALL, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x080d00 /* Available since 8.13.0 */ REGISTER_LONG_CONSTANT("CURLFOLLOW_OBEYCODE", CURLFOLLOW_OBEYCODE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x080d00 /* Available since 8.13.0 */ REGISTER_LONG_CONSTANT("CURLFOLLOW_FIRSTONLY", CURLFOLLOW_FIRSTONLY, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("CURLINFO_TEXT", CURLINFO_TEXT, CONST_PERSISTENT); @@ -436,14 +432,10 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ REGISTER_LONG_CONSTANT("CURLINFO_CAPATH", CURLINFO_CAPATH, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ REGISTER_LONG_CONSTANT("CURLINFO_CAINFO", CURLINFO_CAINFO, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x080c00 /* Available since 8.12.0 */ REGISTER_LONG_CONSTANT("CURLINFO_HTTPAUTH_USED", CURLINFO_HTTPAUTH_USED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x080c00 /* Available since 8.12.0 */ REGISTER_LONG_CONSTANT("CURLINFO_PROXYAUTH_USED", CURLINFO_PROXYAUTH_USED, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("CURLMSG_DONE", CURLMSG_DONE, CONST_PERSISTENT); @@ -838,11 +830,7 @@ static void register_curl_symbols(int module_number) REGISTER_LONG_CONSTANT("CURLOPT_TLS13_CIPHERS", CURLOPT_TLS13_CIPHERS, CONST_PERSISTENT); #if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */ REGISTER_LONG_CONSTANT("CURLOPT_DOH_URL", CURLOPT_DOH_URL, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */ REGISTER_LONG_CONSTANT("CURLOPT_UPKEEP_INTERVAL_MS", CURLOPT_UPKEEP_INTERVAL_MS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */ REGISTER_LONG_CONSTANT("CURLOPT_UPLOAD_BUFFERSIZE", CURLOPT_UPLOAD_BUFFERSIZE, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074000 /* Available since 7.64.0 */ @@ -850,23 +838,11 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLALTSVC_H1", CURLALTSVC_H1, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLALTSVC_H2", CURLALTSVC_H2, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLALTSVC_H3", CURLALTSVC_H3, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLALTSVC_READONLYFILE", CURLALTSVC_READONLYFILE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLOPT_ALTSVC", CURLOPT_ALTSVC, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURLOPT_ALTSVC_CTRL", CURLOPT_ALTSVC_CTRL, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074001 /* Available since 7.64.1 */ REGISTER_LONG_CONSTANT("CURL_VERSION_ALTSVC", CURL_VERSION_ALTSVC, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074100 /* Available since 7.65.0 */ @@ -874,14 +850,8 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SASL_AUTHZID", CURLOPT_SASL_AUTHZID, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */ REGISTER_LONG_CONSTANT("CURL_VERSION_HTTP3", CURL_VERSION_HTTP3, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */ REGISTER_LONG_CONSTANT("CURLINFO_RETRY_AFTER", CURLINFO_RETRY_AFTER, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074200 /* Available since 7.66.0 */ REGISTER_LONG_CONSTANT("CURL_HTTP_VERSION_3", CURL_HTTP_VERSION_3, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074300 /* Available since 7.67.0 */ @@ -898,212 +868,90 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_ISSUERCERT_BLOB", CURLOPT_ISSUERCERT_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROXY_ISSUERCERT", CURLOPT_PROXY_ISSUERCERT, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROXY_ISSUERCERT_BLOB", CURLOPT_PROXY_ISSUERCERT_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROXY_SSLCERT_BLOB", CURLOPT_PROXY_SSLCERT_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROXY_SSLKEY_BLOB", CURLOPT_PROXY_SSLKEY_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SSLCERT_BLOB", CURLOPT_SSLCERT_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SSLKEY_BLOB", CURLOPT_SSLKEY_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLPROTO_MQTT", CURLPROTO_MQTT, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ REGISTER_LONG_CONSTANT("CURLSSLOPT_NATIVE_CA", CURLSSLOPT_NATIVE_CA, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 */ REGISTER_LONG_CONSTANT("CURL_VERSION_UNICODE", CURL_VERSION_UNICODE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 */ REGISTER_LONG_CONSTANT("CURL_VERSION_ZSTD", CURL_VERSION_ZSTD, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLE_PROXY", CURLE_PROXY, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLINFO_PROXY_ERROR", CURLINFO_PROXY_ERROR, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SSL_EC_CURVES", CURLOPT_SSL_EC_CURVES, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_BAD_ADDRESS_TYPE", CURLPX_BAD_ADDRESS_TYPE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_BAD_VERSION", CURLPX_BAD_VERSION, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_CLOSED", CURLPX_CLOSED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_GSSAPI", CURLPX_GSSAPI, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_GSSAPI_PERMSG", CURLPX_GSSAPI_PERMSG, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_GSSAPI_PROTECTION", CURLPX_GSSAPI_PROTECTION, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_IDENTD", CURLPX_IDENTD, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_IDENTD_DIFFER", CURLPX_IDENTD_DIFFER, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_LONG_HOSTNAME", CURLPX_LONG_HOSTNAME, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_LONG_PASSWD", CURLPX_LONG_PASSWD, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_LONG_USER", CURLPX_LONG_USER, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_NO_AUTH", CURLPX_NO_AUTH, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_OK", CURLPX_OK, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_RECV_ADDRESS", CURLPX_RECV_ADDRESS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_RECV_AUTH", CURLPX_RECV_AUTH, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_RECV_CONNECT", CURLPX_RECV_CONNECT, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_RECV_REQACK", CURLPX_RECV_REQACK, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED", CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_COMMAND_NOT_SUPPORTED", CURLPX_REPLY_COMMAND_NOT_SUPPORTED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_CONNECTION_REFUSED", CURLPX_REPLY_CONNECTION_REFUSED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_GENERAL_SERVER_FAILURE", CURLPX_REPLY_GENERAL_SERVER_FAILURE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_HOST_UNREACHABLE", CURLPX_REPLY_HOST_UNREACHABLE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_NETWORK_UNREACHABLE", CURLPX_REPLY_NETWORK_UNREACHABLE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_NOT_ALLOWED", CURLPX_REPLY_NOT_ALLOWED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_TTL_EXPIRED", CURLPX_REPLY_TTL_EXPIRED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REPLY_UNASSIGNED", CURLPX_REPLY_UNASSIGNED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_REQUEST_FAILED", CURLPX_REQUEST_FAILED, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_RESOLVE_HOST", CURLPX_RESOLVE_HOST, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_SEND_AUTH", CURLPX_SEND_AUTH, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_SEND_CONNECT", CURLPX_SEND_CONNECT, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_SEND_REQUEST", CURLPX_SEND_REQUEST, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_UNKNOWN_FAIL", CURLPX_UNKNOWN_FAIL, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_UNKNOWN_MODE", CURLPX_UNKNOWN_MODE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074900 /* Available since 7.73.0 */ REGISTER_LONG_CONSTANT("CURLPX_USER_REJECTED", CURLPX_USER_REJECTED, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */ REGISTER_LONG_CONSTANT("CURLHSTS_ENABLE", CURLHSTS_ENABLE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */ REGISTER_LONG_CONSTANT("CURLHSTS_READONLYFILE", CURLHSTS_READONLYFILE, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */ REGISTER_LONG_CONSTANT("CURLOPT_HSTS", CURLOPT_HSTS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */ REGISTER_LONG_CONSTANT("CURLOPT_HSTS_CTRL", CURLOPT_HSTS_CTRL, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074a00 /* Available since 7.74.0 */ REGISTER_LONG_CONSTANT("CURL_VERSION_HSTS", CURL_VERSION_HSTS, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074b00 /* Available since 7.75.0 */ REGISTER_LONG_CONSTANT("CURLAUTH_AWS_SIGV4", CURLAUTH_AWS_SIGV4, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074b00 /* Available since 7.75.0 */ REGISTER_LONG_CONSTANT("CURLOPT_AWS_SIGV4", CURLOPT_AWS_SIGV4, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */ REGISTER_LONG_CONSTANT("CURLINFO_REFERER", CURLINFO_REFERER, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */ REGISTER_LONG_CONSTANT("CURLOPT_DOH_SSL_VERIFYHOST", CURLOPT_DOH_SSL_VERIFYHOST, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */ REGISTER_LONG_CONSTANT("CURLOPT_DOH_SSL_VERIFYPEER", CURLOPT_DOH_SSL_VERIFYPEER, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */ REGISTER_LONG_CONSTANT("CURLOPT_DOH_SSL_VERIFYSTATUS", CURLOPT_DOH_SSL_VERIFYSTATUS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074c00 /* Available since 7.76.0 */ REGISTER_LONG_CONSTANT("CURL_VERSION_GSASL", CURL_VERSION_GSASL, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x074d00 /* Available since 7.77.0 */ REGISTER_LONG_CONSTANT("CURLOPT_CAINFO_BLOB", CURLOPT_CAINFO_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074d00 /* Available since 7.77.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROXY_CAINFO_BLOB", CURLOPT_PROXY_CAINFO_BLOB, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x074d00 /* Available since 7.77.0 */ REGISTER_LONG_CONSTANT("CURLSSLOPT_AUTO_CLIENT_CERT", CURLSSLOPT_AUTO_CLIENT_CERT, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURLOPT_MAXLIFETIME_CONN", CURLOPT_MAXLIFETIME_CONN, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256", CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PREREQFUNCTION", CURLOPT_PREREQFUNCTION, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURL_PREREQFUNC_OK", CURL_PREREQFUNC_OK, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURL_PREREQFUNC_ABORT", CURL_PREREQFUNC_ABORT, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ REGISTER_LONG_CONSTANT("CURLOPT_MIME_OPTIONS", CURLOPT_MIME_OPTIONS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ REGISTER_LONG_CONSTANT("CURLMIMEOPT_FORMESCAPE", CURLMIMEOPT_FORMESCAPE, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ @@ -1111,20 +959,14 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ REGISTER_LONG_CONSTANT("CURLOPT_PROTOCOLS_STR", CURLOPT_PROTOCOLS_STR, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ REGISTER_LONG_CONSTANT("CURLOPT_REDIR_PROTOCOLS_STR", CURLOPT_REDIR_PROTOCOLS_STR, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ REGISTER_LONG_CONSTANT("CURLOPT_WS_OPTIONS", CURLOPT_WS_OPTIONS, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ REGISTER_LONG_CONSTANT("CURLWS_RAW_MODE", CURLWS_RAW_MODE, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ REGISTER_LONG_CONSTANT("CURLOPT_CA_CACHE_TIMEOUT", CURLOPT_CA_CACHE_TIMEOUT, CONST_PERSISTENT); -#endif -#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ REGISTER_LONG_CONSTANT("CURLOPT_QUICK_EXIT", CURLOPT_QUICK_EXIT, CONST_PERSISTENT); #endif #if LIBCURL_VERSION_NUM >= 0x075800 /* Available since 7.88.0 */ diff --git a/ext/dba/dba_arginfo.h b/ext/dba/dba_arginfo.h index 97a45381c92bf..c2befedfda7c7 100644 --- a/ext/dba/dba_arginfo.h +++ b/ext/dba/dba_arginfo.h @@ -99,8 +99,6 @@ static void register_dba_symbols(int module_number) { #if defined(DBA_LMDB) REGISTER_LONG_CONSTANT("DBA_LMDB_USE_SUB_DIR", 0, CONST_PERSISTENT); -#endif -#if defined(DBA_LMDB) REGISTER_LONG_CONSTANT("DBA_LMDB_NO_SUB_DIR", MDB_NOSUBDIR, CONST_PERSISTENT); #endif } diff --git a/ext/gd/gd_arginfo.h b/ext/gd/gd_arginfo.h index 5cf4f2f29a9bd..c80aaac463348 100644 --- a/ext/gd/gd_arginfo.h +++ b/ext/gd/gd_arginfo.h @@ -932,35 +932,17 @@ static void register_gd_symbols(int module_number) #endif #if (defined(GD_MAJOR_VERSION) && defined(GD_MINOR_VERSION) && defined(GD_RELEASE_VERSION) && defined(GD_EXTRA_VERSION)) REGISTER_LONG_CONSTANT("GD_MAJOR_VERSION", GD_MAJOR_VERSION, CONST_PERSISTENT); -#endif -#if (defined(GD_MAJOR_VERSION) && defined(GD_MINOR_VERSION) && defined(GD_RELEASE_VERSION) && defined(GD_EXTRA_VERSION)) REGISTER_LONG_CONSTANT("GD_MINOR_VERSION", GD_MINOR_VERSION, CONST_PERSISTENT); -#endif -#if (defined(GD_MAJOR_VERSION) && defined(GD_MINOR_VERSION) && defined(GD_RELEASE_VERSION) && defined(GD_EXTRA_VERSION)) REGISTER_LONG_CONSTANT("GD_RELEASE_VERSION", GD_RELEASE_VERSION, CONST_PERSISTENT); -#endif -#if (defined(GD_MAJOR_VERSION) && defined(GD_MINOR_VERSION) && defined(GD_RELEASE_VERSION) && defined(GD_EXTRA_VERSION)) REGISTER_STRING_CONSTANT("GD_EXTRA_VERSION", GD_EXTRA_VERSION, CONST_PERSISTENT); #endif #if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_NO_FILTER", 0x0, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_FILTER_NONE", 0x8, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_FILTER_SUB", 0x10, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_FILTER_UP", 0x20, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_FILTER_AVG", 0x40, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_FILTER_PAETH", 0x80, CONST_PERSISTENT); -#endif -#if defined(HAVE_GD_PNG) REGISTER_LONG_CONSTANT("PNG_ALL_FILTERS", 0x8 | 0x10 | 0x20 | 0x40 | 0x80, CONST_PERSISTENT); #endif } diff --git a/ext/intl/listformatter/listformatter_arginfo.h b/ext/intl/listformatter/listformatter_arginfo.h index d9a4c3fb84ddc..3a2afa2d1c2d9 100644 --- a/ext/intl/listformatter/listformatter_arginfo.h +++ b/ext/intl/listformatter/listformatter_arginfo.h @@ -59,16 +59,12 @@ static zend_class_entry *register_class_IntlListFormatter(void) zend_string *const_TYPE_OR_name = zend_string_init_interned("TYPE_OR", sizeof("TYPE_OR") - 1, 1); zend_declare_typed_class_constant(class_entry, const_TYPE_OR_name, &const_TYPE_OR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_TYPE_OR_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 67 zval const_TYPE_UNITS_value; ZVAL_LONG(&const_TYPE_UNITS_value, ULISTFMT_TYPE_UNITS); zend_string *const_TYPE_UNITS_name = zend_string_init_interned("TYPE_UNITS", sizeof("TYPE_UNITS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_TYPE_UNITS_name, &const_TYPE_UNITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_TYPE_UNITS_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 67 zval const_WIDTH_WIDE_value; ZVAL_LONG(&const_WIDTH_WIDE_value, ULISTFMT_WIDTH_WIDE); @@ -91,8 +87,6 @@ static zend_class_entry *register_class_IntlListFormatter(void) zend_string *const_WIDTH_SHORT_name = zend_string_init_interned("WIDTH_SHORT", sizeof("WIDTH_SHORT") - 1, 1); zend_declare_typed_class_constant(class_entry, const_WIDTH_SHORT_name, &const_WIDTH_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_WIDTH_SHORT_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 67 zval const_WIDTH_NARROW_value; ZVAL_LONG(&const_WIDTH_NARROW_value, ULISTFMT_WIDTH_NARROW); diff --git a/ext/intl/spoofchecker/spoofchecker_arginfo.h b/ext/intl/spoofchecker/spoofchecker_arginfo.h index cee17335dcd40..6a3c0e55aa27d 100644 --- a/ext/intl/spoofchecker/spoofchecker_arginfo.h +++ b/ext/intl/spoofchecker/spoofchecker_arginfo.h @@ -112,48 +112,36 @@ static zend_class_entry *register_class_Spoofchecker(void) zend_string *const_ASCII_name = zend_string_init_interned("ASCII", sizeof("ASCII") - 1, 1); zend_declare_typed_class_constant(class_entry, const_ASCII_name, &const_ASCII_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_ASCII_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_HIGHLY_RESTRICTIVE_value; ZVAL_LONG(&const_HIGHLY_RESTRICTIVE_value, USPOOF_HIGHLY_RESTRICTIVE); zend_string *const_HIGHLY_RESTRICTIVE_name = zend_string_init_interned("HIGHLY_RESTRICTIVE", sizeof("HIGHLY_RESTRICTIVE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_HIGHLY_RESTRICTIVE_name, &const_HIGHLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_HIGHLY_RESTRICTIVE_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_MODERATELY_RESTRICTIVE_value; ZVAL_LONG(&const_MODERATELY_RESTRICTIVE_value, USPOOF_MODERATELY_RESTRICTIVE); zend_string *const_MODERATELY_RESTRICTIVE_name = zend_string_init_interned("MODERATELY_RESTRICTIVE", sizeof("MODERATELY_RESTRICTIVE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_MODERATELY_RESTRICTIVE_name, &const_MODERATELY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_MODERATELY_RESTRICTIVE_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_MINIMALLY_RESTRICTIVE_value; ZVAL_LONG(&const_MINIMALLY_RESTRICTIVE_value, USPOOF_MINIMALLY_RESTRICTIVE); zend_string *const_MINIMALLY_RESTRICTIVE_name = zend_string_init_interned("MINIMALLY_RESTRICTIVE", sizeof("MINIMALLY_RESTRICTIVE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_MINIMALLY_RESTRICTIVE_name, &const_MINIMALLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_MINIMALLY_RESTRICTIVE_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_UNRESTRICTIVE_value; ZVAL_LONG(&const_UNRESTRICTIVE_value, USPOOF_UNRESTRICTIVE); zend_string *const_UNRESTRICTIVE_name = zend_string_init_interned("UNRESTRICTIVE", sizeof("UNRESTRICTIVE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_UNRESTRICTIVE_name, &const_UNRESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_UNRESTRICTIVE_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_SINGLE_SCRIPT_RESTRICTIVE_value; ZVAL_LONG(&const_SINGLE_SCRIPT_RESTRICTIVE_value, USPOOF_SINGLE_SCRIPT_RESTRICTIVE); zend_string *const_SINGLE_SCRIPT_RESTRICTIVE_name = zend_string_init_interned("SINGLE_SCRIPT_RESTRICTIVE", sizeof("SINGLE_SCRIPT_RESTRICTIVE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_SINGLE_SCRIPT_RESTRICTIVE_name, &const_SINGLE_SCRIPT_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_SINGLE_SCRIPT_RESTRICTIVE_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_MIXED_NUMBERS_value; ZVAL_LONG(&const_MIXED_NUMBERS_value, USPOOF_MIXED_NUMBERS); diff --git a/ext/intl/uchar/uchar_arginfo.h b/ext/intl/uchar/uchar_arginfo.h index 085b3b0a5eff3..f290fb2b958ec 100644 --- a/ext/intl/uchar/uchar_arginfo.h +++ b/ext/intl/uchar/uchar_arginfo.h @@ -465,16 +465,12 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_PROPERTY_IDS_UNARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_UNARY_OPERATOR", sizeof("PROPERTY_IDS_UNARY_OPERATOR") - 1, 1); zend_declare_typed_class_constant(class_entry, const_PROPERTY_IDS_UNARY_OPERATOR_name, &const_PROPERTY_IDS_UNARY_OPERATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_PROPERTY_IDS_UNARY_OPERATOR_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 74 zval const_PROPERTY_ID_COMPAT_MATH_START_value; ZVAL_LONG(&const_PROPERTY_ID_COMPAT_MATH_START_value, UCHAR_ID_COMPAT_MATH_START); zend_string *const_PROPERTY_ID_COMPAT_MATH_START_name = zend_string_init_interned("PROPERTY_ID_COMPAT_MATH_START", sizeof("PROPERTY_ID_COMPAT_MATH_START") - 1, 1); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ID_COMPAT_MATH_START_name, &const_PROPERTY_ID_COMPAT_MATH_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_PROPERTY_ID_COMPAT_MATH_START_name); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 74 zval const_PROPERTY_ID_COMPAT_MATH_CONTINUE_value; ZVAL_LONG(&const_PROPERTY_ID_COMPAT_MATH_CONTINUE_value, UCHAR_ID_COMPAT_MATH_CONTINUE); diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h index 984a4bab9a69f..3341b736bb2f1 100644 --- a/ext/ldap/ldap_arginfo.h +++ b/ext/ldap/ldap_arginfo.h @@ -541,11 +541,7 @@ static void register_ldap_symbols(int module_number) REGISTER_STRING_CONSTANT("LDAP_MODIFY_BATCH_VALUES", LDAP_MODIFY_BATCH_VALUES, CONST_PERSISTENT); #if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT); -#endif -#if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT); -#endif -#if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_TIMELIMIT", LDAP_OPT_TIMELIMIT, CONST_PERSISTENT); #endif #if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) && defined(LDAP_OPT_NETWORK_TIMEOUT) @@ -559,11 +555,7 @@ static void register_ldap_symbols(int module_number) #endif #if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_PROTOCOL_VERSION", LDAP_OPT_PROTOCOL_VERSION, CONST_PERSISTENT); -#endif -#if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_ERROR_NUMBER", LDAP_OPT_ERROR_NUMBER, CONST_PERSISTENT); -#endif -#if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_REFERRALS", LDAP_OPT_REFERRALS, CONST_PERSISTENT); #endif #if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) && defined(LDAP_OPT_RESTART) @@ -580,8 +572,6 @@ static void register_ldap_symbols(int module_number) #endif #if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_SERVER_CONTROLS", LDAP_OPT_SERVER_CONTROLS, CONST_PERSISTENT); -#endif -#if ((LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)) REGISTER_LONG_CONSTANT("LDAP_OPT_CLIENT_CONTROLS", LDAP_OPT_CLIENT_CONTROLS, CONST_PERSISTENT); #endif #if defined(LDAP_OPT_DEBUG_LEVEL) @@ -592,14 +582,8 @@ static void register_ldap_symbols(int module_number) #endif #if defined(HAVE_LDAP_SASL) REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_MECH", LDAP_OPT_X_SASL_MECH, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_SASL) REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_REALM", LDAP_OPT_X_SASL_REALM, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_SASL) REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_AUTHCID", LDAP_OPT_X_SASL_AUTHCID, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_SASL) REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_AUTHZID", LDAP_OPT_X_SASL_AUTHZID, CONST_PERSISTENT); #endif #if defined(LDAP_OPT_X_SASL_NOCANON) @@ -610,59 +594,27 @@ static void register_ldap_symbols(int module_number) #endif #if defined(HAVE_ORALDAP) REGISTER_LONG_CONSTANT("GSLC_SSL_NO_AUTH", GSLC_SSL_NO_AUTH, CONST_PERSISTENT); -#endif -#if defined(HAVE_ORALDAP) REGISTER_LONG_CONSTANT("GSLC_SSL_ONEWAY_AUTH", GSLC_SSL_ONEWAY_AUTH, CONST_PERSISTENT); -#endif -#if defined(HAVE_ORALDAP) REGISTER_LONG_CONSTANT("GSLC_SSL_TWOWAY_AUTH", GSLC_SSL_TWOWAY_AUTH, CONST_PERSISTENT); #endif #if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_REQUIRE_CERT", LDAP_OPT_X_TLS_REQUIRE_CERT, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_NEVER", LDAP_OPT_X_TLS_NEVER, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_HARD", LDAP_OPT_X_TLS_HARD, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_DEMAND", LDAP_OPT_X_TLS_DEMAND, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_ALLOW", LDAP_OPT_X_TLS_ALLOW, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_TRY", LDAP_OPT_X_TLS_TRY, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CACERTDIR", LDAP_OPT_X_TLS_CACERTDIR, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CACERTFILE", LDAP_OPT_X_TLS_CACERTFILE, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CERTFILE", LDAP_OPT_X_TLS_CERTFILE, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CIPHER_SUITE", LDAP_OPT_X_TLS_CIPHER_SUITE, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_KEYFILE", LDAP_OPT_X_TLS_KEYFILE, CONST_PERSISTENT); -#endif -#if (LDAP_API_VERSION > 2000) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_RANDOM_FILE", LDAP_OPT_X_TLS_RANDOM_FILE, CONST_PERSISTENT); #endif #if defined(LDAP_OPT_X_TLS_CRLCHECK) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CRLCHECK", LDAP_OPT_X_TLS_CRLCHECK, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_CRLCHECK) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CRL_NONE", LDAP_OPT_X_TLS_CRL_NONE, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_CRLCHECK) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CRL_PEER", LDAP_OPT_X_TLS_CRL_PEER, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_CRLCHECK) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_CRL_ALL", LDAP_OPT_X_TLS_CRL_ALL, CONST_PERSISTENT); #endif #if defined(LDAP_OPT_X_TLS_DHFILE) @@ -673,20 +625,10 @@ static void register_ldap_symbols(int module_number) #endif #if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_MIN", LDAP_OPT_X_TLS_PROTOCOL_MIN, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_SSL2", LDAP_OPT_X_TLS_PROTOCOL_SSL2, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_SSL3", LDAP_OPT_X_TLS_PROTOCOL_SSL3, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_TLS1_0", LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_TLS1_1", LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_TLS_PROTOCOL_MIN) REGISTER_LONG_CONSTANT("LDAP_OPT_X_TLS_PROTOCOL_TLS1_2", LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, CONST_PERSISTENT); #endif #if defined(LDAP_OPT_X_TLS_PROTOCOL_TLS1_3) @@ -700,28 +642,16 @@ static void register_ldap_symbols(int module_number) #endif #if defined(LDAP_OPT_X_KEEPALIVE_IDLE) REGISTER_LONG_CONSTANT("LDAP_OPT_X_KEEPALIVE_IDLE", LDAP_OPT_X_KEEPALIVE_IDLE, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_KEEPALIVE_IDLE) REGISTER_LONG_CONSTANT("LDAP_OPT_X_KEEPALIVE_PROBES", LDAP_OPT_X_KEEPALIVE_PROBES, CONST_PERSISTENT); -#endif -#if defined(LDAP_OPT_X_KEEPALIVE_IDLE) REGISTER_LONG_CONSTANT("LDAP_OPT_X_KEEPALIVE_INTERVAL", LDAP_OPT_X_KEEPALIVE_INTERVAL, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("LDAP_ESCAPE_FILTER", PHP_LDAP_ESCAPE_FILTER, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LDAP_ESCAPE_DN", PHP_LDAP_ESCAPE_DN, CONST_PERSISTENT); #if defined(HAVE_LDAP_EXTENDED_OPERATION_S) REGISTER_STRING_CONSTANT("LDAP_EXOP_START_TLS", LDAP_EXOP_START_TLS, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) REGISTER_STRING_CONSTANT("LDAP_EXOP_MODIFY_PASSWD", LDAP_EXOP_MODIFY_PASSWD, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) REGISTER_STRING_CONSTANT("LDAP_EXOP_REFRESH", LDAP_EXOP_REFRESH, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) REGISTER_STRING_CONSTANT("LDAP_EXOP_WHO_AM_I", LDAP_EXOP_WHO_AM_I, CONST_PERSISTENT); -#endif -#if defined(HAVE_LDAP_EXTENDED_OPERATION_S) REGISTER_STRING_CONSTANT("LDAP_EXOP_TURN", LDAP_EXOP_TURN, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_MANAGEDSAIT) @@ -738,17 +668,11 @@ static void register_ldap_symbols(int module_number) #endif #if defined(LDAP_CONTROL_ASSERT) REGISTER_STRING_CONSTANT("LDAP_CONTROL_ASSERT", LDAP_CONTROL_ASSERT, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_ASSERT) REGISTER_STRING_CONSTANT("LDAP_CONTROL_PRE_READ", LDAP_CONTROL_PRE_READ, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_ASSERT) REGISTER_STRING_CONSTANT("LDAP_CONTROL_POST_READ", LDAP_CONTROL_POST_READ, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_SORTREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_SORTREQUEST", LDAP_CONTROL_SORTREQUEST, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_SORTREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_SORTRESPONSE", LDAP_CONTROL_SORTRESPONSE, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_PAGEDRESULTS) @@ -756,17 +680,11 @@ static void register_ldap_symbols(int module_number) #endif #if defined(LDAP_CONTROL_AUTHZID_REQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_AUTHZID_REQUEST", LDAP_CONTROL_AUTHZID_REQUEST, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_AUTHZID_REQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_AUTHZID_RESPONSE", LDAP_CONTROL_AUTHZID_RESPONSE, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_SYNC) REGISTER_STRING_CONSTANT("LDAP_CONTROL_SYNC", LDAP_CONTROL_SYNC, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_SYNC) REGISTER_STRING_CONSTANT("LDAP_CONTROL_SYNC_STATE", LDAP_CONTROL_SYNC_STATE, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_SYNC) REGISTER_STRING_CONSTANT("LDAP_CONTROL_SYNC_DONE", LDAP_CONTROL_SYNC_DONE, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_DONTUSECOPY) @@ -774,32 +692,18 @@ static void register_ldap_symbols(int module_number) #endif #if defined(LDAP_CONTROL_PASSWORDPOLICYREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_PASSWORDPOLICYREQUEST", LDAP_CONTROL_PASSWORDPOLICYREQUEST, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_PASSWORDPOLICYREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_PASSWORDPOLICYRESPONSE", LDAP_CONTROL_PASSWORDPOLICYRESPONSE, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_INCREMENTAL_VALUES", LDAP_CONTROL_X_INCREMENTAL_VALUES, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_DOMAIN_SCOPE", LDAP_CONTROL_X_DOMAIN_SCOPE, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_PERMISSIVE_MODIFY", LDAP_CONTROL_X_PERMISSIVE_MODIFY, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_SEARCH_OPTIONS", LDAP_CONTROL_X_SEARCH_OPTIONS, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_TREE_DELETE", LDAP_CONTROL_X_TREE_DELETE, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_X_INCREMENTAL_VALUES) REGISTER_STRING_CONSTANT("LDAP_CONTROL_X_EXTENDED_DN", LDAP_CONTROL_X_EXTENDED_DN, CONST_PERSISTENT); #endif #if defined(LDAP_CONTROL_VLVREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_VLVREQUEST", LDAP_CONTROL_VLVREQUEST, CONST_PERSISTENT); -#endif -#if defined(LDAP_CONTROL_VLVREQUEST) REGISTER_STRING_CONSTANT("LDAP_CONTROL_VLVRESPONSE", LDAP_CONTROL_VLVRESPONSE, CONST_PERSISTENT); #endif diff --git a/ext/odbc/odbc_arginfo.h b/ext/odbc/odbc_arginfo.h index 91df4da846d49..d458fee43383b 100644 --- a/ext/odbc/odbc_arginfo.h +++ b/ext/odbc/odbc_arginfo.h @@ -410,53 +410,21 @@ static void register_odbc_symbols(int module_number) REGISTER_LONG_CONSTANT("SQL_TIMESTAMP", SQL_TIMESTAMP, CONST_PERSISTENT); #if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_TYPE_DATE", SQL_TYPE_DATE, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_TYPE_TIME", SQL_TYPE_TIME, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_TYPE_TIMESTAMP", SQL_TYPE_TIMESTAMP, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_WCHAR", SQL_WCHAR, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_WVARCHAR", SQL_WVARCHAR, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_WLONGVARCHAR", SQL_WLONGVARCHAR, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_BEST_ROWID", SQL_BEST_ROWID, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_ROWVER", SQL_ROWVER, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_SCOPE_CURROW", SQL_SCOPE_CURROW, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_SCOPE_TRANSACTION", SQL_SCOPE_TRANSACTION, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_SCOPE_SESSION", SQL_SCOPE_SESSION, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_NO_NULLS", SQL_NO_NULLS, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_NULLABLE", SQL_NULLABLE, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_INDEX_UNIQUE", SQL_INDEX_UNIQUE, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_INDEX_ALL", SQL_INDEX_ALL, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_ENSURE", SQL_ENSURE, CONST_PERSISTENT); -#endif -#if (defined(ODBCVER) && (ODBCVER >= 0x0300)) REGISTER_LONG_CONSTANT("SQL_QUICK", SQL_QUICK, CONST_PERSISTENT); #endif diff --git a/ext/openssl/openssl_arginfo.h b/ext/openssl/openssl_arginfo.h index 94f59ce268510..fb53dcae903e7 100644 --- a/ext/openssl/openssl_arginfo.h +++ b/ext/openssl/openssl_arginfo.h @@ -600,26 +600,16 @@ static void register_openssl_symbols(int module_number) REGISTER_STRING_CONSTANT("OPENSSL_DEFAULT_STREAM_CIPHERS", OPENSSL_DEFAULT_STREAM_CIPHERS, CONST_PERSISTENT); #if !defined(OPENSSL_NO_RC2) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_40", PHP_OPENSSL_CIPHER_RC2_40, CONST_PERSISTENT); -#endif -#if !defined(OPENSSL_NO_RC2) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_128", PHP_OPENSSL_CIPHER_RC2_128, CONST_PERSISTENT); -#endif -#if !defined(OPENSSL_NO_RC2) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_RC2_64", PHP_OPENSSL_CIPHER_RC2_64, CONST_PERSISTENT); #endif #if !defined(OPENSSL_NO_DES) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_DES", PHP_OPENSSL_CIPHER_DES, CONST_PERSISTENT); -#endif -#if !defined(OPENSSL_NO_DES) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_3DES", PHP_OPENSSL_CIPHER_3DES, CONST_PERSISTENT); #endif #if !defined(OPENSSL_NO_AES) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_128_CBC", PHP_OPENSSL_CIPHER_AES_128_CBC, CONST_PERSISTENT); -#endif -#if !defined(OPENSSL_NO_AES) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_192_CBC", PHP_OPENSSL_CIPHER_AES_192_CBC, CONST_PERSISTENT); -#endif -#if !defined(OPENSSL_NO_AES) REGISTER_LONG_CONSTANT("OPENSSL_CIPHER_AES_256_CBC", PHP_OPENSSL_CIPHER_AES_256_CBC, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_RSA", OPENSSL_KEYTYPE_RSA, CONST_PERSISTENT); @@ -632,14 +622,8 @@ static void register_openssl_symbols(int module_number) #endif #if PHP_OPENSSL_API_VERSION >= 0x30000 REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_X25519", OPENSSL_KEYTYPE_X25519, CONST_PERSISTENT); -#endif -#if PHP_OPENSSL_API_VERSION >= 0x30000 REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_ED25519", OPENSSL_KEYTYPE_ED25519, CONST_PERSISTENT); -#endif -#if PHP_OPENSSL_API_VERSION >= 0x30000 REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_X448", OPENSSL_KEYTYPE_X448, CONST_PERSISTENT); -#endif -#if PHP_OPENSSL_API_VERSION >= 0x30000 REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_ED448", OPENSSL_KEYTYPE_ED448, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("OPENSSL_RAW_DATA", OPENSSL_RAW_DATA, CONST_PERSISTENT); diff --git a/ext/openssl/openssl_pwhash_arginfo.h b/ext/openssl/openssl_pwhash_arginfo.h index 7696675a5a84f..b4213158a169a 100644 --- a/ext/openssl/openssl_pwhash_arginfo.h +++ b/ext/openssl/openssl_pwhash_arginfo.h @@ -5,20 +5,10 @@ static void register_openssl_pwhash_symbols(int module_number) { #if defined(HAVE_OPENSSL_ARGON2) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2I", "argon2i", CONST_PERSISTENT); -#endif -#if defined(HAVE_OPENSSL_ARGON2) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2ID", "argon2id", CONST_PERSISTENT); -#endif -#if defined(HAVE_OPENSSL_ARGON2) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_MEMORY_COST", PHP_OPENSSL_PWHASH_MEMLIMIT, CONST_PERSISTENT); -#endif -#if defined(HAVE_OPENSSL_ARGON2) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_TIME_COST", PHP_OPENSSL_PWHASH_ITERLIMIT, CONST_PERSISTENT); -#endif -#if defined(HAVE_OPENSSL_ARGON2) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_THREADS", PHP_OPENSSL_PWHASH_THREADS, CONST_PERSISTENT); -#endif -#if defined(HAVE_OPENSSL_ARGON2) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2_PROVIDER", "openssl", CONST_PERSISTENT); #endif } diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 8da7cb70a6aa7..bc6581d41e17e 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -317,11 +317,7 @@ static void register_pcntl_symbols(int module_number) #endif #if defined(HAVE_WAITID) && defined(HAVE_POSIX_IDTYPES) REGISTER_LONG_CONSTANT("P_ALL", LONG_CONST(P_ALL), CONST_PERSISTENT); -#endif -#if defined(HAVE_WAITID) && defined(HAVE_POSIX_IDTYPES) REGISTER_LONG_CONSTANT("P_PID", LONG_CONST(P_PID), CONST_PERSISTENT); -#endif -#if defined(HAVE_WAITID) && defined(HAVE_POSIX_IDTYPES) REGISTER_LONG_CONSTANT("P_PGID", LONG_CONST(P_PGID), CONST_PERSISTENT); #endif #if defined(HAVE_WAITID) && defined(HAVE_LINUX_IDTYPES) @@ -329,11 +325,7 @@ static void register_pcntl_symbols(int module_number) #endif #if defined(HAVE_WAITID) && defined(HAVE_NETBSD_IDTYPES) REGISTER_LONG_CONSTANT("P_UID", LONG_CONST(P_UID), CONST_PERSISTENT); -#endif -#if defined(HAVE_WAITID) && defined(HAVE_NETBSD_IDTYPES) REGISTER_LONG_CONSTANT("P_GID", LONG_CONST(P_GID), CONST_PERSISTENT); -#endif -#if defined(HAVE_WAITID) && defined(HAVE_NETBSD_IDTYPES) REGISTER_LONG_CONSTANT("P_SID", LONG_CONST(P_SID), CONST_PERSISTENT); #endif #if defined(HAVE_WAITID) && defined(HAVE_FREEBSD_IDTYPES) @@ -394,8 +386,6 @@ static void register_pcntl_symbols(int module_number) #endif #if defined(SIGSYS) REGISTER_LONG_CONSTANT("SIGSYS", LONG_CONST(SIGSYS), CONST_PERSISTENT); -#endif -#if defined(SIGSYS) REGISTER_LONG_CONSTANT("SIGBABY", LONG_CONST(SIGSYS), CONST_PERSISTENT); #endif #if defined(SIGCKPT) @@ -412,26 +402,16 @@ static void register_pcntl_symbols(int module_number) #endif #if (defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY)) REGISTER_LONG_CONSTANT("PRIO_PGRP", PRIO_PGRP, CONST_PERSISTENT); -#endif -#if (defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY)) REGISTER_LONG_CONSTANT("PRIO_USER", PRIO_USER, CONST_PERSISTENT); -#endif -#if (defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY)) REGISTER_LONG_CONSTANT("PRIO_PROCESS", PRIO_PROCESS, CONST_PERSISTENT); #endif #if (defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY)) && defined(PRIO_DARWIN_BG) REGISTER_LONG_CONSTANT("PRIO_DARWIN_BG", PRIO_DARWIN_BG, CONST_PERSISTENT); -#endif -#if (defined(HAVE_GETPRIORITY) || defined(HAVE_SETPRIORITY)) && defined(PRIO_DARWIN_BG) REGISTER_LONG_CONSTANT("PRIO_DARWIN_THREAD", PRIO_DARWIN_THREAD, CONST_PERSISTENT); #endif #if defined(HAVE_SIGPROCMASK) REGISTER_LONG_CONSTANT("SIG_BLOCK", SIG_BLOCK, CONST_PERSISTENT); -#endif -#if defined(HAVE_SIGPROCMASK) REGISTER_LONG_CONSTANT("SIG_UNBLOCK", SIG_UNBLOCK, CONST_PERSISTENT); -#endif -#if defined(HAVE_SIGPROCMASK) REGISTER_LONG_CONSTANT("SIG_SETMASK", SIG_SETMASK, CONST_PERSISTENT); #endif #if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) @@ -445,14 +425,8 @@ static void register_pcntl_symbols(int module_number) #endif #if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) REGISTER_LONG_CONSTANT("SI_QUEUE", SI_QUEUE, CONST_PERSISTENT); -#endif -#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) REGISTER_LONG_CONSTANT("SI_TIMER", SI_TIMER, CONST_PERSISTENT); -#endif -#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) REGISTER_LONG_CONSTANT("SI_MESGQ", SI_MESGQ, CONST_PERSISTENT); -#endif -#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) REGISTER_LONG_CONSTANT("SI_ASYNCIO", SI_ASYNCIO, CONST_PERSISTENT); #endif #if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT)) && defined(SI_SIGIO) @@ -610,8 +584,6 @@ static void register_pcntl_symbols(int module_number) #endif #if defined(HAVE_FORKX) REGISTER_LONG_CONSTANT("FORK_NOSIGCHLD", FORK_NOSIGCHLD, CONST_PERSISTENT); -#endif -#if defined(HAVE_FORKX) REGISTER_LONG_CONSTANT("FORK_WAITPID", FORK_WAITPID, CONST_PERSISTENT); #endif #if defined(EINTR) diff --git a/ext/pdo_mysql/pdo_mysql_arginfo.h b/ext/pdo_mysql/pdo_mysql_arginfo.h index a6a1b5e1b5c78..0e9c04bd3cfd3 100644 --- a/ext/pdo_mysql/pdo_mysql_arginfo.h +++ b/ext/pdo_mysql/pdo_mysql_arginfo.h @@ -42,16 +42,12 @@ static zend_class_entry *register_class_Pdo_Mysql(zend_class_entry *class_entry_ zend_string *const_ATTR_MAX_BUFFER_SIZE_name = zend_string_init_interned("ATTR_MAX_BUFFER_SIZE", sizeof("ATTR_MAX_BUFFER_SIZE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_ATTR_MAX_BUFFER_SIZE_name, &const_ATTR_MAX_BUFFER_SIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_ATTR_MAX_BUFFER_SIZE_name); -#endif -#if !defined(PDO_USE_MYSQLND) zval const_ATTR_READ_DEFAULT_FILE_value; ZVAL_LONG(&const_ATTR_READ_DEFAULT_FILE_value, PDO_MYSQL_ATTR_READ_DEFAULT_FILE); zend_string *const_ATTR_READ_DEFAULT_FILE_name = zend_string_init_interned("ATTR_READ_DEFAULT_FILE", sizeof("ATTR_READ_DEFAULT_FILE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_ATTR_READ_DEFAULT_FILE_name, &const_ATTR_READ_DEFAULT_FILE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_ATTR_READ_DEFAULT_FILE_name); -#endif -#if !defined(PDO_USE_MYSQLND) zval const_ATTR_READ_DEFAULT_GROUP_value; ZVAL_LONG(&const_ATTR_READ_DEFAULT_GROUP_value, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); diff --git a/ext/pdo_sqlite/pdo_sqlite_arginfo.h b/ext/pdo_sqlite/pdo_sqlite_arginfo.h index 02cf12673ce53..e2cd71723706e 100644 --- a/ext/pdo_sqlite/pdo_sqlite_arginfo.h +++ b/ext/pdo_sqlite/pdo_sqlite_arginfo.h @@ -128,16 +128,12 @@ static zend_class_entry *register_class_Pdo_Sqlite(zend_class_entry *class_entry zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_PREPARED_name, &const_EXPLAIN_MODE_PREPARED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EXPLAIN_MODE_PREPARED_name); -#endif -#if SQLITE_VERSION_NUMBER >= 3043000 zval const_EXPLAIN_MODE_EXPLAIN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_value, 1); zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_name, &const_EXPLAIN_MODE_EXPLAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EXPLAIN_MODE_EXPLAIN_name); -#endif -#if SQLITE_VERSION_NUMBER >= 3043000 zval const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, 2); diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index 4be006bc7f0af..b7af6eb6b89ac 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -413,17 +413,9 @@ static void register_sockets_symbols(int module_number) #endif #if defined(SO_USER_COOKIE) REGISTER_LONG_CONSTANT("SO_LABEL", SO_LABEL, CONST_PERSISTENT); -#endif -#if defined(SO_USER_COOKIE) REGISTER_LONG_CONSTANT("SO_PEERLABEL", SO_PEERLABEL, CONST_PERSISTENT); -#endif -#if defined(SO_USER_COOKIE) REGISTER_LONG_CONSTANT("SO_LISTENQLIMIT", SO_LISTENQLIMIT, CONST_PERSISTENT); -#endif -#if defined(SO_USER_COOKIE) REGISTER_LONG_CONSTANT("SO_LISTENQLEN", SO_LISTENQLEN, CONST_PERSISTENT); -#endif -#if defined(SO_USER_COOKIE) REGISTER_LONG_CONSTANT("SO_USER_COOKIE", SO_USER_COOKIE, CONST_PERSISTENT); #endif #if defined(SO_SETFIB) @@ -443,11 +435,7 @@ static void register_sockets_symbols(int module_number) #endif #if defined(SOL_FILTER) REGISTER_LONG_CONSTANT("SOL_FILTER", SOL_FILTER, CONST_PERSISTENT); -#endif -#if defined(SOL_FILTER) REGISTER_LONG_CONSTANT("FIL_ATTACH", FIL_ATTACH, CONST_PERSISTENT); -#endif -#if defined(SOL_FILTER) REGISTER_LONG_CONSTANT("FIL_DETACH", FIL_DETACH, CONST_PERSISTENT); #endif #if defined(SO_DONTTRUNC) @@ -556,11 +544,7 @@ static void register_sockets_symbols(int module_number) #endif #if defined(TCP_KEEPIDLE) REGISTER_LONG_CONSTANT("TCP_KEEPIDLE", TCP_KEEPIDLE, CONST_PERSISTENT); -#endif -#if defined(TCP_KEEPIDLE) REGISTER_LONG_CONSTANT("TCP_KEEPINTVL", TCP_KEEPINTVL, CONST_PERSISTENT); -#endif -#if defined(TCP_KEEPIDLE) REGISTER_LONG_CONSTANT("TCP_KEEPCNT", TCP_KEEPCNT, CONST_PERSISTENT); #endif #if defined(TCP_FUNCTION_BLK) @@ -571,11 +555,7 @@ static void register_sockets_symbols(int module_number) #endif #if defined(TCP_REUSPORT_LB_NUMA) REGISTER_LONG_CONSTANT("TCP_REUSPORT_LB_NUMA", TCP_REUSPORT_LB_NUMA, CONST_PERSISTENT); -#endif -#if defined(TCP_REUSPORT_LB_NUMA) REGISTER_LONG_CONSTANT("TCP_REUSPORT_LB_NUMA_NODOM", TCP_REUSPORT_LB_NUMA_NODOM, CONST_PERSISTENT); -#endif -#if defined(TCP_REUSPORT_LB_NUMA) REGISTER_LONG_CONSTANT("TCP_REUSPORT_LB_NUMA_CURDOM", TCP_REUSPORT_LB_NUMA_CURDOM, CONST_PERSISTENT); #endif #if defined(TCP_BBR_ALGORITHM) @@ -587,14 +567,8 @@ static void register_sockets_symbols(int module_number) REGISTER_LONG_CONSTANT("MCAST_LEAVE_GROUP", PHP_MCAST_LEAVE_GROUP, CONST_PERSISTENT); #if defined(HAS_MCAST_EXT) REGISTER_LONG_CONSTANT("MCAST_BLOCK_SOURCE", PHP_MCAST_BLOCK_SOURCE, CONST_PERSISTENT); -#endif -#if defined(HAS_MCAST_EXT) REGISTER_LONG_CONSTANT("MCAST_UNBLOCK_SOURCE", PHP_MCAST_UNBLOCK_SOURCE, CONST_PERSISTENT); -#endif -#if defined(HAS_MCAST_EXT) REGISTER_LONG_CONSTANT("MCAST_JOIN_SOURCE_GROUP", PHP_MCAST_JOIN_SOURCE_GROUP, CONST_PERSISTENT); -#endif -#if defined(HAS_MCAST_EXT) REGISTER_LONG_CONSTANT("MCAST_LEAVE_SOURCE_GROUP", PHP_MCAST_LEAVE_SOURCE_GROUP, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("IP_MULTICAST_IF", IP_MULTICAST_IF, CONST_PERSISTENT); @@ -605,11 +579,7 @@ static void register_sockets_symbols(int module_number) #endif #if defined(HAVE_IPV6) REGISTER_LONG_CONSTANT("IPV6_MULTICAST_IF", IPV6_MULTICAST_IF, CONST_PERSISTENT); -#endif -#if defined(HAVE_IPV6) REGISTER_LONG_CONSTANT("IPV6_MULTICAST_HOPS", IPV6_MULTICAST_HOPS, CONST_PERSISTENT); -#endif -#if defined(HAVE_IPV6) REGISTER_LONG_CONSTANT("IPV6_MULTICAST_LOOP", IPV6_MULTICAST_LOOP, CONST_PERSISTENT); #endif #if defined(IPV6_V6ONLY) @@ -617,14 +587,8 @@ static void register_sockets_symbols(int module_number) #endif #if defined(IP_PORTRANGE) REGISTER_LONG_CONSTANT("IP_PORTRANGE", IP_PORTRANGE, CONST_PERSISTENT); -#endif -#if defined(IP_PORTRANGE) REGISTER_LONG_CONSTANT("IP_PORTRANGE_DEFAULT", IP_PORTRANGE_DEFAULT, CONST_PERSISTENT); -#endif -#if defined(IP_PORTRANGE) REGISTER_LONG_CONSTANT("IP_PORTRANGE_HIGH", IP_PORTRANGE_HIGH, CONST_PERSISTENT); -#endif -#if defined(IP_PORTRANGE) REGISTER_LONG_CONSTANT("IP_PORTRANGE_LOW", IP_PORTRANGE_LOW, CONST_PERSISTENT); #endif #if defined(EPERM) @@ -932,32 +896,14 @@ static void register_sockets_symbols(int module_number) #endif #if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_ESTALE", WSAESTALE, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_EDISCON", WSAEDISCON, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_SYSNOTREADY", WSASYSNOTREADY, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_VERNOTSUPPORTED", WSAVERNOTSUPPORTED, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NOTINITIALISED", WSANOTINITIALISED, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_HOST_NOT_FOUND", WSAHOST_NOT_FOUND, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_TRY_AGAIN", WSATRY_AGAIN, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_RECOVERY", WSANO_RECOVERY, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_DATA", WSANO_DATA, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("SOCKET_NO_ADDRESS", WSANO_ADDRESS, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("IPPROTO_IP", IPPROTO_IP, CONST_PERSISTENT); @@ -990,8 +936,6 @@ static void register_sockets_symbols(int module_number) REGISTER_LONG_CONSTANT("AI_ADDRCONFIG", AI_ADDRCONFIG, CONST_PERSISTENT); #if defined(AI_IDN) REGISTER_LONG_CONSTANT("AI_IDN", AI_IDN, CONST_PERSISTENT); -#endif -#if defined(AI_IDN) REGISTER_LONG_CONSTANT("AI_CANONIDN", AI_CANONIDN, CONST_PERSISTENT); #endif #if defined(AI_NUMERICSERV) @@ -1002,20 +946,14 @@ static void register_sockets_symbols(int module_number) #endif #if (defined(IPV6_RECVPKTINFO) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_RECVPKTINFO", IPV6_RECVPKTINFO, CONST_PERSISTENT); -#endif -#if (defined(IPV6_RECVPKTINFO) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_PKTINFO", IPV6_PKTINFO, CONST_PERSISTENT); #endif #if (defined(IPV6_RECVHOPLIMIT) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_RECVHOPLIMIT", IPV6_RECVHOPLIMIT, CONST_PERSISTENT); -#endif -#if (defined(IPV6_RECVHOPLIMIT) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_HOPLIMIT", IPV6_HOPLIMIT, CONST_PERSISTENT); #endif #if (defined(IPV6_RECVTCLASS) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_RECVTCLASS", IPV6_RECVTCLASS, CONST_PERSISTENT); -#endif -#if (defined(IPV6_RECVTCLASS) && defined(HAVE_IPV6)) REGISTER_LONG_CONSTANT("IPV6_TCLASS", IPV6_TCLASS, CONST_PERSISTENT); #endif #if defined(SCM_RIGHTS) @@ -1032,14 +970,10 @@ static void register_sockets_symbols(int module_number) #endif #if defined(LOCAL_CREDS_PERSISTENT) REGISTER_LONG_CONSTANT("SCM_CREDS2", SCM_CREDS2, CONST_PERSISTENT); -#endif -#if defined(LOCAL_CREDS_PERSISTENT) REGISTER_LONG_CONSTANT("LOCAL_CREDS_PERSISTENT", LOCAL_CREDS_PERSISTENT, CONST_PERSISTENT); #endif #if (!defined(LOCAL_CREDS_PERSISTENT) && defined(LOCAL_CREDS)) REGISTER_LONG_CONSTANT("SCM_CREDS", SCM_CREDS, CONST_PERSISTENT); -#endif -#if (!defined(LOCAL_CREDS_PERSISTENT) && defined(LOCAL_CREDS)) REGISTER_LONG_CONSTANT("LOCAL_CREDS", LOCAL_CREDS, CONST_PERSISTENT); #endif #if defined(SO_ATTACH_REUSEPORT_CBPF) @@ -1098,14 +1032,8 @@ static void register_sockets_symbols(int module_number) #endif #if defined(ETH_P_ALL) REGISTER_LONG_CONSTANT("ETH_P_IP", ETH_P_IP, CONST_PERSISTENT); -#endif -#if defined(ETH_P_ALL) REGISTER_LONG_CONSTANT("ETH_P_IPV6", ETH_P_IPV6, CONST_PERSISTENT); -#endif -#if defined(ETH_P_ALL) REGISTER_LONG_CONSTANT("ETH_P_LOOP", ETH_P_LOOP, CONST_PERSISTENT); -#endif -#if defined(ETH_P_ALL) REGISTER_LONG_CONSTANT("ETH_P_ALL", ETH_P_ALL, CONST_PERSISTENT); #endif #if defined(UDP_SEGMENT) @@ -1113,11 +1041,7 @@ static void register_sockets_symbols(int module_number) #endif #if defined(SHUT_RDWR) REGISTER_LONG_CONSTANT("SHUT_RD", SHUT_RD, CONST_PERSISTENT); -#endif -#if defined(SHUT_RDWR) REGISTER_LONG_CONSTANT("SHUT_WR", SHUT_WR, CONST_PERSISTENT); -#endif -#if defined(SHUT_RDWR) REGISTER_LONG_CONSTANT("SHUT_RDWR", SHUT_RDWR, CONST_PERSISTENT); #endif } diff --git a/ext/sodium/libsodium_arginfo.h b/ext/sodium/libsodium_arginfo.h index f91a7c5dfe0d9..5fbd831c22e4a 100644 --- a/ext/sodium/libsodium_arginfo.h +++ b/ext/sodium/libsodium_arginfo.h @@ -762,38 +762,20 @@ static void register_libsodium_symbols(int module_number) REGISTER_LONG_CONSTANT("SODIUM_LIBRARY_MINOR_VERSION", sodium_library_version_minor(), CONST_PERSISTENT); #if defined(HAVE_AESGCM) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES", crypto_aead_aes256gcm_KEYBYTES, CONST_PERSISTENT); -#endif -#if defined(HAVE_AESGCM) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES", crypto_aead_aes256gcm_NSECBYTES, CONST_PERSISTENT); -#endif -#if defined(HAVE_AESGCM) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES", crypto_aead_aes256gcm_NPUBBYTES, CONST_PERSISTENT); -#endif -#if defined(HAVE_AESGCM) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES", crypto_aead_aes256gcm_ABYTES, CONST_PERSISTENT); #endif #if defined(crypto_aead_aegis128l_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES", crypto_aead_aegis128l_KEYBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis128l_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS128L_NSECBYTES", crypto_aead_aegis128l_NSECBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis128l_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS128L_NPUBBYTES", crypto_aead_aegis128l_NPUBBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis128l_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS128L_ABYTES", crypto_aead_aegis128l_ABYTES, CONST_PERSISTENT); #endif #if defined(crypto_aead_aegis256_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS256_KEYBYTES", crypto_aead_aegis256_KEYBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis256_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS256_NSECBYTES", crypto_aead_aegis256_NSECBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis256_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS256_NPUBBYTES", crypto_aead_aegis256_NPUBBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_aegis256_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_AEGIS256_ABYTES", crypto_aead_aegis256_ABYTES, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES", crypto_aead_chacha20poly1305_KEYBYTES, CONST_PERSISTENT); @@ -806,14 +788,8 @@ static void register_libsodium_symbols(int module_number) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES", crypto_aead_chacha20poly1305_IETF_ABYTES, CONST_PERSISTENT); #if defined(crypto_aead_xchacha20poly1305_IETF_NPUBBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES", crypto_aead_xchacha20poly1305_IETF_KEYBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_xchacha20poly1305_IETF_NPUBBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES", crypto_aead_xchacha20poly1305_IETF_NSECBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_xchacha20poly1305_IETF_NPUBBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES", crypto_aead_xchacha20poly1305_IETF_NPUBBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_aead_xchacha20poly1305_IETF_NPUBBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES", crypto_aead_xchacha20poly1305_IETF_ABYTES, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_AUTH_BYTES", crypto_auth_BYTES, CONST_PERSISTENT); @@ -836,26 +812,12 @@ static void register_libsodium_symbols(int module_number) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_KX_KEYPAIRBYTES", SODIUM_CRYPTO_KX_KEYPAIRBYTES(), CONST_PERSISTENT); #if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES", crypto_secretstream_xchacha20poly1305_ABYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES", crypto_secretstream_xchacha20poly1305_HEADERBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES", crypto_secretstream_xchacha20poly1305_KEYBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX", crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE", crypto_secretstream_xchacha20poly1305_TAG_MESSAGE, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH", crypto_secretstream_xchacha20poly1305_TAG_PUSH, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY", crypto_secretstream_xchacha20poly1305_TAG_REKEY, CONST_PERSISTENT); -#endif -#if defined(crypto_secretstream_xchacha20poly1305_ABYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL", crypto_secretstream_xchacha20poly1305_TAG_FINAL, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_GENERICHASH_BYTES", crypto_generichash_BYTES, CONST_PERSISTENT); @@ -872,47 +834,21 @@ static void register_libsodium_symbols(int module_number) #endif #if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_ALG_DEFAULT", crypto_pwhash_ALG_DEFAULT, CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SALTBYTES", crypto_pwhash_SALTBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_STRING_CONSTANT("SODIUM_CRYPTO_PWHASH_STRPREFIX", crypto_pwhash_STRPREFIX, CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE", crypto_pwhash_opslimit_interactive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE", crypto_pwhash_memlimit_interactive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE", crypto_pwhash_opslimit_moderate(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE", crypto_pwhash_memlimit_moderate(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE", crypto_pwhash_opslimit_sensitive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE", crypto_pwhash_memlimit_sensitive(), CONST_PERSISTENT); #endif #if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES", crypto_pwhash_scryptsalsa208sha256_SALTBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_STRING_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX", crypto_pwhash_scryptsalsa208sha256_STRPREFIX, CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE", crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE", crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE", crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(), CONST_PERSISTENT); -#endif -#if defined(crypto_pwhash_scryptsalsa208sha256_SALTBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE", crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(), CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SCALARMULT_BYTES", crypto_scalarmult_BYTES, CONST_PERSISTENT); @@ -931,38 +867,20 @@ static void register_libsodium_symbols(int module_number) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_STREAM_KEYBYTES", crypto_stream_KEYBYTES, CONST_PERSISTENT); #if defined(crypto_stream_xchacha20_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES", crypto_stream_xchacha20_NONCEBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_stream_xchacha20_KEYBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES", crypto_stream_xchacha20_KEYBYTES, CONST_PERSISTENT); #endif #if defined(sodium_base64_VARIANT_ORIGINAL) REGISTER_LONG_CONSTANT("SODIUM_BASE64_VARIANT_ORIGINAL", sodium_base64_VARIANT_ORIGINAL, CONST_PERSISTENT); -#endif -#if defined(sodium_base64_VARIANT_ORIGINAL) REGISTER_LONG_CONSTANT("SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING", sodium_base64_VARIANT_ORIGINAL_NO_PADDING, CONST_PERSISTENT); -#endif -#if defined(sodium_base64_VARIANT_ORIGINAL) REGISTER_LONG_CONSTANT("SODIUM_BASE64_VARIANT_URLSAFE", sodium_base64_VARIANT_URLSAFE, CONST_PERSISTENT); -#endif -#if defined(sodium_base64_VARIANT_ORIGINAL) REGISTER_LONG_CONSTANT("SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING", sodium_base64_VARIANT_URLSAFE_NO_PADDING, CONST_PERSISTENT); #endif #if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES", crypto_scalarmult_ristretto255_BYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES", crypto_scalarmult_ristretto255_SCALARBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES", crypto_core_ristretto255_BYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES", crypto_core_ristretto255_HASHBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES", crypto_core_ristretto255_SCALARBYTES, CONST_PERSISTENT); -#endif -#if defined(crypto_core_ristretto255_HASHBYTES) REGISTER_LONG_CONSTANT("SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES", crypto_core_ristretto255_NONREDUCEDSCALARBYTES, CONST_PERSISTENT); #endif diff --git a/ext/sodium/sodium_pwhash_arginfo.h b/ext/sodium/sodium_pwhash_arginfo.h index b33d5b5b96f77..465f3090191d1 100644 --- a/ext/sodium/sodium_pwhash_arginfo.h +++ b/ext/sodium/sodium_pwhash_arginfo.h @@ -5,20 +5,10 @@ static void register_sodium_pwhash_symbols(int module_number) { #if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2I", "argon2i", CONST_PERSISTENT); -#endif -#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2ID", "argon2id", CONST_PERSISTENT); -#endif -#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_MEMORY_COST", PHP_SODIUM_PWHASH_MEMLIMIT, CONST_PERSISTENT); -#endif -#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_TIME_COST", PHP_SODIUM_PWHASH_OPSLIMIT, CONST_PERSISTENT); -#endif -#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_THREADS", PHP_SODIUM_PWHASH_THREADS, CONST_PERSISTENT); -#endif -#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2_PROVIDER", "sodium", CONST_PERSISTENT); #endif } diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index d221a221f4132..37df4de7bdfcd 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -3592,20 +3592,10 @@ static void register_basic_functions_symbols(int module_number) REGISTER_LONG_CONSTANT("CRYPT_SHA512", 1, CONST_PERSISTENT); #if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_A", PHP_DNS_A, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_NS", PHP_DNS_NS, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_CNAME", PHP_DNS_CNAME, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_SOA", PHP_DNS_SOA, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_PTR", PHP_DNS_PTR, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_HINFO", PHP_DNS_HINFO, CONST_PERSISTENT); #endif #if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) && (!defined(PHP_WIN32)) @@ -3613,26 +3603,12 @@ static void register_basic_functions_symbols(int module_number) #endif #if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_MX", PHP_DNS_MX, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_TXT", PHP_DNS_TXT, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_SRV", PHP_DNS_SRV, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_NAPTR", PHP_DNS_NAPTR, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_AAAA", PHP_DNS_AAAA, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_A6", PHP_DNS_A6, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_ANY", PHP_DNS_ANY, CONST_PERSISTENT); -#endif -#if (defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))) REGISTER_LONG_CONSTANT("DNS_ALL", PHP_DNS_ALL, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("HTML_SPECIALCHARS", PHP_HTML_SPECIALCHARS, CONST_PERSISTENT); @@ -3716,26 +3692,12 @@ static void register_basic_functions_symbols(int module_number) #endif #if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL0", LOG_LOCAL0, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL1", LOG_LOCAL1, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL2", LOG_LOCAL2, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL3", LOG_LOCAL3, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL4", LOG_LOCAL4, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL5", LOG_LOCAL5, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL6", LOG_LOCAL6, CONST_PERSISTENT); -#endif -#if !defined(PHP_WIN32) REGISTER_LONG_CONSTANT("LOG_LOCAL7", LOG_LOCAL7, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("LOG_PID", LOG_PID, CONST_PERSISTENT); @@ -3768,116 +3730,48 @@ static void register_basic_functions_symbols(int module_number) #endif #if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_1", ABDAY_1, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_2", ABDAY_2, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_3", ABDAY_3, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_4", ABDAY_4, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_5", ABDAY_5, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_6", ABDAY_6, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABDAY_1) REGISTER_LONG_CONSTANT("ABDAY_7", ABDAY_7, CONST_PERSISTENT); #endif #if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_1", DAY_1, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_2", DAY_2, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_3", DAY_3, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_4", DAY_4, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_5", DAY_5, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_6", DAY_6, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(DAY_1) REGISTER_LONG_CONSTANT("DAY_7", DAY_7, CONST_PERSISTENT); #endif #if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_1", ABMON_1, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_2", ABMON_2, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_3", ABMON_3, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_4", ABMON_4, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_5", ABMON_5, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_6", ABMON_6, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_7", ABMON_7, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_8", ABMON_8, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_9", ABMON_9, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_10", ABMON_10, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_11", ABMON_11, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(ABMON_1) REGISTER_LONG_CONSTANT("ABMON_12", ABMON_12, CONST_PERSISTENT); #endif #if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_1", MON_1, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_2", MON_2, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_3", MON_3, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_4", MON_4, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_5", MON_5, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_6", MON_6, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_7", MON_7, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_8", MON_8, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_9", MON_9, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_10", MON_10, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_11", MON_11, CONST_PERSISTENT); -#endif -#if defined(HAVE_NL_LANGINFO) && defined(MON_1) REGISTER_LONG_CONSTANT("MON_12", MON_12, CONST_PERSISTENT); #endif #if defined(HAVE_NL_LANGINFO) && defined(AM_STR) diff --git a/ext/standard/file_arginfo.h b/ext/standard/file_arginfo.h index b96e587a2ea1d..7dc8fcf80aabe 100644 --- a/ext/standard/file_arginfo.h +++ b/ext/standard/file_arginfo.h @@ -112,11 +112,7 @@ static void register_file_symbols(int module_number) REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_PERSISTENT | CONST_DEPRECATED); #if defined(HAVE_FNMATCH) REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_PERSISTENT); -#endif -#if defined(HAVE_FNMATCH) REGISTER_LONG_CONSTANT("FNM_PATHNAME", FNM_PATHNAME, CONST_PERSISTENT); -#endif -#if defined(HAVE_FNMATCH) REGISTER_LONG_CONSTANT("FNM_PERIOD", FNM_PERIOD, CONST_PERSISTENT); #endif #if defined(HAVE_FNMATCH) && defined(FNM_CASEFOLD) diff --git a/ext/standard/password_arginfo.h b/ext/standard/password_arginfo.h index bf1b614273a4a..fd25fbed67739 100644 --- a/ext/standard/password_arginfo.h +++ b/ext/standard/password_arginfo.h @@ -8,20 +8,10 @@ static void register_password_symbols(int module_number) REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT_DEFAULT_COST", PHP_PASSWORD_BCRYPT_COST, CONST_PERSISTENT); #if defined(HAVE_ARGON2LIB) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2I", "argon2i", CONST_PERSISTENT); -#endif -#if defined(HAVE_ARGON2LIB) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2ID", "argon2id", CONST_PERSISTENT); -#endif -#if defined(HAVE_ARGON2LIB) REGISTER_STRING_CONSTANT("PASSWORD_ARGON2_PROVIDER", "standard", CONST_PERSISTENT); -#endif -#if defined(HAVE_ARGON2LIB) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_MEMORY_COST", PHP_PASSWORD_ARGON2_MEMORY_COST, CONST_PERSISTENT); -#endif -#if defined(HAVE_ARGON2LIB) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_TIME_COST", PHP_PASSWORD_ARGON2_TIME_COST, CONST_PERSISTENT); -#endif -#if defined(HAVE_ARGON2LIB) REGISTER_LONG_CONSTANT("PASSWORD_ARGON2_DEFAULT_THREADS", PHP_PASSWORD_ARGON2_THREADS, CONST_PERSISTENT); #endif } diff --git a/ext/tidy/tidy_arginfo.h b/ext/tidy/tidy_arginfo.h index b7dae788ef316..4084a29f4d908 100644 --- a/ext/tidy/tidy_arginfo.h +++ b/ext/tidy/tidy_arginfo.h @@ -437,86 +437,32 @@ static void register_tidy_symbols(int module_number) REGISTER_LONG_CONSTANT("TIDY_TAG_XMP", TidyTag_XMP, CONST_PERSISTENT); #if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_ARTICLE", TidyTag_ARTICLE, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_ASIDE", TidyTag_ASIDE, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_AUDIO", TidyTag_AUDIO, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_BDI", TidyTag_BDI, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_CANVAS", TidyTag_CANVAS, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_COMMAND", TidyTag_COMMAND, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_DATALIST", TidyTag_DATALIST, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_DETAILS", TidyTag_DETAILS, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_DIALOG", TidyTag_DIALOG, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_FIGCAPTION", TidyTag_FIGCAPTION, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_FIGURE", TidyTag_FIGURE, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_FOOTER", TidyTag_FOOTER, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_HEADER", TidyTag_HEADER, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_HGROUP", TidyTag_HGROUP, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_MAIN", TidyTag_MAIN, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_MARK", TidyTag_MARK, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_MENUITEM", TidyTag_MENUITEM, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_METER", TidyTag_METER, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_NAV", TidyTag_NAV, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_OUTPUT", TidyTag_OUTPUT, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_PROGRESS", TidyTag_PROGRESS, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_SECTION", TidyTag_SECTION, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_SOURCE", TidyTag_SOURCE, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_SUMMARY", TidyTag_SUMMARY, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_TEMPLATE", TidyTag_TEMPLATE, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_TIME", TidyTag_TIME, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_TRACK", TidyTag_TRACK, CONST_PERSISTENT); -#endif -#if defined(HAVE_TIDYBUFFIO_H) REGISTER_LONG_CONSTANT("TIDY_TAG_VIDEO", TidyTag_VIDEO, CONST_PERSISTENT); #endif } diff --git a/ext/xsl/php_xsl_arginfo.h b/ext/xsl/php_xsl_arginfo.h index d040928197f65..72e7ed0b0a99d 100644 --- a/ext/xsl/php_xsl_arginfo.h +++ b/ext/xsl/php_xsl_arginfo.h @@ -106,8 +106,6 @@ static void register_php_xsl_symbols(int module_number) REGISTER_STRING_CONSTANT("LIBXSLT_DOTTED_VERSION", LIBXSLT_DOTTED_VERSION, CONST_PERSISTENT); #if defined(HAVE_XSL_EXSLT) REGISTER_LONG_CONSTANT("LIBEXSLT_VERSION", LIBEXSLT_VERSION, CONST_PERSISTENT); -#endif -#if defined(HAVE_XSL_EXSLT) REGISTER_STRING_CONSTANT("LIBEXSLT_DOTTED_VERSION", LIBEXSLT_DOTTED_VERSION, CONST_PERSISTENT); #endif } diff --git a/ext/zip/php_zip_arginfo.h b/ext/zip/php_zip_arginfo.h index 6166218b2d8dd..c8dab41560e48 100644 --- a/ext/zip/php_zip_arginfo.h +++ b/ext/zip/php_zip_arginfo.h @@ -1103,160 +1103,120 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry zend_string *const_OPSYS_DOS_name = zend_string_init_interned("OPSYS_DOS", sizeof("OPSYS_DOS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_DOS_name, &const_OPSYS_DOS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_DOS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_AMIGA_value; ZVAL_LONG(&const_OPSYS_AMIGA_value, ZIP_OPSYS_AMIGA); zend_string *const_OPSYS_AMIGA_name = zend_string_init_interned("OPSYS_AMIGA", sizeof("OPSYS_AMIGA") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_AMIGA_name, &const_OPSYS_AMIGA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_AMIGA_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_OPENVMS_value; ZVAL_LONG(&const_OPSYS_OPENVMS_value, ZIP_OPSYS_OPENVMS); zend_string *const_OPSYS_OPENVMS_name = zend_string_init_interned("OPSYS_OPENVMS", sizeof("OPSYS_OPENVMS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_OPENVMS_name, &const_OPSYS_OPENVMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_OPENVMS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_UNIX_value; ZVAL_LONG(&const_OPSYS_UNIX_value, ZIP_OPSYS_UNIX); zend_string *const_OPSYS_UNIX_name = zend_string_init_interned("OPSYS_UNIX", sizeof("OPSYS_UNIX") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_UNIX_name, &const_OPSYS_UNIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_UNIX_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_VM_CMS_value; ZVAL_LONG(&const_OPSYS_VM_CMS_value, ZIP_OPSYS_VM_CMS); zend_string *const_OPSYS_VM_CMS_name = zend_string_init_interned("OPSYS_VM_CMS", sizeof("OPSYS_VM_CMS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_VM_CMS_name, &const_OPSYS_VM_CMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_VM_CMS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_ATARI_ST_value; ZVAL_LONG(&const_OPSYS_ATARI_ST_value, ZIP_OPSYS_ATARI_ST); zend_string *const_OPSYS_ATARI_ST_name = zend_string_init_interned("OPSYS_ATARI_ST", sizeof("OPSYS_ATARI_ST") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_ATARI_ST_name, &const_OPSYS_ATARI_ST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_ATARI_ST_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_OS_2_value; ZVAL_LONG(&const_OPSYS_OS_2_value, ZIP_OPSYS_OS_2); zend_string *const_OPSYS_OS_2_name = zend_string_init_interned("OPSYS_OS_2", sizeof("OPSYS_OS_2") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_2_name, &const_OPSYS_OS_2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_OS_2_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_MACINTOSH_value; ZVAL_LONG(&const_OPSYS_MACINTOSH_value, ZIP_OPSYS_MACINTOSH); zend_string *const_OPSYS_MACINTOSH_name = zend_string_init_interned("OPSYS_MACINTOSH", sizeof("OPSYS_MACINTOSH") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_MACINTOSH_name, &const_OPSYS_MACINTOSH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_MACINTOSH_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_Z_SYSTEM_value; ZVAL_LONG(&const_OPSYS_Z_SYSTEM_value, ZIP_OPSYS_Z_SYSTEM); zend_string *const_OPSYS_Z_SYSTEM_name = zend_string_init_interned("OPSYS_Z_SYSTEM", sizeof("OPSYS_Z_SYSTEM") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_Z_SYSTEM_name, &const_OPSYS_Z_SYSTEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_Z_SYSTEM_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_CPM_value; ZVAL_LONG(&const_OPSYS_CPM_value, ZIP_OPSYS_CPM); zend_string *const_OPSYS_CPM_name = zend_string_init_interned("OPSYS_CPM", sizeof("OPSYS_CPM") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_CPM_name, &const_OPSYS_CPM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_CPM_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_WINDOWS_NTFS_value; ZVAL_LONG(&const_OPSYS_WINDOWS_NTFS_value, ZIP_OPSYS_WINDOWS_NTFS); zend_string *const_OPSYS_WINDOWS_NTFS_name = zend_string_init_interned("OPSYS_WINDOWS_NTFS", sizeof("OPSYS_WINDOWS_NTFS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_WINDOWS_NTFS_name, &const_OPSYS_WINDOWS_NTFS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_WINDOWS_NTFS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_MVS_value; ZVAL_LONG(&const_OPSYS_MVS_value, ZIP_OPSYS_MVS); zend_string *const_OPSYS_MVS_name = zend_string_init_interned("OPSYS_MVS", sizeof("OPSYS_MVS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_MVS_name, &const_OPSYS_MVS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_MVS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_VSE_value; ZVAL_LONG(&const_OPSYS_VSE_value, ZIP_OPSYS_VSE); zend_string *const_OPSYS_VSE_name = zend_string_init_interned("OPSYS_VSE", sizeof("OPSYS_VSE") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_VSE_name, &const_OPSYS_VSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_VSE_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_ACORN_RISC_value; ZVAL_LONG(&const_OPSYS_ACORN_RISC_value, ZIP_OPSYS_ACORN_RISC); zend_string *const_OPSYS_ACORN_RISC_name = zend_string_init_interned("OPSYS_ACORN_RISC", sizeof("OPSYS_ACORN_RISC") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_ACORN_RISC_name, &const_OPSYS_ACORN_RISC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_ACORN_RISC_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_VFAT_value; ZVAL_LONG(&const_OPSYS_VFAT_value, ZIP_OPSYS_VFAT); zend_string *const_OPSYS_VFAT_name = zend_string_init_interned("OPSYS_VFAT", sizeof("OPSYS_VFAT") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_VFAT_name, &const_OPSYS_VFAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_VFAT_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_ALTERNATE_MVS_value; ZVAL_LONG(&const_OPSYS_ALTERNATE_MVS_value, ZIP_OPSYS_ALTERNATE_MVS); zend_string *const_OPSYS_ALTERNATE_MVS_name = zend_string_init_interned("OPSYS_ALTERNATE_MVS", sizeof("OPSYS_ALTERNATE_MVS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_ALTERNATE_MVS_name, &const_OPSYS_ALTERNATE_MVS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_ALTERNATE_MVS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_BEOS_value; ZVAL_LONG(&const_OPSYS_BEOS_value, ZIP_OPSYS_BEOS); zend_string *const_OPSYS_BEOS_name = zend_string_init_interned("OPSYS_BEOS", sizeof("OPSYS_BEOS") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_BEOS_name, &const_OPSYS_BEOS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_BEOS_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_TANDEM_value; ZVAL_LONG(&const_OPSYS_TANDEM_value, ZIP_OPSYS_TANDEM); zend_string *const_OPSYS_TANDEM_name = zend_string_init_interned("OPSYS_TANDEM", sizeof("OPSYS_TANDEM") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_TANDEM_name, &const_OPSYS_TANDEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_TANDEM_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_OS_400_value; ZVAL_LONG(&const_OPSYS_OS_400_value, ZIP_OPSYS_OS_400); zend_string *const_OPSYS_OS_400_name = zend_string_init_interned("OPSYS_OS_400", sizeof("OPSYS_OS_400") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_400_name, &const_OPSYS_OS_400_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_OS_400_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_OS_X_value; ZVAL_LONG(&const_OPSYS_OS_X_value, ZIP_OPSYS_OS_X); zend_string *const_OPSYS_OS_X_name = zend_string_init_interned("OPSYS_OS_X", sizeof("OPSYS_OS_X") - 1, 1); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_X_name, &const_OPSYS_OS_X_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_OPSYS_OS_X_name); -#endif -#if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_DEFAULT_value; ZVAL_LONG(&const_OPSYS_DEFAULT_value, ZIP_OPSYS_DEFAULT); @@ -1283,16 +1243,12 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry zend_string *const_EM_AES_128_name = zend_string_init_interned("EM_AES_128", sizeof("EM_AES_128") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EM_AES_128_name, &const_EM_AES_128_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EM_AES_128_name); -#endif -#if defined(HAVE_ENCRYPTION) zval const_EM_AES_192_value; ZVAL_LONG(&const_EM_AES_192_value, ZIP_EM_AES_192); zend_string *const_EM_AES_192_name = zend_string_init_interned("EM_AES_192", sizeof("EM_AES_192") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EM_AES_192_name, &const_EM_AES_192_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EM_AES_192_name); -#endif -#if defined(HAVE_ENCRYPTION) zval const_EM_AES_256_value; ZVAL_LONG(&const_EM_AES_256_value, ZIP_EM_AES_256); diff --git a/main/main_arginfo.h b/main/main_arginfo.h index f0d2599baf473..922af3aff0629 100644 --- a/main/main_arginfo.h +++ b/main/main_arginfo.h @@ -43,35 +43,15 @@ static void register_main_symbols(int module_number) REGISTER_DOUBLE_CONSTANT("PHP_FLOAT_MIN", DBL_MIN, CONST_PERSISTENT); #if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_MINOR", EG(windows_version_info).dwMinorVersion, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_BUILD", EG(windows_version_info).dwBuildNumber, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_PLATFORM", EG(windows_version_info).dwPlatformId, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MAJOR", EG(windows_version_info).wServicePackMajor, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SP_MINOR", EG(windows_version_info).wServicePackMinor, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_SUITEMASK", EG(windows_version_info).wSuiteMask, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_VERSION_PRODUCTTYPE", EG(windows_version_info).wProductType, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_DOMAIN_CONTROLLER", VER_NT_DOMAIN_CONTROLLER, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_SERVER", VER_NT_SERVER, CONST_PERSISTENT); -#endif -#if defined(PHP_WIN32) REGISTER_LONG_CONSTANT("PHP_WINDOWS_NT_WORKSTATION", VER_NT_WORKSTATION, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("PHP_OUTPUT_HANDLER_START", PHP_OUTPUT_HANDLER_START, CONST_PERSISTENT); From e9310171f767d95c34df90eebfbec7d61ad22bbc Mon Sep 17 00:00:00 2001 From: Saki Takamachi <34942839+SakiTakamachi@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:29:20 +0900 Subject: [PATCH 21/62] [skip ci] Add myself to EXTENSIONS (#18918) --- EXTENSIONS | 1 + 1 file changed, 1 insertion(+) diff --git a/EXTENSIONS b/EXTENSIONS index 34e289ffcae2b..d15401f372384 100644 --- a/EXTENSIONS +++ b/EXTENSIONS @@ -238,6 +238,7 @@ SINCE: 5.0 ------------------------------------------------------------------------------- EXTENSION: bcmath PRIMARY MAINTAINER: Andi Gutmans (2000 - 2004) + Saki Takamachi (2024 - 2025) MAINTENANCE: Maintained STATUS: Working ------------------------------------------------------------------------------- From 22bd2ae63f33cfcbd4f2383f4fe8ffa480a1ab42 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 15 Jun 2025 00:04:30 +0100 Subject: [PATCH 22/62] ext/sqlite3: explain statement support addition. similar to what have been done for pdo/sqlite as having statement explain support to simulate how a query would operate or for more advanced users, analysing the VM routines used for possible optimisations. close GH-18853 --- NEWS | 2 + ext/sqlite3/sqlite3.c | 57 ++++ ext/sqlite3/sqlite3.stub.php | 9 + ext/sqlite3/sqlite3_arginfo.h | 43 ++- ext/sqlite3/tests/sqlite3_explain.phpt | 390 +++++++++++++++++++++++++ 5 files changed, 500 insertions(+), 1 deletion(-) create mode 100644 ext/sqlite3/tests/sqlite3_explain.phpt diff --git a/NEWS b/NEWS index dfa90ed08f62c..ccda0d50af84e 100644 --- a/NEWS +++ b/NEWS @@ -247,6 +247,8 @@ PHP NEWS - Sqlite: . Added Sqlite3Stmt::busy to check if a statement is still being executed. (David Carlier) + . Added Sqlite3Stmt::explain to produce a explain query plan from + the statement. (David Carlier) - Standard: . Fixed crypt() tests on musl when using --with-external-libcrypt diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 799c77b24a8c8..349d2823bb1e0 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -26,6 +26,9 @@ #include "SAPI.h" #include +#ifdef __APPLE__ +#include +#endif #include "zend_exceptions.h" #include "sqlite3_arginfo.h" @@ -1500,6 +1503,60 @@ PHP_METHOD(SQLite3Stmt, busy) RETURN_FALSE; } +#if SQLITE_VERSION_NUMBER >= 3043000 +PHP_METHOD(SQLite3Stmt, explain) +{ +#ifdef __APPLE__ + if (__builtin_available(macOS 14.2, *)) { +#endif + php_sqlite3_stmt *stmt_obj; + zval *object = ZEND_THIS; + stmt_obj = Z_SQLITE3_STMT_P(object); + + ZEND_PARSE_PARAMETERS_NONE(); + + SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3); + SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt); + + RETURN_LONG((zend_long)sqlite3_stmt_isexplain(stmt_obj->stmt)); +#ifdef __APPLE__ + } else { + zend_throw_error(NULL, "explain statement unsupported"); + } +#endif +} + +PHP_METHOD(SQLite3Stmt, setExplain) +{ +#ifdef __APPLE__ + if (__builtin_available(macOS 14.2, *)) { +#endif + php_sqlite3_stmt *stmt_obj; + zend_long mode; + zval *object = ZEND_THIS; + stmt_obj = Z_SQLITE3_STMT_P(object); + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(mode) + ZEND_PARSE_PARAMETERS_END(); + + if (mode < 0 || mode > 2) { + zend_argument_value_error(1, "must be one of the SQLite3Stmt::EXPLAIN_MODE_* constants"); + RETURN_THROWS(); + } + + SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3); + SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt); + + RETURN_BOOL(sqlite3_stmt_explain(stmt_obj->stmt, (int)mode) == SQLITE_OK); +#ifdef __APPLE__ + } else { + zend_throw_error(NULL, "explain statement unsupported"); + } +#endif +} +#endif + /* bind parameters to a statement before execution */ static int php_sqlite3_bind_params(php_sqlite3_stmt *stmt_obj) /* {{{ */ { diff --git a/ext/sqlite3/sqlite3.stub.php b/ext/sqlite3/sqlite3.stub.php index 8a3d90470767a..55af378b325c5 100644 --- a/ext/sqlite3/sqlite3.stub.php +++ b/ext/sqlite3/sqlite3.stub.php @@ -274,6 +274,15 @@ public function readOnly(): bool {} public function reset(): bool {} public function busy(): bool {} + +#if SQLITE_VERSION_NUMBER >= 3043000 + public const int EXPLAIN_MODE_PREPARED = 0; + public const int EXPLAIN_MODE_EXPLAIN = 1; + public const int EXPLAIN_MODE_EXPLAIN_QUERY_PLAN = 2; + + public function explain(): int {} + public function setExplain(int $mode): bool {} +#endif } /** @not-serializable */ diff --git a/ext/sqlite3/sqlite3_arginfo.h b/ext/sqlite3/sqlite3_arginfo.h index f83188841b43f..e306af04538b3 100644 --- a/ext/sqlite3/sqlite3_arginfo.h +++ b/ext/sqlite3/sqlite3_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 28132e0e4df61f19dc4b23a7c9f79be6b3e40a8e */ + * Stub hash: c3216eada9881743cbd3aa1510f1200b7ce0d942 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -147,6 +147,15 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SQLite3Stmt_busy, 0, 0, _IS_BOOL, 0) ZEND_END_ARG_INFO() +#if SQLITE_VERSION_NUMBER >= 3043000 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SQLite3Stmt_explain, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SQLite3Stmt_setExplain, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) +ZEND_END_ARG_INFO() +#endif + ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3Result___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -206,6 +215,10 @@ ZEND_METHOD(SQLite3Stmt, paramCount); ZEND_METHOD(SQLite3Stmt, readOnly); ZEND_METHOD(SQLite3Stmt, reset); ZEND_METHOD(SQLite3Stmt, busy); +#if SQLITE_VERSION_NUMBER >= 3043000 +ZEND_METHOD(SQLite3Stmt, explain); +ZEND_METHOD(SQLite3Stmt, setExplain); +#endif ZEND_METHOD(SQLite3Result, __construct); ZEND_METHOD(SQLite3Result, numColumns); ZEND_METHOD(SQLite3Result, columnName); @@ -258,6 +271,10 @@ static const zend_function_entry class_SQLite3Stmt_methods[] = { ZEND_ME(SQLite3Stmt, readOnly, arginfo_class_SQLite3Stmt_readOnly, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Stmt, reset, arginfo_class_SQLite3Stmt_reset, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Stmt, busy, arginfo_class_SQLite3Stmt_busy, ZEND_ACC_PUBLIC) +#if SQLITE_VERSION_NUMBER >= 3043000 + ZEND_ME(SQLite3Stmt, explain, arginfo_class_SQLite3Stmt_explain, ZEND_ACC_PUBLIC) + ZEND_ME(SQLite3Stmt, setExplain, arginfo_class_SQLite3Stmt_setExplain, ZEND_ACC_PUBLIC) +#endif ZEND_FE_END }; @@ -540,6 +557,30 @@ static zend_class_entry *register_class_SQLite3Stmt(void) INIT_CLASS_ENTRY(ce, "SQLite3Stmt", class_SQLite3Stmt_methods); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_NOT_SERIALIZABLE); +#if SQLITE_VERSION_NUMBER >= 3043000 + + zval const_EXPLAIN_MODE_PREPARED_value; + ZVAL_LONG(&const_EXPLAIN_MODE_PREPARED_value, 0); + zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_PREPARED_name, &const_EXPLAIN_MODE_PREPARED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_EXPLAIN_MODE_PREPARED_name); +#endif +#if SQLITE_VERSION_NUMBER >= 3043000 + + zval const_EXPLAIN_MODE_EXPLAIN_value; + ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_value, 1); + zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_name, &const_EXPLAIN_MODE_EXPLAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_EXPLAIN_MODE_EXPLAIN_name); +#endif +#if SQLITE_VERSION_NUMBER >= 3043000 + + zval const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value; + ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, 2); + zend_string *const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN", sizeof("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name, &const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name); +#endif return class_entry; } diff --git a/ext/sqlite3/tests/sqlite3_explain.phpt b/ext/sqlite3/tests/sqlite3_explain.phpt new file mode 100644 index 0000000000000..f580783ca1d14 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_explain.phpt @@ -0,0 +1,390 @@ +--TEST-- +Sqlite3Stmt::explain/setExplain usage +--EXTENSIONS-- +sqlite3 +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test_explain (a string);'); +$stmt = $db->prepare('INSERT INTO test_explain VALUES ("first insert"), ("second_insert")'); +$stmt->setExplain(Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN); +var_dump($stmt->explain() == Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN); +$r = $stmt->execute(); +$result = []; +while (($arr = $r->fetchArray(SQLITE3_ASSOC)) !== false) $result[] = $arr; +var_dump($result); +$stmts = $db->prepare('SELECT * FROM test_explain'); +$stmts->setExplain(Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN); +$r = $stmts->execute(); +$result = []; +while (($arr = $r->fetchArray(SQLITE3_ASSOC)) !== false) $result[] = $arr; +var_dump($result); + +$stmt = $db->prepare('INSERT INTO test_explain VALUES ("first insert"), ("second_insert")'); +$stmt->setExplain(Sqlite3Stmt::EXPLAIN_MODE_PREPARED); +$stmt->execute(); +$stmts = $db->prepare('SELECT * FROM test_explain'); +$stmts->setExplain(Sqlite3Stmt::EXPLAIN_MODE_PREPARED); +$r = $stmts->execute(); +$result = []; +while (($arr = $r->fetchArray(SQLITE3_ASSOC)) !== false) $result[] = $arr; +var_dump($result); + +try { + $stmts->setExplain(-1); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +try { + $stmts->setExplain(256); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +var_dump($stmts->explain() == Sqlite3Stmt::EXPLAIN_MODE_PREPARED); +?> +--EXPECTF-- +bool(true) +array(%d) { + [0]=> + array(8) { + ["addr"]=> + int(0) + ["opcode"]=> + string(4) "Init" + ["p1"]=> + int(0) + ["p2"]=> + int(%d) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [1]=> + array(8) { + ["addr"]=> + int(1) + ["opcode"]=> + string(13) "InitCoroutine" + ["p1"]=> + int(3) + ["p2"]=> + int(%d) + ["p3"]=> + int(2) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + %A + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(7) "String8" + ["p1"]=> + int(0) + ["p2"]=> + int(2) + ["p3"]=> + int(0) + ["p4"]=> + string(12) "first insert" + ["p5"]=> + int(0) + ["comment"]=> + %a + } + %A + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(5) "Yield" + ["p1"]=> + int(3) + ["p2"]=> + int(0) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + %A + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(7) "String8" + ["p1"]=> + int(0) + ["p2"]=> + int(2) + ["p3"]=> + int(0) + ["p4"]=> + string(13) "second_insert" + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(5) "Yield" + ["p1"]=> + int(3) + ["p2"]=> + int(0) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(12) "EndCoroutine" + ["p1"]=> + int(3) + ["p2"]=> + int(0) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(9) "OpenWrite" + ["p1"]=> + int(0) + ["p2"]=> + int(2) + ["p3"]=> + int(0) + ["p4"]=> + string(1) "1" + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(5) "Yield" + ["p1"]=> + int(3) + ["p2"]=> + int(%d) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(8) "NewRowid" + ["p1"]=> + int(0) + ["p2"]=> + int(1) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(10) "MakeRecord" + ["p1"]=> + int(2) + ["p2"]=> + int(1) + ["p3"]=> + int(4) + ["p4"]=> + string(1) "C" + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(6) "Insert" + ["p1"]=> + int(0) + ["p2"]=> + int(4) + ["p3"]=> + int(1) + ["p4"]=> + string(12) "test_explain" + ["p5"]=> + int(57) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(4) "Goto" + ["p1"]=> + int(0) + ["p2"]=> + int(%d) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(4) "Halt" + ["p1"]=> + int(0) + ["p2"]=> + int(0) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(11) "Transaction" + ["p1"]=> + int(0) + ["p2"]=> + int(1) + ["p3"]=> + int(1) + ["p4"]=> + string(1) "0" + ["p5"]=> + int(1) + ["comment"]=> + %a + } + [%d]=> + array(8) { + ["addr"]=> + int(%d) + ["opcode"]=> + string(4) "Goto" + ["p1"]=> + int(0) + ["p2"]=> + int(1) + ["p3"]=> + int(0) + ["p4"]=> + NULL + ["p5"]=> + int(0) + ["comment"]=> + %a + } +} +array(1) { + [0]=> + array(4) { + ["id"]=> + int(2) + ["parent"]=> + int(0) + ["notused"]=> + int(0) + ["detail"]=> + string(17) "SCAN test_explain" + } +} +array(2) { + [0]=> + array(1) { + ["a"]=> + string(12) "first insert" + } + [1]=> + array(1) { + ["a"]=> + string(13) "second_insert" + } +} +SQLite3Stmt::setExplain(): Argument #1 ($mode) must be one of the SQLite3Stmt::EXPLAIN_MODE_* constants +SQLite3Stmt::setExplain(): Argument #1 ($mode) must be one of the SQLite3Stmt::EXPLAIN_MODE_* constants +bool(true) From 375316d0e24259077a4709bc21e0c0c628611a18 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 19 Jun 2025 23:38:51 +0100 Subject: [PATCH 23/62] ext/sqlite3: Sqlite3Result::fetchAll() support associative and indexes arrays for results. close GH-1884 --- NEWS | 2 + UPGRADING | 5 ++ ext/sqlite3/sqlite3.c | 101 ++++++++++++++++----- ext/sqlite3/sqlite3.stub.php | 2 + ext/sqlite3/sqlite3_arginfo.h | 12 +-- ext/sqlite3/tests/sqlite3_fetch_all.phpt | 108 +++++++++++++++++++++++ 6 files changed, 205 insertions(+), 25 deletions(-) create mode 100644 ext/sqlite3/tests/sqlite3_fetch_all.phpt diff --git a/NEWS b/NEWS index ccda0d50af84e..1ce8ce754adc9 100644 --- a/NEWS +++ b/NEWS @@ -249,6 +249,8 @@ PHP NEWS (David Carlier) . Added Sqlite3Stmt::explain to produce a explain query plan from the statement. (David Carlier) + . Added Sqlite3Result::fetchAll to returns all results at once from a query. + (David Carlier) - Standard: . Fixed crypt() tests on musl when using --with-external-libcrypt diff --git a/UPGRADING b/UPGRADING index e551f0c894260..4c6e40cfdebaf 100644 --- a/UPGRADING +++ b/UPGRADING @@ -212,6 +212,11 @@ PHP 8.5 UPGRADE NOTES now have an optional $lang parameter. This support solves compatibility with .NET SOAP clients. +- Sqlite: + . Added class constants Sqlite3Stmt::EXPLAIN_MODE_PREPARED, + Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN and + Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN. + - XSL: . The $namespace argument of XSLTProcessor::getParameter(), XSLTProcessor::setParameter() and XSLTProcessor::removeParameter() diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 349d2823bb1e0..5e402300980bb 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -39,6 +39,7 @@ static PHP_GINIT_FUNCTION(sqlite3); static int php_sqlite3_authorizer(void *autharg, int action, const char *arg1, const char *arg2, const char *arg3, const char *arg4); static void sqlite3_param_dtor(zval *data); static int php_sqlite3_compare_stmt_free(php_sqlite3_stmt **stmt_obj_ptr, sqlite3_stmt *statement); +static zend_always_inline void php_sqlite3_fetch_one(int n_cols, php_sqlite3_result *result_obj, zend_long mode, zval *result); #define SQLITE3_CHECK_INITIALIZED(db_obj, member, class_name) \ if (!(db_obj) || !(member)) { \ @@ -1991,7 +1992,7 @@ PHP_METHOD(SQLite3Result, fetchArray) { php_sqlite3_result *result_obj; zval *object = ZEND_THIS; - int i, ret; + int ret; zend_long mode = PHP_SQLITE3_BOTH; result_obj = Z_SQLITE3_RESULT_P(object); @@ -2028,26 +2029,8 @@ PHP_METHOD(SQLite3Result, fetchArray) array_init(return_value); - for (i = 0; i < n_cols; i++) { - zval data; - - sqlite_value_to_zval(result_obj->stmt_obj->stmt, i, &data); - - if (mode & PHP_SQLITE3_NUM) { - add_index_zval(return_value, i, &data); - } + php_sqlite3_fetch_one(n_cols, result_obj, mode, return_value); - if (mode & PHP_SQLITE3_ASSOC) { - if (mode & PHP_SQLITE3_NUM) { - if (Z_REFCOUNTED(data)) { - Z_ADDREF(data); - } - } - /* Note: we can't use the "add_new" variant here instead of "update" because - * when the same column name is encountered, the last result should be taken. */ - zend_symtable_update(Z_ARR_P(return_value), result_obj->column_names[i], &data); - } - } break; case SQLITE_DONE: @@ -2071,6 +2054,61 @@ static void sqlite3result_clear_column_names_cache(php_sqlite3_result *result) { result->column_count = -1; } +PHP_METHOD(SQLite3Result, fetchAll) +{ + int i, nb_cols; + bool done = false; + php_sqlite3_result *result_obj; + zval *object = ZEND_THIS; + zend_long mode = PHP_SQLITE3_BOTH; + result_obj = Z_SQLITE3_RESULT_P(object); + + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(mode) + ZEND_PARSE_PARAMETERS_END(); + + SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result) + + nb_cols = sqlite3_column_count(result_obj->stmt_obj->stmt); + if (mode & PHP_SQLITE3_ASSOC) { + sqlite3result_clear_column_names_cache(result_obj); + result_obj->column_names = emalloc(nb_cols * sizeof(zend_string*)); + + for (i = 0; i < nb_cols; i++) { + const char *column = sqlite3_column_name(result_obj->stmt_obj->stmt, i); + result_obj->column_names[i] = zend_string_init(column, strlen(column), 0); + } + } + result_obj->column_count = nb_cols; + array_init(return_value); + + while (!done) { + int step = sqlite3_step(result_obj->stmt_obj->stmt); + + switch (step) { + case SQLITE_ROW: { + zval result; + array_init_size(&result, result_obj->column_count); + + php_sqlite3_fetch_one(result_obj->column_count, result_obj, mode, &result); + + add_next_index_zval(return_value, &result); + break; + } + case SQLITE_DONE: + done = true; + break; + default: + if (!EG(exception)) { + php_sqlite3_error(result_obj->db_obj, sqlite3_errcode(sqlite3_db_handle(result_obj->stmt_obj->stmt)), "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(result_obj->stmt_obj->stmt))); + } + zval_ptr_dtor(return_value); + RETURN_FALSE; + } + } +} + /* {{{ Resets the result set back to the first row. */ PHP_METHOD(SQLite3Result, reset) { @@ -2429,6 +2467,29 @@ static void sqlite3_param_dtor(zval *data) /* {{{ */ } /* }}} */ +static zend_always_inline void php_sqlite3_fetch_one(int n_cols, php_sqlite3_result *result_obj, zend_long mode, zval *result) +{ + for (int i = 0; i < n_cols; i ++) { + zval data; + sqlite_value_to_zval(result_obj->stmt_obj->stmt, i, &data); + + if (mode & PHP_SQLITE3_NUM) { + add_index_zval(result, i, &data); + } + + if (mode & PHP_SQLITE3_ASSOC) { + if (mode & PHP_SQLITE3_NUM) { + if (Z_REFCOUNTED(data)) { + Z_ADDREF(data); + } + } + /* Note: we can't use the "add_new" variant here instead of "update" because + * when the same column name is encountered, the last result should be taken. */ + zend_symtable_update(Z_ARR_P(result), result_obj->column_names[i], &data); + } + } +} + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(sqlite3) { diff --git a/ext/sqlite3/sqlite3.stub.php b/ext/sqlite3/sqlite3.stub.php index 55af378b325c5..54a7b41ec5576 100644 --- a/ext/sqlite3/sqlite3.stub.php +++ b/ext/sqlite3/sqlite3.stub.php @@ -302,6 +302,8 @@ public function columnType(int $column): int|false {} /** @tentative-return-type */ public function fetchArray(int $mode = SQLITE3_BOTH): array|false {} + public function fetchAll(int $mode = SQLITE3_BOTH): array|false {} + /** @tentative-return-type */ public function reset(): bool {} diff --git a/ext/sqlite3/sqlite3_arginfo.h b/ext/sqlite3/sqlite3_arginfo.h index e306af04538b3..54ca70cad5c53 100644 --- a/ext/sqlite3/sqlite3_arginfo.h +++ b/ext/sqlite3/sqlite3_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c3216eada9881743cbd3aa1510f1200b7ce0d942 */ + * Stub hash: da91c32c6070c808d6e1b01894b5f8beedda7b45 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -173,6 +173,10 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SQLite3Result_fe ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "SQLITE3_BOTH") ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_SQLite3Result_fetchAll, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "SQLITE3_BOTH") +ZEND_END_ARG_INFO() + #define arginfo_class_SQLite3Result_reset arginfo_class_SQLite3_close #define arginfo_class_SQLite3Result_finalize arginfo_class_SQLite3Stmt_close @@ -224,6 +228,7 @@ ZEND_METHOD(SQLite3Result, numColumns); ZEND_METHOD(SQLite3Result, columnName); ZEND_METHOD(SQLite3Result, columnType); ZEND_METHOD(SQLite3Result, fetchArray); +ZEND_METHOD(SQLite3Result, fetchAll); ZEND_METHOD(SQLite3Result, reset); ZEND_METHOD(SQLite3Result, finalize); @@ -284,6 +289,7 @@ static const zend_function_entry class_SQLite3Result_methods[] = { ZEND_ME(SQLite3Result, columnName, arginfo_class_SQLite3Result_columnName, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Result, columnType, arginfo_class_SQLite3Result_columnType, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Result, fetchArray, arginfo_class_SQLite3Result_fetchArray, ZEND_ACC_PUBLIC) + ZEND_ME(SQLite3Result, fetchAll, arginfo_class_SQLite3Result_fetchAll, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Result, reset, arginfo_class_SQLite3Result_reset, ZEND_ACC_PUBLIC) ZEND_ME(SQLite3Result, finalize, arginfo_class_SQLite3Result_finalize, ZEND_ACC_PUBLIC) ZEND_FE_END @@ -564,16 +570,12 @@ static zend_class_entry *register_class_SQLite3Stmt(void) zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_PREPARED_name, &const_EXPLAIN_MODE_PREPARED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EXPLAIN_MODE_PREPARED_name); -#endif -#if SQLITE_VERSION_NUMBER >= 3043000 zval const_EXPLAIN_MODE_EXPLAIN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_value, 1); zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, 1); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_name, &const_EXPLAIN_MODE_EXPLAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_EXPLAIN_MODE_EXPLAIN_name); -#endif -#if SQLITE_VERSION_NUMBER >= 3043000 zval const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, 2); diff --git a/ext/sqlite3/tests/sqlite3_fetch_all.phpt b/ext/sqlite3/tests/sqlite3_fetch_all.phpt new file mode 100644 index 0000000000000..5a318afb12561 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_fetch_all.phpt @@ -0,0 +1,108 @@ +--TEST-- +SQLite3Result::fetchAll usage +--EXTENSIONS-- +sqlite3 +--FILE-- +query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->query('insert into users (id, num) values (1, 1)'); +$stmt = $conn->query('insert into users (id, num) values (2, 2)'); + +$stmt = $conn->query('SELECT * FROM users'); +$rowall = $stmt->fetchAll(); +var_dump($rowall); +$stmt->reset(); +$rowfetch = []; +while (($row = $stmt->fetchArray())) $rowfetch[] = $row; +var_dump($rowfetch); +var_dump($rowall == $rowfetch); +$stmt->reset(); +var_dump($stmt->fetchAll(SQLITE3_NUM)); +$stmt->reset(); +var_dump($stmt->fetchAll(SQLITE3_ASSOC)); + +?> +--EXPECT-- +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + ["id"]=> + int(1) + [1]=> + int(1) + ["num"]=> + int(1) + } + [1]=> + array(4) { + [0]=> + int(2) + ["id"]=> + int(2) + [1]=> + int(2) + ["num"]=> + int(2) + } +} +array(2) { + [0]=> + array(4) { + [0]=> + int(1) + ["id"]=> + int(1) + [1]=> + int(1) + ["num"]=> + int(1) + } + [1]=> + array(4) { + [0]=> + int(2) + ["id"]=> + int(2) + [1]=> + int(2) + ["num"]=> + int(2) + } +} +bool(true) +array(2) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(1) + } + [1]=> + array(2) { + [0]=> + int(2) + [1]=> + int(2) + } +} +array(2) { + [0]=> + array(2) { + ["id"]=> + int(1) + ["num"]=> + int(1) + } + [1]=> + array(2) { + ["id"]=> + int(2) + ["num"]=> + int(2) + } +} From 81865ec5bdcba61b1a4bb39158960d547f4424e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 23 Jun 2025 12:14:00 +0200 Subject: [PATCH 24/62] uri: Improve exceptions for Uri\WhatWg\Url (#18855) A more specific exception message is used, while the code is simplified. --- ext/uri/php_lexbor.c | 65 +++++++++++++++++++++--------------------- ext/uri/tests/004.phpt | 4 +-- ext/uri/tests/007.phpt | 2 +- ext/uri/tests/023.phpt | 4 +-- ext/uri/tests/026.phpt | 4 +-- ext/uri/tests/051.phpt | 2 +- 6 files changed, 40 insertions(+), 41 deletions(-) diff --git a/ext/uri/php_lexbor.c b/ext/uri/php_lexbor.c index 82f3919bb6a97..44bca30f8fda7 100644 --- a/ext/uri/php_lexbor.c +++ b/ext/uri/php_lexbor.c @@ -73,10 +73,10 @@ static void lexbor_cleanup_parser(void) * When errors is NULL, the caller is not interested in the additional error information, * so the function does nothing. */ -static void fill_errors(zval *errors) +static zend_string *fill_errors(zval *errors) { if (errors == NULL) { - return; + return NULL; } ZEND_ASSERT(Z_ISUNDEF_P(errors)); @@ -84,9 +84,10 @@ static void fill_errors(zval *errors) array_init(errors); if (lexbor_parser.log == NULL) { - return; + return NULL; } + zend_string *result = NULL; lexbor_plog_entry_t *lxb_error; while ((lxb_error = lexbor_array_obj_pop(&lexbor_parser.log->list)) != NULL) { zval error; @@ -223,32 +224,29 @@ static void fill_errors(zval *errors) zend_update_property(uri_whatwg_url_validation_error_ce, Z_OBJ(error), ZEND_STRL("failure"), &failure); + if (Z_TYPE(failure) == IS_TRUE) { + result = error_str; + } + add_next_index_zval(errors, &error); } -} - -static void throw_invalid_url_exception(zval *errors) -{ - ZEND_ASSERT(errors != NULL && Z_TYPE_P(errors) == IS_ARRAY); - - zval exception; - - object_init_ex(&exception, uri_whatwg_invalid_url_exception_ce); - - zval value; - ZVAL_STRING(&value, "URL parsing failed"); - zend_update_property_ex(uri_whatwg_invalid_url_exception_ce, Z_OBJ(exception), ZSTR_KNOWN(ZEND_STR_MESSAGE), &value); - zval_ptr_dtor_str(&value); - - zend_update_property(uri_whatwg_invalid_url_exception_ce, Z_OBJ(exception), ZEND_STRL("errors"), errors); - zend_throw_exception_object(&exception); + return result; } -static void throw_invalid_url_exception_during_write(zval *errors) +static void throw_invalid_url_exception_during_write(zval *errors, const char *component) { - fill_errors(errors); - throw_invalid_url_exception(errors); + zend_string *reason = fill_errors(errors); + zend_object *exception = zend_throw_exception_ex( + uri_whatwg_invalid_url_exception_ce, + 0, + "The specified %s is malformed%s%s%s", + component, + reason ? " (" : "", + reason ? ZSTR_VAL(reason) : "", + reason ? ")" : "" + ); + zend_update_property(exception->ce, exception, ZEND_STRL("errors"), errors); } static lxb_status_t lexbor_serialize_callback(const lxb_char_t *data, size_t length, void *ctx) @@ -281,7 +279,7 @@ static zend_result lexbor_write_scheme(struct uri_internal_t *internal_uri, zval zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_protocol_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "scheme"); return FAILURE; } @@ -310,7 +308,7 @@ static zend_result lexbor_write_username(uri_internal_t *internal_uri, zval *val zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_username_set(lexbor_uri, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "username"); return FAILURE; } @@ -339,7 +337,7 @@ static zend_result lexbor_write_password(struct uri_internal_t *internal_uri, zv zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_password_set(lexbor_uri, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "password"); return FAILURE; } @@ -411,7 +409,7 @@ static zend_result lexbor_write_host(struct uri_internal_t *internal_uri, zval * zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_hostname_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "host"); return FAILURE; } @@ -440,7 +438,7 @@ static zend_result lexbor_write_port(struct uri_internal_t *internal_uri, zval * zval_long_or_null_to_lexbor_str(value, &str); if (lxb_url_api_port_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "port"); return FAILURE; } @@ -469,7 +467,7 @@ static zend_result lexbor_write_path(struct uri_internal_t *internal_uri, zval * zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_pathname_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "path"); return FAILURE; } @@ -498,7 +496,7 @@ static zend_result lexbor_write_query(struct uri_internal_t *internal_uri, zval zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_search_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "query string"); return FAILURE; } @@ -527,7 +525,7 @@ static zend_result lexbor_write_fragment(struct uri_internal_t *internal_uri, zv zval_string_or_null_to_lexbor_str(value, &str); if (lxb_url_api_hash_set(lexbor_uri, &lexbor_parser, str.data, str.length) != LXB_STATUS_OK) { - throw_invalid_url_exception_during_write(errors); + throw_invalid_url_exception_during_write(errors, "fragment"); return FAILURE; } @@ -569,10 +567,11 @@ lxb_url_t *lexbor_parse_uri_ex(const zend_string *uri_str, const lxb_url_t *lexb lexbor_cleanup_parser(); lxb_url_t *url = lxb_url_parse(&lexbor_parser, lexbor_base_url, (unsigned char *) ZSTR_VAL(uri_str), ZSTR_LEN(uri_str)); - fill_errors(errors); + zend_string *reason = fill_errors(errors); if (url == NULL && !silent) { - throw_invalid_url_exception(errors); + zend_object *exception = zend_throw_exception_ex(uri_whatwg_invalid_url_exception_ce, 0, "The specified URI is malformed%s%s%s", reason ? " (" : "", reason ? ZSTR_VAL(reason) : "", reason ? ")" : ""); + zend_update_property(exception->ce, exception, ZEND_STRL("errors"), errors); } return url; diff --git a/ext/uri/tests/004.phpt b/ext/uri/tests/004.phpt index 04127a7ded0d3..abbad59fee2e8 100644 --- a/ext/uri/tests/004.phpt +++ b/ext/uri/tests/004.phpt @@ -18,8 +18,8 @@ var_dump(Uri\WhatWg\Url::parse("192.168/contact.html", null)); var_dump(Uri\WhatWg\Url::parse("http://RuPaul's Drag Race All Stars 7 Winners Cast on This Season's", null)); ?> ---EXPECTF-- -URL parsing failed +--EXPECT-- +The specified URI is malformed (MissingSchemeNonRelativeUrl) NULL NULL NULL diff --git a/ext/uri/tests/007.phpt b/ext/uri/tests/007.phpt index e60e69fc113a3..cb445fcf71a43 100644 --- a/ext/uri/tests/007.phpt +++ b/ext/uri/tests/007.phpt @@ -19,7 +19,7 @@ var_dump($failures); ?> --EXPECTF-- -URL parsing failed +The specified URI is malformed (PortInvalid) array(%d) { [0]=> object(Uri\WhatWg\UrlValidationError)#%d (%d) { diff --git a/ext/uri/tests/023.phpt b/ext/uri/tests/023.phpt index b48e2df838eef..a1ca06bd6f6e5 100644 --- a/ext/uri/tests/023.phpt +++ b/ext/uri/tests/023.phpt @@ -27,5 +27,5 @@ try { --EXPECT-- string(5) "https" string(4) "http" -URL parsing failed -URL parsing failed +The specified scheme is malformed +The specified scheme is malformed diff --git a/ext/uri/tests/026.phpt b/ext/uri/tests/026.phpt index 4640ebebae52d..4763ea9d4406c 100644 --- a/ext/uri/tests/026.phpt +++ b/ext/uri/tests/026.phpt @@ -43,7 +43,7 @@ string(8) "test.com" string(8) "test.com" string(8) "test.com" NULL -URL parsing failed +The specified host is malformed (DomainInvalidCodePoint) object(Uri\WhatWg\Url)#%d (%d) { ["scheme"]=> string(5) "https" @@ -62,6 +62,6 @@ object(Uri\WhatWg\Url)#%d (%d) { ["fragment"]=> NULL } -URL parsing failed +The specified host is malformed (HostMissing) string(7) "foo.com" string(8) "test.com" diff --git a/ext/uri/tests/051.phpt b/ext/uri/tests/051.phpt index 5911f8767567c..ad4751470e23b 100644 --- a/ext/uri/tests/051.phpt +++ b/ext/uri/tests/051.phpt @@ -20,7 +20,7 @@ var_dump($softErrors); ?> --EXPECTF-- -URL parsing failed +The specified URI is malformed (Ipv4TooManyParts) string(23) "https://example.com/foo" array(%d) { [0]=> From 2ccd2b016df2c4cf8ff36a65b5875f1a7e39ac21 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 14 Jun 2025 11:11:38 +0100 Subject: [PATCH 25/62] ext/calendar: jewishtojd overflow on year argument. Upper limit set to the 7th millenium (Messianic Age) in the jewish calendar, around 2239 year in the gregorian calendar. close GH-18849 --- NEWS | 3 +++ ext/calendar/calendar.c | 5 +++++ ext/calendar/jewish.c | 2 +- ext/calendar/tests/gh16234_2.phpt | 11 +++++++++++ ext/calendar/tests/gh16234_2_64.phpt | 21 +++++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ext/calendar/tests/gh16234_2.phpt create mode 100644 ext/calendar/tests/gh16234_2_64.phpt diff --git a/NEWS b/NEWS index ea77125b205eb..fd344ee94c72e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.3.24 +- Calendar: + . Fixed jewishtojd overflow on year argument. (David Carlier) + - Core: . Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction order). (Daniil Gentili) diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index 756ce0e90dc98..6da7e69529e2e 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -490,6 +490,11 @@ PHP_FUNCTION(jewishtojd) RETURN_THROWS(); } + if (ZEND_LONG_EXCEEDS_INT(year)) { + zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX); + RETURN_THROWS(); + } + RETURN_LONG(JewishToSdn(year, month, day)); } /* }}} */ diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c index bdfc9b4f91016..2fbdcb059b096 100644 --- a/ext/calendar/jewish.c +++ b/ext/calendar/jewish.c @@ -714,7 +714,7 @@ zend_long JewishToSdn( int yearLength; int lengthOfAdarIAndII; - if (year <= 0 || day <= 0 || day > 30) { + if (year <= 0 || year >= 6000 || day <= 0 || day > 30) { return (0); } switch (month) { diff --git a/ext/calendar/tests/gh16234_2.phpt b/ext/calendar/tests/gh16234_2.phpt new file mode 100644 index 0000000000000..76db2b9abf269 --- /dev/null +++ b/ext/calendar/tests/gh16234_2.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-16234 jewishtojd overflow on year argument +--EXTENSIONS-- +calendar +--FILE-- + +--EXPECTF-- +DONE diff --git a/ext/calendar/tests/gh16234_2_64.phpt b/ext/calendar/tests/gh16234_2_64.phpt new file mode 100644 index 0000000000000..7da2546096509 --- /dev/null +++ b/ext/calendar/tests/gh16234_2_64.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-16234 jewishtojd overflow on year argument +--EXTENSIONS-- +calendar +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +jewishtojd(): Argument #3 ($year) must be between %i and %d + From 67bbf9c9610465e42378b34301505f26045aed8d Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 20 Jun 2025 15:17:51 +0200 Subject: [PATCH 26/62] ext/filter: Remove ZPP test --- ext/filter/tests/057.phpt | 52 --------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 ext/filter/tests/057.phpt diff --git a/ext/filter/tests/057.phpt b/ext/filter/tests/057.phpt deleted file mode 100644 index ec8083e2f891d..0000000000000 --- a/ext/filter/tests/057.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -filter_input_array() and filter_var_array() with invalid $definition arguments ---EXTENSIONS-- -filter ---FILE-- -getMessage() . "\n"; - } - - try { - var_dump(filter_var_array(array(), $invalid)); - } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; - } -} -?> ---EXPECTF-- -Deprecated: filter_input_array(): Passing null to parameter #2 ($options) of type array|int is deprecated in %s on line %d - -Warning: filter_input_array(): Unknown filter with ID 0 in %s on line %d -bool(false) - -Deprecated: filter_var_array(): Passing null to parameter #2 ($options) of type array|int is deprecated in %s on line %d - -Warning: filter_var_array(): Unknown filter with ID 0 in %s on line %d -bool(false) - -Warning: filter_input_array(): Unknown filter with ID 1 in %s on line %d -bool(false) - -Warning: filter_var_array(): Unknown filter with ID 1 in %s on line %d -bool(false) - -Warning: filter_input_array(): Unknown filter with ID 0 in %s on line %d -bool(false) - -Warning: filter_var_array(): Unknown filter with ID 0 in %s on line %d -bool(false) - -Warning: filter_input_array(): Unknown filter with ID 1 in %s on line %d -bool(false) - -Warning: filter_var_array(): Unknown filter with ID 1 in %s on line %d -bool(false) -filter_input_array(): Argument #2 ($options) must be of type array|int, string given -filter_var_array(): Argument #2 ($options) must be of type array|int, string given -filter_input_array(): Argument #2 ($options) must be of type array|int, stdClass given -filter_var_array(): Argument #2 ($options) must be of type array|int, stdClass given From c03f6065fa9be4f898bddc351451ba964f8c75bb Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 20 Jun 2025 15:20:16 +0200 Subject: [PATCH 27/62] ext/calendar: Remove ZPP test --- ext/calendar/tests/unixtojd_error1.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/calendar/tests/unixtojd_error1.phpt b/ext/calendar/tests/unixtojd_error1.phpt index 6b8fad05ebd83..171d400b99e76 100644 --- a/ext/calendar/tests/unixtojd_error1.phpt +++ b/ext/calendar/tests/unixtojd_error1.phpt @@ -15,7 +15,6 @@ try { } catch (ValueError $ex) { echo $ex->getMessage(), PHP_EOL; } -var_dump(unixtojd(false)) . PHP_EOL; var_dump(unixtojd(null)) . PHP_EOL; var_dump(unixtojd(time())) . PHP_EOL; ?> @@ -23,4 +22,3 @@ var_dump(unixtojd(time())) . PHP_EOL; unixtojd(): Argument #1 ($timestamp) must be greater than or equal to 0 int(%d) int(%d) -int(%d) From c7778641dde526cc6024cc2b6aff321452473c34 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Fri, 20 Jun 2025 15:52:30 +0200 Subject: [PATCH 28/62] ext/mbstring: Remove ZPP tests --- ext/mbstring/tests/bug43994.phpt | 59 ++---- ext/mbstring/tests/bug43998.phpt | 42 +---- ext/mbstring/tests/gh16229.phpt | 2 +- .../tests/mb_ereg_replace_variation1.phpt | 65 +------ ...titute_character_variation_weak_types.phpt | 172 ------------------ 5 files changed, 29 insertions(+), 311 deletions(-) delete mode 100644 ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt diff --git a/ext/mbstring/tests/bug43994.phpt b/ext/mbstring/tests/bug43994.phpt index 26f641f6d3d7e..b4ae29ff40e7f 100644 --- a/ext/mbstring/tests/bug43994.phpt +++ b/ext/mbstring/tests/bug43994.phpt @@ -14,55 +14,24 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build * pattern is supplied to mb_ereg. Similar error message to ereg(). */ -$inputs = array(false, FALSE, "", ''); +$input = ''; +echo "Without \$regs arg:\n"; +try { + var_dump( mb_ereg($input, 'hello, world') ); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} -$iterator = 1; -foreach($inputs as $input) { - if(@is_array($mb_regs)){ - $mb_regs = ''; - } - echo "\n-- Iteration $iterator --\n"; - echo "Without \$regs arg:\n"; - try { - var_dump( mb_ereg($input, 'hello, world') ); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } +echo "With \$regs arg:\n"; +try { + var_dump(mb_ereg($input, 'hello, world', $mb_regs)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} - echo "With \$regs arg:\n"; - try { - var_dump(mb_ereg($input, 'hello, world', $mb_regs)); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - - var_dump($mb_regs); - $iterator++; -}; +var_dump($mb_regs); ?> --EXPECT-- --- Iteration 1 -- -Without $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -With $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -NULL - --- Iteration 2 -- -Without $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -With $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -NULL - --- Iteration 3 -- -Without $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -With $regs arg: -mb_ereg(): Argument #1 ($pattern) must not be empty -NULL - --- Iteration 4 -- Without $regs arg: mb_ereg(): Argument #1 ($pattern) must not be empty With $regs arg: diff --git a/ext/mbstring/tests/bug43998.phpt b/ext/mbstring/tests/bug43998.phpt index 112ab88728341..5be1bd2cc9ffd 100644 --- a/ext/mbstring/tests/bug43998.phpt +++ b/ext/mbstring/tests/bug43998.phpt @@ -11,41 +11,19 @@ mbstring $sourcestring = 'Hello, World'; -$inputs = array(12345, 12.3456789000E-10, true, false, ""); -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump( mb_strtolower($sourcestring, $input) ); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - try { - var_dump( mb_strtoupper($sourcestring, $input) ); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - $iterator++; +$input = ""; +try { + var_dump( mb_strtolower($sourcestring, $input) ); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump( mb_strtoupper($sourcestring, $input) ); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } ?> --EXPECT-- --- Iteration 1 -- -mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "12345" given -mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "12345" given - --- Iteration 2 -- -mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "1.23456789E-9" given -mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "1.23456789E-9" given - --- Iteration 3 -- -mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "1" given -mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "1" given - --- Iteration 4 -- -mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "" given -mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "" given - --- Iteration 5 -- mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "" given mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "" given diff --git a/ext/mbstring/tests/gh16229.phpt b/ext/mbstring/tests/gh16229.phpt index 1fe558d9b1025..6e4924a091a54 100644 --- a/ext/mbstring/tests/gh16229.phpt +++ b/ext/mbstring/tests/gh16229.phpt @@ -14,7 +14,7 @@ if (!function_exists("mb_send_mail") || !mb_language("japanese")) { --FILE-- ---INI-- -error_reporting=E_ALL & ~E_NOTICE +Test mb_ereg_replace() function : usage variations - different input types --EXTENSIONS-- mbstring --SKIPIF-- @@ -17,22 +15,8 @@ $replacement = 'string_val'; $string = 'string_val'; $option = ''; -// get a class -class classA -{ - public function __toString() { - return "UTF-8"; - } -} - -// heredoc string -$heredoc = << 1, 'two' => 2); - -//array of values to iterate over -$inputs = array( - - // int data - 'int 0' => 0, - 'int 1' => 1, - 'int 12345' => 12345, - 'int -12345' => -2345, - - // float data - 'float 10.5' => 10.5, - 'float -10.5' => -10.5, - 'float 10.0e19' => 10.0e19, // Cannot be represented as int - 'float -10.0e19' => -10.0e19, // Cannot be represented as int - 'float .5' => .5, - - // array data - 'empty array' => array(), - 'int indexed array' => $index_array, - 'associative array' => $assoc_array, - 'nested arrays' => array('foo', $index_array, $assoc_array), - - // null data - 'uppercase NULL' => NULL, - 'lowercase null' => null, - - // boolean data - 'lowercase true' => true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - - // empty data - 'empty string DQ' => "", - 'empty string SQ' => '', - - // string data - 'string DQ' => "string", - 'string SQ' => 'string', - 'mixed case string' => "sTrInG", - 'heredoc' => $heredoc, - - // object data - 'instance of classWithToString' => new classWithToString(), - 'instance of classWithoutToString' => new classWithoutToString(), - - // undefined data - 'undefined var' => @$undefined_var, - - // unset data - 'unset var' => @$unset_var, -); - -// loop through each element of the array for substchar - -mb_internal_encoding('utf-8'); -foreach($inputs as $key =>$value) { - echo "--$key--\n"; - try { - var_dump( mb_substitute_character($value) ); - } catch (\ValueError|\TypeError $e) { - echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL; - } -} - -fclose($fp); - -?> ---EXPECTF-- -*** Testing mb_substitute_character(): various types in weak typing mode *** ---int 0-- -bool(true) ---int 1-- -bool(true) ---int 12345-- -bool(true) ---int -12345-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint ---float 10.5-- - -Deprecated: Implicit conversion from float 10.5 to int loses precision in %s on line %d -bool(true) ---float -10.5-- - -Deprecated: Implicit conversion from float -10.5 to int loses precision in %s on line %d -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint ---float 10.0e19-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---float -10.0e19-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---float .5-- - -Deprecated: Implicit conversion from float 0.5 to int loses precision in %s on line %d -bool(true) ---empty array-- -TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given ---int indexed array-- -TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given ---associative array-- -TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given ---nested arrays-- -TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given ---uppercase NULL-- -int(0) ---lowercase null-- -int(0) ---lowercase true-- -bool(true) ---lowercase false-- -bool(true) ---uppercase TRUE-- -bool(true) ---uppercase FALSE-- -bool(true) ---empty string DQ-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---empty string SQ-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---string DQ-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---string SQ-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---mixed case string-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---heredoc-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---instance of classWithToString-- -ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint ---instance of classWithoutToString-- -TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, classWithoutToString given ---undefined var-- -int(0) ---unset var-- -int(0) From b068bef45dabcb061eef2bea07593676fdb6e1b8 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 14:08:58 +0200 Subject: [PATCH 29/62] ext/dom: Remove bool type coercions in tests --- ext/dom/tests/bug46849.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/dom/tests/bug46849.phpt b/ext/dom/tests/bug46849.phpt index a26fa2b2311db..a9cdd5bba578b 100644 --- a/ext/dom/tests/bug46849.phpt +++ b/ext/dom/tests/bug46849.phpt @@ -5,7 +5,7 @@ dom --FILE-- formatOutput = 1; +$dom->formatOutput = true; var_dump($dom->formatOutput); $dom2 = clone $dom; From 8cd4f95ea374748bc5e76774097658d27d1e99a8 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 14:16:28 +0200 Subject: [PATCH 30/62] ext/pcntl: Remove bool type coercions in tests --- ext/pcntl/tests/async_signals.phpt | 2 +- ext/pcntl/tests/async_signals_2.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/pcntl/tests/async_signals.phpt b/ext/pcntl/tests/async_signals.phpt index e9c1c96d4ea9c..dd0f602c25be2 100644 --- a/ext/pcntl/tests/async_signals.phpt +++ b/ext/pcntl/tests/async_signals.phpt @@ -5,7 +5,7 @@ pcntl posix --FILE-- Date: Mon, 23 Jun 2025 14:17:53 +0200 Subject: [PATCH 31/62] ext/posix: Remove ZPP tests --- ext/posix/tests/posix_seteuid_variation2.phpt | 38 ------------------- ext/posix/tests/posix_setgid_variation2.phpt | 38 ------------------- ext/posix/tests/posix_setuid_variation2.phpt | 38 ------------------- 3 files changed, 114 deletions(-) delete mode 100644 ext/posix/tests/posix_seteuid_variation2.phpt delete mode 100644 ext/posix/tests/posix_setgid_variation2.phpt delete mode 100644 ext/posix/tests/posix_setuid_variation2.phpt diff --git a/ext/posix/tests/posix_seteuid_variation2.phpt b/ext/posix/tests/posix_seteuid_variation2.phpt deleted file mode 100644 index 700f44e5c8f22..0000000000000 --- a/ext/posix/tests/posix_seteuid_variation2.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Test function posix_seteuid() by substituting argument 1 with boolean values. ---EXTENSIONS-- -posix ---SKIPIF-- - ---CREDITS-- -Marco Fabbri mrfabbri@gmail.com -Francesco Fullone ff@ideato.it -#PHPTestFest Cesena Italia on 2009-06-20 ---FILE-- - true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - ); - - -foreach ( $variation_array as $var ) { - var_dump(posix_seteuid( $var ) ); -} -?> ---EXPECT-- -*** Test substituting argument 1 with boolean values *** -bool(false) -bool(false) -bool(false) -bool(false) diff --git a/ext/posix/tests/posix_setgid_variation2.phpt b/ext/posix/tests/posix_setgid_variation2.phpt deleted file mode 100644 index 8504706c54756..0000000000000 --- a/ext/posix/tests/posix_setgid_variation2.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Test function posix_setgid() by substituting argument 1 with boolean values. ---EXTENSIONS-- -posix ---SKIPIF-- - ---CREDITS-- -Marco Fabbri mrfabbri@gmail.com -Francesco Fullone ff@ideato.it -#PHPTestFest Cesena Italia on 2009-06-20 ---FILE-- - true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - ); - - -foreach ( $variation_array as $var ) { - var_dump(posix_setgid( $var ) ); -} -?> ---EXPECT-- -*** Test substituting argument 1 with boolean values *** -bool(false) -bool(false) -bool(false) -bool(false) diff --git a/ext/posix/tests/posix_setuid_variation2.phpt b/ext/posix/tests/posix_setuid_variation2.phpt deleted file mode 100644 index 5b2f64f7859ef..0000000000000 --- a/ext/posix/tests/posix_setuid_variation2.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -Test function posix_setuid() by substituting argument 1 with boolean values. ---EXTENSIONS-- -posix ---SKIPIF-- - ---CREDITS-- -Marco Fabbri mrfabbri@gmail.com -Francesco Fullone ff@ideato.it -#PHPTestFest Cesena Italia on 2009-06-20 ---FILE-- - true, - 'lowercase false' =>false, - 'uppercase TRUE' =>TRUE, - 'uppercase FALSE' =>FALSE, - ); - - -foreach ( $variation_array as $var ) { - var_dump(posix_setuid( $var ) ); -} -?> ---EXPECT-- -*** Test substituting argument 1 with boolean values *** -bool(false) -bool(false) -bool(false) -bool(false) From 4ff8d9f6b4a1e0fc84e4e5681fde499516e94186 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 13:49:20 +0100 Subject: [PATCH 32/62] ext/uri: Remove bool type coercions in tests (#18921) --- ext/uri/tests/053.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/uri/tests/053.phpt b/ext/uri/tests/053.phpt index 93ff77b15c0a5..2bd02365b09a0 100644 --- a/ext/uri/tests/053.phpt +++ b/ext/uri/tests/053.phpt @@ -25,13 +25,13 @@ try { } try { - $r->__construct("baz", [], false); + $r->__construct("baz", [], 0); } catch (Error $e) { echo $e->getMessage() . "\n"; } try { - $r->__construct("qax", [], false, null); + $r->__construct("qax", [], 0, null); } catch (Error $e) { echo $e->getMessage() . "\n"; } From 40be5fa99fc25007078f196dd7cdb26e805cc45f Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 14:43:53 +0200 Subject: [PATCH 33/62] ext/sockets: Remove bool type coercions in tests --- ext/sockets/tests/socket_export_stream-1.phpt | 2 +- ext/sockets/tests/socket_export_stream-3.phpt | 2 +- ext/sockets/tests/socket_export_stream-4.phpt | 2 +- ext/sockets/tests/socket_import_stream-1.phpt | 2 +- ext/sockets/tests/socket_import_stream-3.phpt | 2 +- ext/sockets/tests/socket_import_stream-4.phpt | 5 ++--- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ext/sockets/tests/socket_export_stream-1.phpt b/ext/sockets/tests/socket_export_stream-1.phpt index b2a01ddcca10d..9b832a80aac33 100644 --- a/ext/sockets/tests/socket_export_stream-1.phpt +++ b/ext/sockets/tests/socket_export_stream-1.phpt @@ -5,7 +5,7 @@ sockets --FILE-- diff --git a/ext/sockets/tests/socket_export_stream-4.phpt b/ext/sockets/tests/socket_export_stream-4.phpt index 512a62379e98c..a3879a93b7cd8 100644 --- a/ext/sockets/tests/socket_export_stream-4.phpt +++ b/ext/sockets/tests/socket_export_stream-4.phpt @@ -16,7 +16,7 @@ function test($stream, $sock) { if ($stream !== null) { echo "stream_set_blocking "; try { - print_r(stream_set_blocking($stream, 0)); + print_r(stream_set_blocking($stream, false)); } catch (Error $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; } diff --git a/ext/sockets/tests/socket_import_stream-1.phpt b/ext/sockets/tests/socket_import_stream-1.phpt index 80d3069fc01e7..8d5ec01cd7d01 100644 --- a/ext/sockets/tests/socket_import_stream-1.phpt +++ b/ext/sockets/tests/socket_import_stream-1.phpt @@ -5,7 +5,7 @@ sockets --FILE-- diff --git a/ext/sockets/tests/socket_import_stream-4.phpt b/ext/sockets/tests/socket_import_stream-4.phpt index 25e425961f613..efe987dfdce28 100644 --- a/ext/sockets/tests/socket_import_stream-4.phpt +++ b/ext/sockets/tests/socket_import_stream-4.phpt @@ -4,8 +4,7 @@ socket_import_stream: effects of closing sockets --SKIPIF-- @@ -16,7 +15,7 @@ function test($stream, $sock) { if ($stream !== null) { echo "stream_set_blocking "; try { - print_r(stream_set_blocking($stream, 0)); + print_r(stream_set_blocking($stream, false)); } catch (Error $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; } From 4baecc1d4a2561a96df9f6f57e82d97b32a154dd Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 14:50:49 +0200 Subject: [PATCH 34/62] ext/simplexml: Remove bool type coercions in tests --- ext/simplexml/tests/profile13.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/simplexml/tests/profile13.phpt b/ext/simplexml/tests/profile13.phpt index 8c441654c8bee..be2b38f30bba4 100644 --- a/ext/simplexml/tests/profile13.phpt +++ b/ext/simplexml/tests/profile13.phpt @@ -21,9 +21,9 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" EOF; $sxe = simplexml_load_string($xml); -var_dump($sxe->children('soap', 1)); +var_dump($sxe->children('soap', true)); -$sxe = simplexml_load_string($xml, NULL, 0, 'soap', 1); +$sxe = simplexml_load_string($xml, NULL, 0, 'soap', true); var_dump($sxe->Body); var_dump($sxe->Body->children('')); var_dump($sxe->Body->children('')->businessList); From 7f80d4dc7ddc012a7d4f4ea2ff75c279592408a2 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 14:56:03 +0200 Subject: [PATCH 35/62] ext/session: Remove bool type coercions in tests --- ext/session/tests/010.phpt | 2 +- ext/session/tests/session_encode_variation8.phpt | 4 ++-- .../user_session_module/session_set_save_handler_basic.phpt | 2 +- .../session_set_save_handler_closures.phpt | 2 +- .../session_set_save_handler_variation1.phpt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/session/tests/010.phpt b/ext/session/tests/010.phpt index 367edcfa61fd4..1a48680106d80 100644 --- a/ext/session/tests/010.phpt +++ b/ext/session/tests/010.phpt @@ -11,7 +11,7 @@ session.cache_limiter= --EXPECT-- diff --git a/ext/session/tests/session_encode_variation8.phpt b/ext/session/tests/session_encode_variation8.phpt index 3571e8c821691..326b03711580d 100644 --- a/ext/session/tests/session_encode_variation8.phpt +++ b/ext/session/tests/session_encode_variation8.phpt @@ -16,7 +16,7 @@ echo "*** Testing session_encode() : variation ***\n"; var_dump(session_start()); $_SESSION["foo"] = 1234567890; $encoded = session_encode(); -var_dump(base64_encode($encoded)); +var_dump($encoded); var_dump(session_destroy()); echo "Done"; @@ -29,7 +29,7 @@ Warning: session_start(): Cannot find session serialization handler "blah" - ses bool(false) Warning: session_encode(): Cannot encode non-existent session in %s on line %d -string(0) "" +bool(false) Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d bool(false) diff --git a/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt b/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt index b3932b52587a1..b864d50ab7e9f 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt @@ -16,7 +16,7 @@ echo "*** Testing session_set_save_handler() : basic functionality ***\n"; require_once "save_handler.inc"; var_dump(session_module_name()); -var_dump(session_module_name(FALSE)); +var_dump(session_module_name('')); var_dump(session_module_name("blah")); var_dump(session_module_name("foo")); diff --git a/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt b/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt index e84bc6fbef6d4..08f533e6cee38 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt @@ -15,7 +15,7 @@ echo "*** Testing session_set_save_handler() : using closures as callbacks ***\n require_once "save_handler_closures.inc"; var_dump(session_module_name()); -var_dump(session_module_name(FALSE)); +var_dump(session_module_name('')); var_dump(session_module_name("blah")); var_dump(session_module_name("foo")); diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation1.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation1.phpt index 417103b3d1b1c..87996a3314534 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation1.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation1.phpt @@ -10,7 +10,7 @@ ob_start(); echo "*** Testing session_set_save_handler() : variation ***\n"; var_dump(session_module_name()); -var_dump(session_module_name(FALSE)); +var_dump(session_module_name('')); var_dump(session_module_name()); var_dump(session_module_name("blah")); var_dump(session_module_name()); From c7f0ac1bf942df3b129b558773cace58a72f2b16 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 23 Jun 2025 13:59:05 +0100 Subject: [PATCH 36/62] ext/random: Remove useless tests (#18920) --- .../tests/01_functions/mt_srand_basic.phpt | 24 ----------------- .../tests/01_functions/srand_basic.phpt | 27 ------------------- 2 files changed, 51 deletions(-) delete mode 100644 ext/random/tests/01_functions/mt_srand_basic.phpt delete mode 100644 ext/random/tests/01_functions/srand_basic.phpt diff --git a/ext/random/tests/01_functions/mt_srand_basic.phpt b/ext/random/tests/01_functions/mt_srand_basic.phpt deleted file mode 100644 index aee012d713fa4..0000000000000 --- a/ext/random/tests/01_functions/mt_srand_basic.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Test mt_srand() - basic function (return values) mt_srand() ---FILE-- - ---EXPECTF-- -NULL -NULL - -Deprecated: Implicit conversion from float 500.1 to int loses precision in %s on line %d -NULL -NULL -NULL -NULL -NULL diff --git a/ext/random/tests/01_functions/srand_basic.phpt b/ext/random/tests/01_functions/srand_basic.phpt deleted file mode 100644 index 99f43bc502737..0000000000000 --- a/ext/random/tests/01_functions/srand_basic.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Test srand() - basic function test for srand() ---FILE-- - ---EXPECTF-- -*** Testing srand() : basic functionality *** -NULL -NULL - -Deprecated: Implicit conversion from float 500.1 to int loses precision in %s on line %d -NULL -NULL -NULL -NULL -NULL From fe504d33571f7c21a3529594693460a863dbb5ed Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 23 Jun 2025 00:05:03 +0200 Subject: [PATCH 37/62] Fix leak when creating cycle in hook This is necessary because the VM frees operands with the nogc variants. We cannot just call gc_possible_root() because the object may no longer exist at that point. Fixes GH-18907 Closes GH-18917 --- NEWS | 1 + Zend/tests/gh18907.phpt | 26 ++++++++++++++++++++++++++ Zend/zend_object_handlers.c | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 Zend/tests/gh18907.phpt diff --git a/NEWS b/NEWS index 94eb74cae5179..80b805983e863 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ PHP NEWS - Core: . Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction order). (Daniil Gentili) + . Fixed bug GH-18907 (Leak when creating cycle in hook). (ilutov) - Curl: . Fix memory leaks when returning refcounted value from curl callback. diff --git a/Zend/tests/gh18907.phpt b/Zend/tests/gh18907.phpt new file mode 100644 index 0000000000000..1be881fd4941b --- /dev/null +++ b/Zend/tests/gh18907.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-18907: Leak when creating cycle inside hook +--FILE-- +prop = $this; + return 1; + } + } +} + +function test() { + var_dump((new Foo)->prop); +} + +/* Call twice to test the ZEND_IS_PROPERTY_HOOK_SIMPLE_GET() path. */ +test(); +test(); + +?> +--EXPECT-- +int(1) +int(1) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 0def95fc85227..2ddaeae96e999 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -719,7 +719,9 @@ static bool zend_call_get_hook( return false; } + GC_ADDREF(zobj); zend_call_known_instance_method_with_0_params(get, zobj, rv); + OBJ_RELEASE(zobj); return true; } From b50898894d885eb4a95e6ff88f90ab56f9c8c03c Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:03:45 +0200 Subject: [PATCH 38/62] Unbreak PRINTF_DEBUG macro usages Clearly nobody has used this in a while given the compile errors and warnings. This patch fixes them so there are no errors nor warnings anymore. Closes GH-18910. --- ext/standard/formatted_print.c | 46 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index b988422df21ca..00445d3cca7c7 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -52,10 +52,10 @@ inline static void php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add) { if ((*pos + 1) >= ZSTR_LEN(*buffer)) { - PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), ZSTR_LEN(*buffer))); + PRINTF_DEBUG(("%s(): ereallocing buffer to %zu bytes\n", get_active_function_name(), ZSTR_LEN(*buffer))); *buffer = zend_string_extend(*buffer, ZSTR_LEN(*buffer) << 1, 0); } - PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos)); + PRINTF_DEBUG(("sprintf: appending '%c', pos=%zu\n", add, *pos)); ZSTR_VAL(*buffer)[(*pos)++] = add; } /* }}} */ @@ -67,13 +67,13 @@ php_sprintf_appendchars(zend_string **buffer, size_t *pos, char *add, size_t len if ((*pos + len) >= ZSTR_LEN(*buffer)) { size_t nlen = ZSTR_LEN(*buffer); - PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), ZSTR_LEN(*buffer))); + PRINTF_DEBUG(("%s(): ereallocing buffer to %zu bytes\n", get_active_function_name(), ZSTR_LEN(*buffer))); do { nlen = nlen << 1; } while ((*pos + len) >= nlen); *buffer = zend_string_extend(*buffer, nlen, 0); } - PRINTF_DEBUG(("sprintf: appending \"%s\", pos=\n", add, *pos)); + PRINTF_DEBUG(("sprintf: appending \"%s\", pos=%zu\n", add, *pos)); memcpy(ZSTR_VAL(*buffer) + (*pos), add, len); *pos += len; } @@ -93,7 +93,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, copy_len = (expprec ? MIN(max_width, len) : len); npad = (min_width < copy_len) ? 0 : min_width - copy_len; - PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n", + PRINTF_DEBUG(("sprintf: appendstring(%p, %zu, %zu, \"%s\", %zu, '%c', %zu)\n", *buffer, *pos, ZSTR_LEN(*buffer), add, min_width, padding, alignment)); m_width = MAX(min_width, copy_len); @@ -111,7 +111,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, } size <<= 1; } - PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", size)); + PRINTF_DEBUG(("sprintf ereallocing buffer to %zu bytes\n", size)); *buffer = zend_string_extend(*buffer, size, 0); } if (alignment == ALIGN_RIGHT) { @@ -146,8 +146,8 @@ php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number, zend_ulong magn, nmagn; unsigned int i = NUM_BUF_SIZE - 1, neg = 0; - PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n", - *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment)); + PRINTF_DEBUG(("sprintf: appendint(%p, %zu, %zu, " ZEND_LONG_FMT ", %zu, '%c', %zu)\n", + *buffer, *pos, ZSTR_LEN(*buffer), number, width, padding, alignment)); if (number < 0) { neg = 1; magn = ((zend_ulong) -(number + 1)) + 1; @@ -172,7 +172,7 @@ php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number, } else if (always_sign) { numbuf[--i] = '+'; } - PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", + PRINTF_DEBUG(("sprintf: appending " ZEND_LONG_FMT " as \"%s\", i=%u\n", number, &numbuf[i], i)); php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0, padding, alignment, (NUM_BUF_SIZE - 1) - i, @@ -190,8 +190,8 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos, zend_ulong magn, nmagn; unsigned int i = NUM_BUF_SIZE - 1; - PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n", - *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment)); + PRINTF_DEBUG(("sprintf: appenduint(%p, %zu, %zu, " ZEND_LONG_FMT ", %zu, '%c', %zu)\n", + *buffer, *pos, ZSTR_LEN(*buffer), number, width, padding, alignment)); magn = (zend_ulong) number; /* Can't right-pad 0's on integers */ @@ -206,7 +206,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos, magn = nmagn; } while (magn > 0 && i > 0); - PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i)); + PRINTF_DEBUG(("sprintf: appending " ZEND_LONG_FMT " as \"%s\", i=%d\n", number, &numbuf[i], i)); php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0, padding, alignment, (NUM_BUF_SIZE - 1) - i, /* neg */ false, 0, 0); } @@ -232,8 +232,8 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos, struct lconv *lconv; #endif - PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", - *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, fmt)); + PRINTF_DEBUG(("sprintf: appenddouble(%p, %zu, %zu, %f, %zu, '%c', %zu, %c)\n", + *buffer, *pos, ZSTR_LEN(*buffer), number, width, padding, alignment, fmt)); if ((adjust & ADJ_PRECISION) == 0) { precision = FLOAT_PRECISION; } else if (precision > MAX_FLOAT_PRECISION) { @@ -330,8 +330,8 @@ php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number, zend_ulong i = NUM_BUF_SIZE - 1; int andbits = (1 << n) - 1; - PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n", - *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, n, + PRINTF_DEBUG(("sprintf: append2n(%p, %zu, %zu, " ZEND_LONG_FMT ", %zu, '%c', %zu, %d, %p)\n", + *buffer, *pos, ZSTR_LEN(*buffer), number, width, padding, alignment, n, chartable)); PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits)); @@ -363,7 +363,7 @@ php_sprintf_getnumber(char **buffer, size_t *len) *len -= i; *buffer = endptr; } - PRINTF_DEBUG(("sprintf_getnumber: number was %d bytes long\n", i)); + PRINTF_DEBUG(("sprintf_getnumber: number was %zu bytes long\n", i)); if (num >= INT_MAX || num < 0) { return -1; @@ -431,6 +431,10 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n int always_sign; int max_missing_argnum = -1; + /* For debugging */ + const char *format_orig = format; + ZEND_IGNORE_VALUE(format_orig); + result = zend_string_alloc(size, 0); currarg = 0; @@ -464,8 +468,8 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n always_sign = 0; expprec = 0; - PRINTF_DEBUG(("sprintf: first looking at '%c', inpos=%d\n", - *format, format - Z_STRVAL_P(z_format))); + PRINTF_DEBUG(("sprintf: first looking at '%c', inpos=%zu\n", + *format, format - format_orig)); if (isalpha((int)*format)) { width = precision = 0; argnum = ARG_NUM_NEXT; @@ -478,8 +482,8 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n /* after argnum comes modifiers */ PRINTF_DEBUG(("sprintf: looking for modifiers\n" - "sprintf: now looking at '%c', inpos=%d\n", - *format, format - Z_STRVAL_P(z_format))); + "sprintf: now looking at '%c', inpos=%zu\n", + *format, format - format_orig)); for (;; format++, format_len--) { if (*format == ' ' || *format == '0') { padding = *format; From 799ec7b8c50440f851d823d5c4b68f430234149b Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:29:19 +0200 Subject: [PATCH 39/62] Fix misleading errors in printf() The precision and width _can_ be zero. Closes GH-18911. --- NEWS | 3 +++ ext/standard/formatted_print.c | 6 +++--- ext/standard/tests/strings/sprintf_star.phpt | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index fd344ee94c72e..1010209696243 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ PHP NEWS - MbString: . Fixed bug GH-18901 (integer overflow mb_split). (nielsdos) +- Standard: + . Fix misleading errors in printf(). (nielsdos) + - Streams: . Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter fatal error). (Jakub Zelenka) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 00445d3cca7c7..1ff0f36212bbf 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -534,7 +534,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n goto fail; } if (Z_LVAL_P(tmp) < 0 || Z_LVAL_P(tmp) > INT_MAX) { - zend_value_error("Width must be greater than zero and less than %d", INT_MAX); + zend_value_error("Width must be between 0 and %d", INT_MAX); goto fail; } width = Z_LVAL_P(tmp); @@ -542,7 +542,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n } else if (isdigit((int)*format)) { PRINTF_DEBUG(("sprintf: getting width\n")); if ((width = php_sprintf_getnumber(&format, &format_len)) < 0) { - zend_value_error("Width must be greater than zero and less than %d", INT_MAX); + zend_value_error("Width must be between 0 and %d", INT_MAX); goto fail; } adjusting |= ADJ_WIDTH; @@ -586,7 +586,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n expprec = 1; } else if (isdigit((int)*format)) { if ((precision = php_sprintf_getnumber(&format, &format_len)) < 0) { - zend_value_error("Precision must be greater than zero and less than %d", INT_MAX); + zend_value_error("Precision must be between 0 and %d", INT_MAX); goto fail; } adjusting |= ADJ_PRECISION; diff --git a/ext/standard/tests/strings/sprintf_star.phpt b/ext/standard/tests/strings/sprintf_star.phpt index 0e3e16c326420..0c8a211e5c437 100644 --- a/ext/standard/tests/strings/sprintf_star.phpt +++ b/ext/standard/tests/strings/sprintf_star.phpt @@ -62,6 +62,18 @@ try { echo $e->getMessage(), "\n"; } +try { + printf("%9999999999999999999999.f\n", $f); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} + +try { + printf("%.9999999999999999999999f\n", $f); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} + ?> --EXPECT-- float(1.2345678901234567) @@ -95,4 +107,6 @@ foo Precision must be an integer Precision must be between -1 and 2147483647 Precision -1 is only supported for %g, %G, %h and %H -Width must be greater than zero and less than 2147483647 +Width must be between 0 and 2147483647 +Width must be between 0 and 2147483647 +Precision must be between 0 and 2147483647 From 8e731ca622bfc2cf26375c950fdd58ccae2f999f Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 20:18:55 +0200 Subject: [PATCH 40/62] Fix GH-18639: Internal class aliases can break preloading + JIT ZEND_FUNC_INFO() can not be used on internal CE's. If preloading makes a CE that's an alias of an internal class, the invalid access happens when setting the FUNC_INFO. While we could check the class type to be of user code, we can just skip aliases altogether anyway which may be faster. Closes GH-18915. --- NEWS | 4 ++++ ext/opcache/jit/zend_jit.c | 10 +++++++++- ext/opcache/tests/gh18639.phpt | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/gh18639.phpt diff --git a/NEWS b/NEWS index 1010209696243..b453445854f95 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS - MbString: . Fixed bug GH-18901 (integer overflow mb_split). (nielsdos) +- Opcache: + . Fixed bug GH-18639 (Internal class aliases can break preloading + JIT). + (nielsdos) + - Standard: . Fix misleading errors in printf(). (nielsdos) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 9adfe1719f626..7caa3387016e7 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -4628,8 +4628,16 @@ ZEND_EXT_API int zend_jit_script(zend_script *script) || JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { zend_class_entry *ce; zend_op_array *op_array; + zval *zv; + + ZEND_HASH_MAP_FOREACH_VAL(&script->class_table, zv) { + if (Z_TYPE_P(zv) == IS_ALIAS_PTR) { + continue; + } + + ce = Z_PTR_P(zv); + ZEND_ASSERT(ce->type == ZEND_USER_CLASS); - ZEND_HASH_MAP_FOREACH_PTR(&script->class_table, ce) { ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) { if (!ZEND_FUNC_INFO(op_array)) { void *jit_extension = zend_shared_alloc_get_xlat_entry(op_array->opcodes); diff --git a/ext/opcache/tests/gh18639.phpt b/ext/opcache/tests/gh18639.phpt new file mode 100644 index 0000000000000..28424032931ab --- /dev/null +++ b/ext/opcache/tests/gh18639.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-18639 (Internal class aliases can break preloading + JIT) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1255 +opcache.jit_buffer_size=16M +opcache.preload={PWD}/preload_gh18567.inc +--EXTENSIONS-- +opcache +--SKIPIF-- + +--FILE-- + +--EXPECT-- +ok From 56c4ddfaf62ff3935029847bb6fb44768f4b9452 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 09:43:08 +0200 Subject: [PATCH 41/62] Fix GH-18899: JIT function crash when emitting undefined variable warning and opline is not set yet The crash happens because EX(opline) is attempted to be accessed but it's not set yet. Closes GH-18904. --- NEWS | 2 ++ ext/opcache/jit/zend_jit_ir.c | 2 ++ ext/opcache/tests/jit/gh18899.phpt | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 ext/opcache/tests/jit/gh18899.phpt diff --git a/NEWS b/NEWS index 2e969e0830f41..f71edaedb61c0 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ PHP NEWS - Opcache: . Fixed bug GH-18639 (Internal class aliases can break preloading + JIT). (nielsdos) + . Fixed bug GH-18899 (JIT function crash when emitting undefined variable + warning and opline is not set yet). (nielsdos) - Standard: . Fix misleading errors in printf(). (nielsdos) diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 74fad38ffee87..6afd768321cb3 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -5981,6 +5981,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, ir_IF_FALSE_cold(if_def); // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var))); + jit_SET_EX_OPLINE(jit, opline); ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var)); ref2 = jit_EG(uninitialized_zval); @@ -5997,6 +5998,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, ir_IF_FALSE_cold(if_def); // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var))); + jit_SET_EX_OPLINE(jit, opline); ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op2.var)); ref2 = jit_EG(uninitialized_zval); diff --git a/ext/opcache/tests/jit/gh18899.phpt b/ext/opcache/tests/jit/gh18899.phpt new file mode 100644 index 0000000000000..47c9a3e1ae379 --- /dev/null +++ b/ext/opcache/tests/jit/gh18899.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-18899 (JIT function crash when emitting undefined variable warning and opline is not set yet) +--EXTENSIONS-- +opcache +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1205 +opcache.jit_buffer_size=8M +--FILE-- +>= 8; + } +} +str_repeat("A",232).ptr2str(); +?> +--EXPECTF-- +Warning: Undefined variable $ptr in %s on line %d From 591b3249da3f7dbad91685b1dc78efa733d28b85 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 23 Jun 2025 21:44:58 +0200 Subject: [PATCH 42/62] Do not use RTLD_DEEPBIND if dlmopen is available (#18612) DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms where dlmopen with LM_ID_NEWLM is available: this means shared library symbol isolation (if needed) must be enabled on the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM instead of dlopen. RTLD_DEEPBIND is still enabled when the Apache SAPI is in use. Closes GH-10670. --- NEWS | 1 + UPGRADING.INTERNALS | 6 ++++++ Zend/zend_API.c | 7 +++++++ Zend/zend_API.h | 2 ++ Zend/zend_portability.h | 7 ++++++- sapi/apache2handler/sapi_apache2.c | 1 + 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1ce8ce754adc9..65fb408ddaacf 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,7 @@ PHP NEWS . Added the pipe (|>) operator. (crell) . Added support for `final` with constructor property promotion. (DanielEScherzer) + . Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili) - Curl: . Added curl_multi_get_handles(). (timwolla) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 432754528f09a..47482d40d0b8d 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -17,6 +17,12 @@ PHP 8.5 INTERNALS UPGRADE NOTES - Core . PG(arg_separator).input and PG(arg_separator).output are now `zend_string*` instead of `char*`. + . DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms + where dlmopen with LM_ID_NEWLM is available: + this means shared library symbol isolation (if needed) must be enabled on + the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM + instead of dlopen. + RTLD_DEEPBIND is still enabled when the Apache SAPI is in use. - Zend . Added zend_safe_assign_to_variable_noref() function to safely assign diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e0006e7d7275f..d29fe8ae8e3c3 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -40,6 +40,8 @@ /* these variables are true statics/globals, and have to be mutex'ed on every access */ ZEND_API HashTable module_registry; +ZEND_API bool zend_dl_use_deepbind = false; + static zend_module_entry **module_request_startup_handlers; static zend_module_entry **module_request_shutdown_handlers; static zend_module_entry **module_post_deactivate_handlers; @@ -47,6 +49,11 @@ static zend_module_entry **modules_dl_loaded; static zend_class_entry **class_cleanup_handlers; +ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind) +{ + zend_dl_use_deepbind = use_deepbind; +} + ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index a644de8e15134..02ec1b18a6b69 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -343,6 +343,8 @@ typedef struct _zend_fcall_info_cache { ZEND_API int zend_next_free_module(void); BEGIN_EXTERN_C() +ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind); + ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); /* internal function to efficiently copy parameters when executing __call() */ diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 65ce533c753bd..97bd038ecf3d8 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -165,7 +165,12 @@ # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT) # define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT) # elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer) -# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) +# if defined(LM_ID_NEWLM) + ZEND_API extern bool zend_dl_use_deepbind; +# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | (zend_dl_use_deepbind ? RTLD_DEEPBIND : 0)) +# else +# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) +# endif # else # define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL) # endif diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 1d85a92ebf4d8..e87223b055e12 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -466,6 +466,7 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp { void *data = NULL; const char *userdata_key = "apache2hook_post_config"; + zend_set_dl_use_deepbind(true); /* Apache will load, unload and then reload a DSO module. This * prevents us from starting PHP until the second load. */ From 1e3d92f8a95c17d0fb19c11e17a0cd8c13c18309 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 22 Jun 2025 20:28:02 +0200 Subject: [PATCH 43/62] Fix GH-14082: Segmentation fault on unknown address 0x600000000018 in ext/opcache/jit/zend_jit.c During persisting, the JIT may trigger and fill in the call graph. The call graph info is allocated on the arena which will be gone after preloading. To prevent invalid accesses during normal requests, the arena data should be cleared. This has to be done after all scripts have been persisted because shared op arrays between scripts can change the call graph. Closes GH-18916. --- NEWS | 2 + ext/opcache/ZendAccelerator.c | 47 +++++++++++++++++++++++ ext/opcache/tests/jit/gh14082.phpt | 23 +++++++++++ ext/opcache/tests/jit/preload_gh14082.inc | 9 +++++ 4 files changed, 81 insertions(+) create mode 100644 ext/opcache/tests/jit/gh14082.phpt create mode 100644 ext/opcache/tests/jit/preload_gh14082.inc diff --git a/NEWS b/NEWS index b453445854f95..34866abfb21d8 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,8 @@ PHP NEWS - Opcache: . Fixed bug GH-18639 (Internal class aliases can break preloading + JIT). (nielsdos) + . Fixed bug GH-14082 (Segmentation fault on unknown address 0x600000000018 + in ext/opcache/jit/zend_jit.c). (nielsdos) - Standard: . Fix misleading errors in printf(). (nielsdos) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index bd6b323871bcc..1b0101dbfd6cb 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -52,6 +52,8 @@ #ifdef HAVE_JIT # include "jit/zend_jit.h" +# include "Optimizer/zend_func_info.h" +# include "Optimizer/zend_call_graph.h" #endif #ifndef ZEND_WIN32 @@ -4363,6 +4365,39 @@ static void preload_load(void) } } +#if HAVE_JIT +static void zend_accel_clear_call_graph_ptrs(zend_op_array *op_array) +{ + ZEND_ASSERT(ZEND_USER_CODE(op_array->type)); + zend_func_info *info = ZEND_FUNC_INFO(op_array); + if (info) { + info->caller_info = NULL; + info->callee_info = NULL; + } +} + +static void accel_reset_arena_info(zend_persistent_script *script) +{ + zend_op_array *op_array; + zend_class_entry *ce; + + zend_accel_clear_call_graph_ptrs(&script->script.main_op_array); + ZEND_HASH_MAP_FOREACH_PTR(&script->script.function_table, op_array) { + zend_accel_clear_call_graph_ptrs(op_array); + } ZEND_HASH_FOREACH_END(); + ZEND_HASH_MAP_FOREACH_PTR(&script->script.class_table, ce) { + ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) { + if (op_array->scope == ce + && op_array->type == ZEND_USER_FUNCTION + && !(op_array->fn_flags & ZEND_ACC_ABSTRACT) + && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) { + zend_accel_clear_call_graph_ptrs(op_array); + } + } ZEND_HASH_FOREACH_END(); + } ZEND_HASH_FOREACH_END(); +} +#endif + static zend_result accel_preload(const char *config, bool in_child) { zend_file_handle file_handle; @@ -4568,6 +4603,18 @@ static zend_result accel_preload(const char *config, bool in_child) } ZEND_HASH_FOREACH_END(); ZCSG(saved_scripts)[i] = NULL; +#if HAVE_JIT + /* During persisting, the JIT may trigger and fill in the call graph. + * The call graph info is allocated on the arena which will be gone after preloading. + * To prevent invalid accesses during normal requests, the arena data should be cleared. + * This has to be done after all scripts have been persisted because shared op arrays between + * scripts can change the call graph. */ + accel_reset_arena_info(ZCSG(preload_script)); + for (zend_persistent_script **scripts = ZCSG(saved_scripts); *scripts; scripts++) { + accel_reset_arena_info(*scripts); + } +#endif + zend_shared_alloc_save_state(); accel_interned_strings_save_state(); diff --git a/ext/opcache/tests/jit/gh14082.phpt b/ext/opcache/tests/jit/gh14082.phpt new file mode 100644 index 0000000000000..eba67a096b82c --- /dev/null +++ b/ext/opcache/tests/jit/gh14082.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-14082 (Segmentation fault on unknown address 0x600000000018 in ext/opcache/jit/zend_jit.c) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1235 +opcache.jit_buffer_size=16M +opcache.preload={PWD}/preload_gh14082.inc +--EXTENSIONS-- +opcache +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(1) +int(1) +ok diff --git a/ext/opcache/tests/jit/preload_gh14082.inc b/ext/opcache/tests/jit/preload_gh14082.inc new file mode 100644 index 0000000000000..f5b11ac621ebe --- /dev/null +++ b/ext/opcache/tests/jit/preload_gh14082.inc @@ -0,0 +1,9 @@ + Date: Mon, 23 Jun 2025 23:43:52 +0200 Subject: [PATCH 44/62] Autotools: Remove obsole Autoconf macros (#18914) These Autoconf macros have been marked as obsolete in PHP-8.4 and now also removed: - PHP_AP_EXTRACT_VERSION - PHP_BUILD_THREAD_SAFE - PHP_DEF_HAVE - PHP_OUTPUT - PHP_TEST_BUILD --- UPGRADING.INTERNALS | 8 ++++- build/php.m4 | 71 --------------------------------------------- 2 files changed, 7 insertions(+), 72 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 47482d40d0b8d..f421242dba6c6 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -55,12 +55,18 @@ PHP 8.5 INTERNALS UPGRADE NOTES without duplicate build rules. It is up to the SAPI maintainers to ensure that appropriate build rules are created. -- Linux build system changes +- Unix build system changes . libdir is properly set when --libdir (ex: /usr/lib64) and --with-libdir (ex lib64) configure options are used to ${libdir}/php (ex: /usr/lib64/php) . PHP_ODBC_CFLAGS, PHP_ODBC_LFLAGS, PHP_ODBC_LIBS, PHP_ODBC_TYPE preprocessor macros defined by ext/odbc are now defined in php_config.h instead of the build-defs.h header. + . Autoconf macro PHP_AP_EXTRACT_VERSION has been removed. + . Autoconf macro PHP_BUILD_THREAD_SAFE has been removed (set enable_zts + manually). + . Autoconf macro PHP_DEF_HAVE has been removed (use AC_DEFINE). + . Autoconf macro PHP_OUTPUT has been removed (use AC_CONFIG_FILES). + . Autoconf macro PHP_TEST_BUILD has been removed (use AC_* macros). ======================== 3. Module changes diff --git a/build/php.m4 b/build/php.m4 index aa49766fedd7f..8cdf318083fbb 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -26,15 +26,6 @@ dnl ---------------------------------------------------------------------------- dnl Build system helper macros. dnl ---------------------------------------------------------------------------- -dnl -dnl PHP_DEF_HAVE(what) -dnl -dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'. -dnl -AC_DEFUN([PHP_DEF_HAVE], [m4_warn([obsolete], - [The macro 'PHP_DEF_HAVE' is obsolete. Use AC_DEFINE.]) -AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])]) - dnl dnl PHP_RUN_ONCE(namespace, variable, code) dnl @@ -89,17 +80,6 @@ AC_DEFUN([PHP_SUBST_OLD],[ PHP_SUBST([$1]) ]) -dnl -dnl PHP_OUTPUT(file) -dnl -dnl Adds "file" to the list of files generated by AC_OUTPUT. This macro can be -dnl used several times. This macro is obsolete as of PHP 8.4 in favor of the -dnl default AC_CONFIG_FILES. -dnl -AC_DEFUN([PHP_OUTPUT], -[m4_warn([obsolete], [The macro 'PHP_OUTPUT' is obsolete. Use AC_CONFIG_FILES.]) -AC_CONFIG_FILES([$1])]) - dnl ---------------------------------------------------------------------------- dnl Build system base macros. dnl ---------------------------------------------------------------------------- @@ -743,13 +723,6 @@ dnl ---------------------------------------------------------------------------- dnl Build macros dnl ---------------------------------------------------------------------------- -dnl -dnl PHP_BUILD_THREAD_SAFE -dnl -AC_DEFUN([PHP_BUILD_THREAD_SAFE], [m4_warn([obsolete], - [The macro 'PHP_BUILD_THREAD_SAFE' is obsolete. Set 'enable_zts' manually.]) - enable_zts=yes]) - dnl dnl PHP_REQUIRE_CXX dnl @@ -1518,31 +1491,6 @@ AC_DEFUN([PHP_CHECK_FUNC],[ esac ]) -dnl -dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]]) -dnl -dnl This macro checks whether build works and given function exists. -dnl -AC_DEFUN([PHP_TEST_BUILD], [m4_warn([obsolete], - [The macro 'PHP_TEST_BUILD' is obsolete. Use AC_* macros.]) - old_LIBS=$LIBS - LIBS="$4 $LIBS" - AC_LINK_IFELSE([AC_LANG_SOURCE([ - $5 - char $1(void); - int main(void) { - $1(); - return 0; - } - ])],[ - LIBS=$old_LIBS - $2 - ],[ - LIBS=$old_LIBS - $3 - ]) -]) - dnl ---------------------------------------------------------------------------- dnl Platform characteristics checks. dnl ---------------------------------------------------------------------------- @@ -2039,25 +1987,6 @@ AC_DEFUN([PHP_INSTALL_HEADERS], ]) ]) -dnl -dnl PHP_AP_EXTRACT_VERSION(/path/httpd) -dnl -dnl This macro is used to get a comparable version for Apache. -dnl -AC_DEFUN([PHP_AP_EXTRACT_VERSION], [m4_warn([obsolete], - [The macro 'PHP_AP_EXTRACT_VERSION' is obsolete. Use 'apxs -q HTTPD_VERSION']) -AS_IF([test -x "$1"], [ - ac_output=$($1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//') - ac_IFS=$IFS -IFS="- /. -" - set $ac_output - IFS=$ac_IFS - - APACHE_VERSION=$(expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6) -]) -]) - dnl dnl PHP_CONFIG_NICE(filename) dnl From ecc602e3bb5878228cf6b85de790f3f097bbb0fd Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Mon, 23 Jun 2025 23:44:20 +0200 Subject: [PATCH 45/62] Remove non-existing INI directive detect_unicode (#18909) The detect_unicode was removed and zend.detect_unicode was added in PHP 5.4 (bbf3d43c1ee0ad53b03c3821cd630f0746d5e954). --- ext/phar/tests/zip/notphar.phpt | 1 - pear/Makefile.frag | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/phar/tests/zip/notphar.phpt b/ext/phar/tests/zip/notphar.phpt index 10d4d7d8be311..ab4f80e430bba 100644 --- a/ext/phar/tests/zip/notphar.phpt +++ b/ext/phar/tests/zip/notphar.phpt @@ -4,7 +4,6 @@ Phar: a non-executable zip with no stub named .phar.zip phar --INI-- phar.readonly=1 -detect_unicode=0 zend.multibyte=0 --FILE-- /dev/null` FETCH = `which fetch 2>/dev/null` From d6fc7430b95af036386d9910a763708725a1b9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 24 Jun 2025 08:50:47 +0200 Subject: [PATCH 46/62] zend_string: Simplify logic in `zend_interned_strings_init()` (#18922) No need to manually init a `zend_string` to then intern it, we can directly intern it while initializing, bypassing some of the safety checks that are redundant in this case. --- Zend/zend_string.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Zend/zend_string.c b/Zend/zend_string.c index dfe059359aa53..c864a847af39f 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -86,8 +86,6 @@ static zend_always_inline void zend_init_interned_strings_ht(HashTable *interned ZEND_API void zend_interned_strings_init(void) { char s[2]; - unsigned int i; - zend_string *str; interned_string_request_handler = zend_new_interned_string_request; interned_string_init_request_handler = zend_string_init_interned_request; @@ -103,15 +101,13 @@ ZEND_API void zend_interned_strings_init(void) zend_string_init_existing_interned = zend_string_init_existing_interned_permanent; /* interned empty string */ - str = zend_string_alloc(sizeof("")-1, 1); - ZSTR_VAL(str)[0] = '\000'; - zend_empty_string = zend_new_interned_string_permanent(str); + zend_empty_string = zend_string_init_interned_permanent("", 0, true); GC_ADD_FLAGS(zend_empty_string, IS_STR_VALID_UTF8); s[1] = 0; - for (i = 0; i < 256; i++) { + for (size_t i = 0; i < 256; i++) { s[0] = i; - zend_one_char_string[i] = zend_new_interned_string_permanent(zend_string_init(s, 1, 1)); + zend_one_char_string[i] = zend_string_init_interned_permanent(s, 1, true); if (i < 0x80) { GC_ADD_FLAGS(zend_one_char_string[i], IS_STR_VALID_UTF8); } @@ -119,9 +115,8 @@ ZEND_API void zend_interned_strings_init(void) /* known strings */ zend_known_strings = pemalloc(sizeof(zend_string*) * ((sizeof(known_strings) / sizeof(known_strings[0]) - 1)), 1); - for (i = 0; i < (sizeof(known_strings) / sizeof(known_strings[0])) - 1; i++) { - str = zend_string_init(known_strings[i], strlen(known_strings[i]), 1); - zend_known_strings[i] = zend_new_interned_string_permanent(str); + for (size_t i = 0; i < (sizeof(known_strings) / sizeof(known_strings[0])) - 1; i++) { + zend_known_strings[i] = zend_string_init_interned_permanent(known_strings[i], strlen(known_strings[i]), true); GC_ADD_FLAGS(zend_known_strings[i], IS_STR_VALID_UTF8); } } From c5e7490963a1c53ec12c09264d0dbe1654ec8cfc Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Tue, 3 Jun 2025 10:03:10 -0500 Subject: [PATCH 47/62] mail: fix exit code handling of sendmail cmd Prior to this commit the return code of the pclose function was assumed to be the exit code of the process. However, the returned value as specified in wait(2) is a bit packed integer and must be interpreted with the provided macros. This has no effect in success cases as the integer is still zero, but in failure cases the wrong value is used, since the 8 least significant bits contain the status code. After this commit we use the macros to obtain the status code, which fixes the EX_TEMPFAIL conditional. For WIN32 the TSRM popen_ex and pclose function are used. The return value of TSRM's pclose is not bit packed so we only check if the return value is non-zero, which should solve, #43327, https://bugs.php.net/bug.php?id=43327 --- ext/standard/mail.c | 32 +++++++++++++++++--- ext/standard/tests/mail/mail_variation3.phpt | 22 ++++++++++++++ ext/standard/tests/mail/mail_variation4.phpt | 22 ++++++++++++++ ext/standard/tests/mail/mail_variation5.phpt | 22 ++++++++++++++ 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 ext/standard/tests/mail/mail_variation3.phpt create mode 100644 ext/standard/tests/mail/mail_variation4.phpt create mode 100644 ext/standard/tests/mail/mail_variation5.phpt diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 0243ec897a05e..ff0ec13500946 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -25,6 +25,10 @@ #include "ext/date/php_date.h" #include "zend_smart_str.h" +#ifdef HAVE_SYS_WAIT_H +#include +#endif + #ifdef HAVE_SYSEXITS_H # include #endif @@ -562,6 +566,7 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c } if (sendmail) { + int ret; #ifndef PHP_WIN32 if (EACCES == errno) { php_error_docref(NULL, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path); @@ -582,24 +587,41 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c fprintf(sendmail, "%s%s", hdr, line_sep); } fprintf(sendmail, "%s%s%s", line_sep, message, line_sep); - int ret = pclose(sendmail); +#ifdef PHP_WIN32 + ret = pclose(sendmail); #if PHP_SIGCHILD if (sig_handler) { signal(SIGCHLD, sig_handler); } #endif - -#ifdef PHP_WIN32 - if (ret == -1) #else + int wstatus = pclose(sendmail); +#if PHP_SIGCHILD + if (sig_handler) { + signal(SIGCHLD, sig_handler); + } +#endif + /* Determine the wait(2) exit status */ + if (wstatus == -1) { + MAIL_RET(false); + } else if (WIFSIGNALED(wstatus)) { + MAIL_RET(false); + } else { + if (WIFEXITED(wstatus)) { + ret = WEXITSTATUS(wstatus); + } else { + MAIL_RET(false); + } + } +#endif + #if defined(EX_TEMPFAIL) if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) #elif defined(EX_OK) if (ret != EX_OK) #else if (ret != 0) -#endif #endif { MAIL_RET(false); diff --git a/ext/standard/tests/mail/mail_variation3.phpt b/ext/standard/tests/mail/mail_variation3.phpt new file mode 100644 index 0000000000000..03908242d88e9 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test mail() function : variation sendmail temp fail +--INI-- +sendmail_path=exit 75 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +*** Testing mail() : variation *** +bool(true) diff --git a/ext/standard/tests/mail/mail_variation4.phpt b/ext/standard/tests/mail/mail_variation4.phpt new file mode 100644 index 0000000000000..8b3b301ac0be4 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation4.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test mail() function : variation sigterm +--INI-- +sendmail_path="kill \$\$" +--SKIPIF-- + +--FILE-- + +--EXPECT-- +*** Testing mail() : variation *** +bool(false) diff --git a/ext/standard/tests/mail/mail_variation5.phpt b/ext/standard/tests/mail/mail_variation5.phpt new file mode 100644 index 0000000000000..a6c25feba5e1d --- /dev/null +++ b/ext/standard/tests/mail/mail_variation5.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test mail() function : variation non-zero exit +--INI-- +sendmail_path="exit 123" +--SKIPIF-- + +--FILE-- + +--EXPECT-- +*** Testing mail() : variation *** +bool(false) From 6a7561203de89031147c0de6fe09cad905f82984 Mon Sep 17 00:00:00 2001 From: Jesse Hathaway Date: Tue, 3 Jun 2025 10:03:10 -0500 Subject: [PATCH 48/62] mail: add logging on errors Prior to this commit the exit code of the sendmail command, called by the mail function was lost, since the mail function only returns true or false. Add additional logging to the mail function to capture the exit code when the sendmail command fails. --- ext/standard/mail.c | 4 ++++ ext/standard/tests/mail/gh10990.phpt | 3 ++- ext/standard/tests/mail/mail_basic5.phpt | 4 +++- ext/standard/tests/mail/mail_variation1.phpt | 4 +++- ext/standard/tests/mail/mail_variation4.phpt | 4 +++- ext/standard/tests/mail/mail_variation5.phpt | 4 +++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ext/standard/mail.c b/ext/standard/mail.c index ff0ec13500946..41e2a02078e78 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -604,13 +604,16 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c #endif /* Determine the wait(2) exit status */ if (wstatus == -1) { + php_error_docref(NULL, E_WARNING, "Sendmail pclose failed %d (%s)", errno, strerror(errno)); MAIL_RET(false); } else if (WIFSIGNALED(wstatus)) { + php_error_docref(NULL, E_WARNING, "Sendmail killed by signal %d (%s)", WTERMSIG(wstatus), strsignal(WTERMSIG(wstatus))); MAIL_RET(false); } else { if (WIFEXITED(wstatus)) { ret = WEXITSTATUS(wstatus); } else { + php_error_docref(NULL, E_WARNING, "Sendmail did not exit"); MAIL_RET(false); } } @@ -624,6 +627,7 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c if (ret != 0) #endif { + php_error_docref(NULL, E_WARNING, "Sendmail exited with non-zero exit code %d", ret); MAIL_RET(false); } else { MAIL_RET(true); diff --git a/ext/standard/tests/mail/gh10990.phpt b/ext/standard/tests/mail/gh10990.phpt index 4f74c17c22bda..ee28f30313858 100644 --- a/ext/standard/tests/mail/gh10990.phpt +++ b/ext/standard/tests/mail/gh10990.phpt @@ -13,5 +13,6 @@ $from = 'test@example.com'; $headers = ['From' => &$from]; var_dump(mail('test@example.com', 'Test', 'Test', $headers)); ?> ---EXPECT-- +--EXPECTF-- +Warning: mail(): Sendmail exited with non-zero exit code 127 in %sgh10990.php on line %d bool(false) diff --git a/ext/standard/tests/mail/mail_basic5.phpt b/ext/standard/tests/mail/mail_basic5.phpt index b427fbeb670a0..73be1e1eaa1ad 100644 --- a/ext/standard/tests/mail/mail_basic5.phpt +++ b/ext/standard/tests/mail/mail_basic5.phpt @@ -20,7 +20,9 @@ $message = 'A Message'; echo "-- failure --\n"; var_dump( mail($to, $subject, $message) ); ?> ---EXPECT-- +--EXPECTF-- *** Testing mail() : basic functionality *** -- failure -- + +Warning: mail(): Sendmail exited with non-zero exit code 1 in %smail_basic5.php on line %d bool(false) diff --git a/ext/standard/tests/mail/mail_variation1.phpt b/ext/standard/tests/mail/mail_variation1.phpt index 75adc62822358..16779bcf455ee 100644 --- a/ext/standard/tests/mail/mail_variation1.phpt +++ b/ext/standard/tests/mail/mail_variation1.phpt @@ -17,6 +17,8 @@ $subject = 'Test Subject'; $message = 'A Message'; var_dump( mail($to, $subject, $message) ); ?> ---EXPECT-- +--EXPECTF-- *** Testing mail() : variation *** + +Warning: mail(): Sendmail exited with non-zero exit code 127 in %smail_variation1.php on line %d bool(false) diff --git a/ext/standard/tests/mail/mail_variation4.phpt b/ext/standard/tests/mail/mail_variation4.phpt index 8b3b301ac0be4..c761e3bdbd199 100644 --- a/ext/standard/tests/mail/mail_variation4.phpt +++ b/ext/standard/tests/mail/mail_variation4.phpt @@ -17,6 +17,8 @@ $subject = 'Test Subject'; $message = 'A Message'; var_dump(mail($to, $subject, $message)); ?> ---EXPECT-- +--EXPECTF-- *** Testing mail() : variation *** + +Warning: mail(): Sendmail killed by signal %d (%s) in %smail_variation4.php on line %d bool(false) diff --git a/ext/standard/tests/mail/mail_variation5.phpt b/ext/standard/tests/mail/mail_variation5.phpt index a6c25feba5e1d..9e430f40c5dfc 100644 --- a/ext/standard/tests/mail/mail_variation5.phpt +++ b/ext/standard/tests/mail/mail_variation5.phpt @@ -17,6 +17,8 @@ $subject = 'Test Subject'; $message = 'A Message'; var_dump(mail($to, $subject, $message)); ?> ---EXPECT-- +--EXPECTF-- *** Testing mail() : variation *** + +Warning: mail(): Sendmail exited with non-zero exit code 123 in %smail_variation5.php on line %d bool(false) From fc04966c364be62a818e0c7e495ba0bc2d5bfc97 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Tue, 24 Jun 2025 12:30:35 +0200 Subject: [PATCH 49/62] Add NEWS and UPGRADING for sendmail error handling changes --- NEWS | 2 ++ UPGRADING | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 65fb408ddaacf..b3ac9d6b405bf 100644 --- a/NEWS +++ b/NEWS @@ -261,6 +261,8 @@ PHP NEWS . Added array_first() and array_last(). (nielsdos) . Fixed bug GH-18823 (setlocale's 2nd and 3rd argument ignores strict_types). (nielsdos) + . Fixed exit code handling of sendmail cmd and added warnings. + (Jesse Hathaway) - Streams: . Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows). diff --git a/UPGRADING b/UPGRADING index 4c6e40cfdebaf..1462be95a43fc 100644 --- a/UPGRADING +++ b/UPGRADING @@ -217,6 +217,12 @@ PHP 8.5 UPGRADE NOTES Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN and Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN. +- Standard: + . mail() now returns the actual sendmail error and detects if the sendmail + process was terminated unexpectedly. In such cases, a warning is emitted + and the function returns false. Previously, these errors were silently + ignored. This change affects only the sendmail transport. + - XSL: . The $namespace argument of XSLTProcessor::getParameter(), XSLTProcessor::setParameter() and XSLTProcessor::removeParameter() From 537ae4f990d35ff6d54d7af31b1d2cfa064c021c Mon Sep 17 00:00:00 2001 From: Saki Takamachi <34942839+SakiTakamachi@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:40:09 +0900 Subject: [PATCH 50/62] removed `ZEND_IS_XDIGIT()` (#18926) --- UPGRADING.INTERNALS | 2 ++ Zend/zend_operators.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index f421242dba6c6..acc9612b72e30 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -43,6 +43,8 @@ PHP 8.5 INTERNALS UPGRADE NOTES . Added the zend_update_exception_properties() function for instantiating Exception child classes. It updates the $message, $code, and $previous properties. + . ZEND_IS_XDIGIT() macro was removed because it was unused and its name + did not match its actual behavior. ======================== 2. Build system changes diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index db86345b69968..a7537d1b3ef33 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -156,7 +156,6 @@ static zend_always_inline zend_long zend_dval_to_lval_safe(double d) } #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') -#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) static zend_always_inline uint8_t is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors, int *oflow_info, bool *trailing_data) From 39cf27689bc13cf94c047675901c3fb43ba44879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 24 Jun 2025 15:22:25 +0200 Subject: [PATCH 51/62] php_gdb: Print some numeric fields as hexadecimal (#18925) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * php_gdb: Print `zend_string*`’s `h` field as hexadecimal A decimal representation of a hash value is not particularly meaningful and makes it harder to compare hash values. * php_gdb: Print `HashTable*`’s `nTableMask` field as hexadecimal --- main/debug_gdb_scripts.c | 11 ++++++----- scripts/gdb/php_gdb.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/main/debug_gdb_scripts.c b/main/debug_gdb_scripts.c index 3806f6aab60dd..e3c522bc04843 100644 --- a/main/debug_gdb_scripts.c +++ b/main/debug_gdb_scripts.c @@ -719,6 +719,8 @@ asm( ".ascii \" for field in self.val.type.fields():\\n\"\n" ".ascii \" if field.name == 'val':\\n\"\n" ".ascii \" yield ('val', format_zstr(self.val))\\n\"\n" + ".ascii \" elif field.name == 'h':\\n\"\n" + ".ascii \" yield (field.name, \\\"0x%x\\\" % self.val[field.name])\\n\"\n" ".ascii \" else:\\n\"\n" ".ascii \" yield (field.name, format_nested(self.val[field.name]))\\n\"\n" ".ascii \"\\n\"\n" @@ -751,12 +753,11 @@ asm( ".ascii \" def children(self):\\n\"\n" ".ascii \" for field in self.val.type.fields():\\n\"\n" ".ascii \" if field.name is None:\\n\"\n" - ".ascii \" name = ''\\n\"\n" - ".ascii \" val = self.val[field]\\n\"\n" + ".ascii \" yield ('', format_nested(self.val[field]))\\n\"\n" + ".ascii \" elif field.name == 'nTableMask':\\n\"\n" + ".ascii \" yield (field.name, \\\"0x%x\\\" % self.val[field.name])\\n\"\n" ".ascii \" else:\\n\"\n" - ".ascii \" name = field.name\\n\"\n" - ".ascii \" val = self.val[field.name]\\n\"\n" - ".ascii \" yield (name, format_nested(val))\\n\"\n" + ".ascii \" yield (field.name, format_nested(self.val[field.name]))\\n\"\n" ".ascii \"\\n\"\n" ".ascii \"pp_set.add_printer('zend_array', '^_zend_array$', ZendArrayPrettyPrinter)\\n\"\n" ".ascii \"\\n\"\n" diff --git a/scripts/gdb/php_gdb.py b/scripts/gdb/php_gdb.py index ae8396a2ac0c2..1c5da0154aecd 100644 --- a/scripts/gdb/php_gdb.py +++ b/scripts/gdb/php_gdb.py @@ -49,6 +49,8 @@ def children(self): for field in self.val.type.fields(): if field.name == 'val': yield ('val', format_zstr(self.val)) + elif field.name == 'h': + yield (field.name, "0x%x" % self.val[field.name]) else: yield (field.name, format_nested(self.val[field.name])) @@ -81,12 +83,11 @@ def to_string(self): def children(self): for field in self.val.type.fields(): if field.name is None: - name = '' - val = self.val[field] + yield ('', format_nested(self.val[field])) + elif field.name == 'nTableMask': + yield (field.name, "0x%x" % self.val[field.name]) else: - name = field.name - val = self.val[field.name] - yield (name, format_nested(val)) + yield (field.name, format_nested(self.val[field.name])) pp_set.add_printer('zend_array', '^_zend_array$', ZendArrayPrettyPrinter) From 5ed8b2be5533fbd4db95d9724d268eb9c9741f14 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:06:47 +0200 Subject: [PATCH 52/62] Fix GH-18897: printf: empty precision is interpreted as precision 6, not as precision 0 (#18912) Like in other languages, and especially C where printf originates from, a missing precision should be treated as a 0 precision. Because the ADJ_PRECISION flag was not set, the double formatting code resetted the precision to the default float precision of 6. --- NEWS | 2 ++ UPGRADING | 5 +++++ ext/standard/formatted_print.c | 1 + ext/standard/tests/strings/gh18897.phpt | 10 ++++++++++ 4 files changed, 18 insertions(+) create mode 100644 ext/standard/tests/strings/gh18897.phpt diff --git a/NEWS b/NEWS index b3ac9d6b405bf..8f129d715d873 100644 --- a/NEWS +++ b/NEWS @@ -263,6 +263,8 @@ PHP NEWS (nielsdos) . Fixed exit code handling of sendmail cmd and added warnings. (Jesse Hathaway) + . Fixed bug GH-18897 (printf: empty precision is interpreted as precision 6, + not as precision 0). (nielsdos) - Streams: . Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows). diff --git a/UPGRADING b/UPGRADING index 1462be95a43fc..4dca8f2b2c213 100644 --- a/UPGRADING +++ b/UPGRADING @@ -116,6 +116,11 @@ PHP 8.5 UPGRADE NOTES . SplFileObject::fwrite's parameter $length is now nullable. The default value changed from 0 to null. +- Standard: + . Using a printf-family function with a formatter that did not specify the + precision previously incorrectly reset the precision instead of treating + it as a precision of 0. See GH-18897. + ======================================== 2. New Features ======================================== diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 9a74ae6c877f3..b2c287c02900c 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -591,6 +591,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n expprec = 1; } else { precision = 0; + adjusting |= ADJ_PRECISION; } } else { precision = 0; diff --git a/ext/standard/tests/strings/gh18897.phpt b/ext/standard/tests/strings/gh18897.phpt new file mode 100644 index 0000000000000..328ea7161e023 --- /dev/null +++ b/ext/standard/tests/strings/gh18897.phpt @@ -0,0 +1,10 @@ +--TEST-- +GH-18897 (printf: empty precision is interpreted as precision 6, not as precision 0) +--FILE-- + +--EXPECT-- +3 +3 From ca49a7bec2a0a8d77bfa4b6d375ca0ffa4edc5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 24 Jun 2025 20:14:40 +0200 Subject: [PATCH 53/62] RFC: Turn `clone()` into a function (#18919) RFC: https://wiki.php.net/rfc/clone_with_v2 Co-authored-by: Volker Dusch --- NEWS | 1 + UPGRADING | 2 + Zend/Optimizer/zend_func_infos.h | 1 + Zend/tests/assert/expect_015.phpt | 2 +- Zend/tests/clone/ast.phpt | 31 +++++++++++++++ Zend/tests/clone/bug36071.phpt | 14 +++---- Zend/tests/clone/bug42817.phpt | 14 +++---- Zend/tests/clone/bug42818.phpt | 13 +++--- Zend/tests/clone/clone_001.phpt | 13 +++--- Zend/tests/clone/clone_003.phpt | 12 +++--- Zend/tests/clone/clone_005.phpt | 55 ++++++++++++++++++++++++++ Zend/tests/magic_methods/bug73288.phpt | 1 + Zend/zend_API.c | 1 + Zend/zend_ast.c | 2 - Zend/zend_ast.h | 1 - Zend/zend_builtin_functions.c | 43 ++++++++++++++++++++ Zend/zend_builtin_functions.stub.php | 3 ++ Zend/zend_builtin_functions_arginfo.h | 8 +++- Zend/zend_compile.c | 30 +++++++------- Zend/zend_language_parser.y | 11 +++++- Zend/zend_string.h | 1 + Zend/zend_vm_def.h | 4 +- Zend/zend_vm_execute.h | 16 ++++++-- build/gen_stub.php | 4 ++ ext/opcache/tests/func_info.phpt | 2 +- 25 files changed, 227 insertions(+), 58 deletions(-) create mode 100644 Zend/tests/clone/ast.phpt create mode 100644 Zend/tests/clone/clone_005.phpt diff --git a/NEWS b/NEWS index 8f129d715d873..930dbec180221 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,7 @@ PHP NEWS . Added support for `final` with constructor property promotion. (DanielEScherzer) . Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili) + . Make `clone() a function. (timwolla, edorian) - Curl: . Added curl_multi_get_handles(). (timwolla) diff --git a/UPGRADING b/UPGRADING index 4dca8f2b2c213..98537007f65cd 100644 --- a/UPGRADING +++ b/UPGRADING @@ -374,6 +374,8 @@ PHP 8.5 UPGRADE NOTES . get_exception_handler() allows retrieving the current user-defined exception handler function. RFC: https://wiki.php.net/rfc/get-error-exception-handler + . The clone language construct is now a function. + RFC: https://wiki.php.net/rfc/clone_with_v2 - Curl: . curl_multi_get_handles() allows retrieving all CurlHandles current diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 3655e5fd21c35..c36b7490de62c 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -1,6 +1,7 @@ /* This is a generated file, edit the .stub.php files instead. */ static const func_info_t func_infos[] = { + F1("clone", MAY_BE_OBJECT), F1("zend_version", MAY_BE_STRING), FN("func_get_args", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY), F1("get_class_vars", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), diff --git a/Zend/tests/assert/expect_015.phpt b/Zend/tests/assert/expect_015.phpt index 695c4c166a83c..9f8e9b77003bc 100644 --- a/Zend/tests/assert/expect_015.phpt +++ b/Zend/tests/assert/expect_015.phpt @@ -183,7 +183,7 @@ assert(0 && ($a = function () { $x = $a ?? $b; [$a, $b, $c] = [1, 2 => 'x', 'z' => 'c']; @foo(); - $y = clone $x; + $y = \clone($x); yield 1 => 2; yield from $x; })) diff --git a/Zend/tests/clone/ast.phpt b/Zend/tests/clone/ast.phpt new file mode 100644 index 0000000000000..89a1a0a481000 --- /dev/null +++ b/Zend/tests/clone/ast.phpt @@ -0,0 +1,31 @@ +--TEST-- +Ast Printing +--FILE-- +getMessage(), PHP_EOL; +} + +try { + assert(false && $y = clone($x)); +} catch (Error $e) { + echo $e->getMessage(), PHP_EOL; +} + +try { + assert(false && $y = clone(...)); +} catch (Error $e) { + echo $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +assert(false && ($y = \clone($x))) +assert(false && ($y = \clone($x))) +assert(false && ($y = \clone(...))) diff --git a/Zend/tests/clone/bug36071.phpt b/Zend/tests/clone/bug36071.phpt index 945118fef3754..e1a4baa7226ee 100644 --- a/Zend/tests/clone/bug36071.phpt +++ b/Zend/tests/clone/bug36071.phpt @@ -4,11 +4,11 @@ Bug #36071 (Engine Crash related with 'clone') error_reporting=4095 --FILE-- b = 0; +try { + $a = clone 0; +} catch (Error $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught Error: __clone method called on non-object in %sbug36071.php:2 -Stack trace: -#0 {main} - thrown in %sbug36071.php on line 2 +--EXPECT-- +TypeError: clone(): Argument #1 ($object) must be of type object, int given diff --git a/Zend/tests/clone/bug42817.phpt b/Zend/tests/clone/bug42817.phpt index a681d861d0c8f..b5f53222d7ee5 100644 --- a/Zend/tests/clone/bug42817.phpt +++ b/Zend/tests/clone/bug42817.phpt @@ -2,11 +2,11 @@ Bug #42817 (clone() on a non-object does not result in a fatal error) --FILE-- b, $c); +try { + $a = clone(null); +} catch (Error $e) { + echo $e::class, ": ", $e->getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught Error: __clone method called on non-object in %sbug42817.php:2 -Stack trace: -#0 {main} - thrown in %sbug42817.php on line 2 +--EXPECT-- +TypeError: clone(): Argument #1 ($object) must be of type object, null given diff --git a/Zend/tests/clone/bug42818.phpt b/Zend/tests/clone/bug42818.phpt index b37ce13fd174a..08ba05fcfaa22 100644 --- a/Zend/tests/clone/bug42818.phpt +++ b/Zend/tests/clone/bug42818.phpt @@ -2,10 +2,11 @@ Bug #42818 ($foo = clone(array()); leaks memory) --FILE-- getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught Error: __clone method called on non-object in %sbug42818.php:2 -Stack trace: -#0 {main} - thrown in %sbug42818.php on line 2 +--EXPECT-- +TypeError: clone(): Argument #1 ($object) must be of type object, array given diff --git a/Zend/tests/clone/clone_001.phpt b/Zend/tests/clone/clone_001.phpt index 87024c3cd5614..91fa6f551176d 100644 --- a/Zend/tests/clone/clone_001.phpt +++ b/Zend/tests/clone/clone_001.phpt @@ -3,11 +3,12 @@ Using clone statement on non-object --FILE-- getMessage(), PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught Error: __clone method called on non-object in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d +--EXPECT-- +TypeError: clone(): Argument #1 ($object) must be of type object, array given diff --git a/Zend/tests/clone/clone_003.phpt b/Zend/tests/clone/clone_003.phpt index f163616a876dc..b8bb2833dc257 100644 --- a/Zend/tests/clone/clone_003.phpt +++ b/Zend/tests/clone/clone_003.phpt @@ -3,13 +3,13 @@ Using clone statement on undefined variable --FILE-- getMessage(), PHP_EOL; +} ?> --EXPECTF-- Warning: Undefined variable $b in %s on line %d - -Fatal error: Uncaught Error: __clone method called on non-object in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d +TypeError: clone(): Argument #1 ($object) must be of type object, null given diff --git a/Zend/tests/clone/clone_005.phpt b/Zend/tests/clone/clone_005.phpt new file mode 100644 index 0000000000000..e0366cae67cb5 --- /dev/null +++ b/Zend/tests/clone/clone_005.phpt @@ -0,0 +1,55 @@ +--TEST-- +Clone as a function. +--FILE-- +clone_me()[0]; + +var_dump($f !== $clone); + +?> +--EXPECTF-- +object(stdClass)#%d (0) { +} +array(3) { + [0]=> + object(stdClass)#%d (0) { + } + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + object(stdClass)#%d (0) { + } +} +array(3) { + [0]=> + object(stdClass)#%d (0) { + } + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + object(stdClass)#%d (0) { + } +} +bool(true) diff --git a/Zend/tests/magic_methods/bug73288.phpt b/Zend/tests/magic_methods/bug73288.phpt index 52e8eedeaf013..5e1334cacd07c 100644 --- a/Zend/tests/magic_methods/bug73288.phpt +++ b/Zend/tests/magic_methods/bug73288.phpt @@ -23,6 +23,7 @@ function test_clone() { $b = clone $c->x; } +// No catch, because we want to test Exception::__toString(). test_clone(); ?> --EXPECTF-- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index d29fe8ae8e3c3..df8b4252c42ad 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3648,6 +3648,7 @@ static void zend_disable_function(const char *function_name, size_t function_nam if (UNEXPECTED( (function_name_length == strlen("exit") && !memcmp(function_name, "exit", strlen("exit"))) || (function_name_length == strlen("die") && !memcmp(function_name, "die", strlen("die"))) + || (function_name_length == strlen("clone") && !memcmp(function_name, "clone", strlen("clone"))) )) { zend_error(E_WARNING, "Cannot disable function %s()", function_name); return; diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index cdc86faa95aa3..728695bd9e930 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -2345,8 +2345,6 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio } smart_str_appendc(str, '`'); break; - case ZEND_AST_CLONE: - PREFIX_OP("clone ", 270, 271); case ZEND_AST_PRINT: PREFIX_OP("print ", 60, 61); case ZEND_AST_INCLUDE_OR_EVAL: diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index c82ca66c9f573..08400cff5dd8e 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -89,7 +89,6 @@ enum _zend_ast_kind { ZEND_AST_ISSET, ZEND_AST_SILENCE, ZEND_AST_SHELL_EXEC, - ZEND_AST_CLONE, ZEND_AST_PRINT, ZEND_AST_INCLUDE_OR_EVAL, ZEND_AST_UNARY_OP, diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 7a07ceadce2e2..48e5c70897294 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -69,6 +69,49 @@ zend_result zend_startup_builtin_functions(void) /* {{{ */ } /* }}} */ +ZEND_FUNCTION(clone) +{ + zend_object *zobj; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJ(zobj) + ZEND_PARSE_PARAMETERS_END(); + + /* clone() also exists as the ZEND_CLONE OPcode and both implementations must be kept in sync. */ + + zend_class_entry *scope = zend_get_executed_scope(); + + zend_class_entry *ce = zobj->ce; + zend_function *clone = ce->clone; + + if (UNEXPECTED(zobj->handlers->clone_obj == NULL)) { + zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); + RETURN_THROWS(); + } + + if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { + if (clone->common.scope != scope) { + if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) + || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { + zend_throw_error(NULL, "Call to %s %s::__clone() from %s%s", + zend_visibility_string(clone->common.fn_flags), ZSTR_VAL(clone->common.scope->name), + scope ? "scope " : "global scope", + scope ? ZSTR_VAL(scope->name) : "" + ); + RETURN_THROWS(); + } + } + } + + zend_object *cloned; + cloned = zobj->handlers->clone_obj(zobj); + + ZEND_ASSERT(cloned || EG(exception)); + if (EXPECTED(cloned)) { + RETURN_OBJ(cloned); + } +} + ZEND_FUNCTION(exit) { zend_string *str = NULL; diff --git a/Zend/zend_builtin_functions.stub.php b/Zend/zend_builtin_functions.stub.php index 7f316835aea6b..256c405c71c28 100644 --- a/Zend/zend_builtin_functions.stub.php +++ b/Zend/zend_builtin_functions.stub.php @@ -7,6 +7,9 @@ class stdClass { } +/** @refcount 1 */ +function _clone(object $object): object {} + function exit(string|int $status = 0): never {} /** @alias exit */ diff --git a/Zend/zend_builtin_functions_arginfo.h b/Zend/zend_builtin_functions_arginfo.h index 9498b8292f892..1c595ecd5777c 100644 --- a/Zend/zend_builtin_functions_arginfo.h +++ b/Zend/zend_builtin_functions_arginfo.h @@ -1,5 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a24761186f1ddf758e648b0a764826537cbd33b9 */ + * Stub hash: 12327caa3fe940ccef68ed99f9278982dc0173a5 */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_clone, 0, 1, IS_OBJECT, 0) + ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_exit, 0, 0, IS_NEVER, 0) ZEND_ARG_TYPE_MASK(0, status, MAY_BE_STRING|MAY_BE_LONG, "0") @@ -243,6 +247,7 @@ static const zend_frameless_function_info frameless_function_infos_class_exists[ { 0 }, }; +ZEND_FUNCTION(clone); ZEND_FUNCTION(exit); ZEND_FUNCTION(zend_version); ZEND_FUNCTION(func_num_args); @@ -306,6 +311,7 @@ ZEND_FUNCTION(gc_disable); ZEND_FUNCTION(gc_status); static const zend_function_entry ext_functions[] = { + ZEND_FE(clone, arginfo_clone) ZEND_FE(exit, arginfo_exit) ZEND_RAW_FENTRY("die", zif_exit, arginfo_die, 0, NULL, NULL) ZEND_FE(zend_version, arginfo_zend_version) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 28bea1a21d759..f3f6d1b75aec1 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4930,6 +4930,20 @@ static zend_result zend_compile_func_sprintf(znode *result, zend_ast_list *args) return SUCCESS; } +static zend_result zend_compile_func_clone(znode *result, zend_ast_list *args) +{ + znode arg_node; + + if (args->children != 1) { + return FAILURE; + } + + zend_compile_expr(&arg_node, args->child[0]); + zend_emit_op_tmp(result, ZEND_CLONE, &arg_node, NULL); + + return SUCCESS; +} + static zend_result zend_try_compile_special_func_ex(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ { if (zend_string_equals_literal(lcname, "strlen")) { @@ -4998,6 +5012,8 @@ static zend_result zend_try_compile_special_func_ex(znode *result, zend_string * return zend_compile_func_array_key_exists(result, args); } else if (zend_string_equals_literal(lcname, "sprintf")) { return zend_compile_func_sprintf(result, args); + } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_CLONE))) { + return zend_compile_func_clone(result, args); } else { return FAILURE; } @@ -5391,17 +5407,6 @@ static void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_clone(znode *result, zend_ast *ast) /* {{{ */ -{ - zend_ast *obj_ast = ast->child[0]; - - znode obj_node; - zend_compile_expr(&obj_node, obj_ast); - - zend_emit_op_tmp(result, ZEND_CLONE, &obj_node, NULL); -} -/* }}} */ - static void zend_compile_global_var(zend_ast *ast) /* {{{ */ { zend_ast *var_ast = ast->child[0]; @@ -11717,9 +11722,6 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */ case ZEND_AST_NEW: zend_compile_new(result, ast); return; - case ZEND_AST_CLONE: - zend_compile_clone(result, ast); - return; case ZEND_AST_ASSIGN_OP: zend_compile_compound_assign(result, ast); return; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 816b8126cbf25..016c6e5c9d098 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1228,7 +1228,16 @@ expr: { $$ = zend_ast_create(ZEND_AST_ASSIGN, $1, $3); } | variable '=' ampersand variable { $$ = zend_ast_create(ZEND_AST_ASSIGN_REF, $1, $4); } - | T_CLONE expr { $$ = zend_ast_create(ZEND_AST_CLONE, $2); } + | T_CLONE '(' T_ELLIPSIS ')' { + zend_ast *name = zend_ast_create_zval_from_str(ZSTR_KNOWN(ZEND_STR_CLONE)); + name->attr = ZEND_NAME_FQ; + $$ = zend_ast_create(ZEND_AST_CALL, name, zend_ast_create_fcc()); + } + | T_CLONE expr { + zend_ast *name = zend_ast_create_zval_from_str(ZSTR_KNOWN(ZEND_STR_CLONE)); + name->attr = ZEND_NAME_FQ; + $$ = zend_ast_create(ZEND_AST_CALL, name, zend_ast_create_list(1, ZEND_AST_ARG_LIST, $2)); + } | variable T_PLUS_EQUAL expr { $$ = zend_ast_create_assign_op(ZEND_ADD, $1, $3); } | variable T_MINUS_EQUAL expr diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 0b2a484016ec3..f60e4dec4e71f 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -575,6 +575,7 @@ EMPTY_SWITCH_DEFAULT_CASE() _(ZEND_STR_UNKNOWN, "unknown") \ _(ZEND_STR_UNKNOWN_CAPITALIZED, "Unknown") \ _(ZEND_STR_EXIT, "exit") \ + _(ZEND_STR_CLONE, "clone") \ _(ZEND_STR_EVAL, "eval") \ _(ZEND_STR_INCLUDE, "include") \ _(ZEND_STR_REQUIRE, "require") \ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 617e114dd05db..be7bc8b37b7dd 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6006,6 +6006,8 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) SAVE_OPLINE(); obj = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_R); + /* ZEND_CLONE also exists as the clone() function and both implementations must be kept in sync. */ + do { if (OP1_TYPE == IS_CONST || (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -6022,7 +6024,7 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) HANDLE_EXCEPTION(); } } - zend_throw_error(NULL, "__clone method called on non-object"); + zend_type_error("clone(): Argument #1 ($object) must be of type object, %s given", zend_zval_value_name(obj)); FREE_OP1(); HANDLE_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 791e4b4e88437..3a13f4244d361 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5180,6 +5180,8 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ SAVE_OPLINE(); obj = RT_CONSTANT(opline, opline->op1); + /* ZEND_CLONE also exists as the clone() function and both implementations must be kept in sync. */ + do { if (IS_CONST == IS_CONST || (IS_CONST != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -5196,7 +5198,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ HANDLE_EXCEPTION(); } } - zend_throw_error(NULL, "__clone method called on non-object"); + zend_type_error("clone(): Argument #1 ($object) must be of type object, %s given", zend_zval_value_name(obj)); HANDLE_EXCEPTION(); } @@ -15428,6 +15430,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND SAVE_OPLINE(); obj = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); + /* ZEND_CLONE also exists as the clone() function and both implementations must be kept in sync. */ + do { if ((IS_TMP_VAR|IS_VAR) == IS_CONST || ((IS_TMP_VAR|IS_VAR) != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -15444,7 +15448,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND HANDLE_EXCEPTION(); } } - zend_throw_error(NULL, "__clone method called on non-object"); + zend_type_error("clone(): Argument #1 ($object) must be of type object, %s given", zend_zval_value_name(obj)); zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } @@ -33523,6 +33527,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND SAVE_OPLINE(); obj = &EX(This); + /* ZEND_CLONE also exists as the clone() function and both implementations must be kept in sync. */ + do { if (IS_UNUSED == IS_CONST || (IS_UNUSED != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -33539,7 +33545,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND HANDLE_EXCEPTION(); } } - zend_throw_error(NULL, "__clone method called on non-object"); + zend_type_error("clone(): Argument #1 ($object) must be of type object, %s given", zend_zval_value_name(obj)); HANDLE_EXCEPTION(); } @@ -41042,6 +41048,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC SAVE_OPLINE(); obj = EX_VAR(opline->op1.var); + /* ZEND_CLONE also exists as the clone() function and both implementations must be kept in sync. */ + do { if (IS_CV == IS_CONST || (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) { @@ -41058,7 +41066,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC HANDLE_EXCEPTION(); } } - zend_throw_error(NULL, "__clone method called on non-object"); + zend_type_error("clone(): Argument #1 ($object) must be of type object, %s given", zend_zval_value_name(obj)); HANDLE_EXCEPTION(); } diff --git a/build/gen_stub.php b/build/gen_stub.php index fcef8213d0b55..d9327b67d042f 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1009,6 +1009,9 @@ class FunctionName implements FunctionOrMethodName { private /* readonly */ Name $name; public function __construct(Name $name) { + if ($name->name === '_clone') { + $name = new Name('clone', $name->getAttributes()); + } $this->name = $name; } @@ -3049,6 +3052,7 @@ class PropertyInfo extends VariableLike "parent" => "ZEND_STR_PARENT", "username" => "ZEND_STR_USERNAME", "password" => "ZEND_STR_PASSWORD", + "clone" => "ZEND_STR_CLONE", ]; /** diff --git a/ext/opcache/tests/func_info.phpt b/ext/opcache/tests/func_info.phpt index 8b1f9ef436c4b..9596aa23199d2 100644 --- a/ext/opcache/tests/func_info.phpt +++ b/ext/opcache/tests/func_info.phpt @@ -16,7 +16,7 @@ foreach (get_defined_functions()["internal"] as $function) { if (in_array($function, ["extract", "compact", "get_defined_vars"])) { continue; } - $contents .= " \$result = {$function}();\n"; + $contents .= " \$result = \\{$function}();\n"; } $contents .= "}\n"; From aea3ade74fdaf5e764061858fdc1d3e5378b862b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladimir=20Vrzi=C4=87?= Date: Mon, 16 Sep 2024 17:59:40 +0200 Subject: [PATCH 54/62] ext/pcntl: Added rusage parameter to pcntl_waitid This functionality is not part of the POSIX interface. - On FreeBSD, the wait6 system call provides it - On Linux, the raw waitid system call provides it (glibc does not) close GH-15921 --- NEWS | 3 + UPGRADING | 2 + ext/pcntl/config.m4 | 5 ++ ext/pcntl/pcntl.c | 46 +++++++++++++-- ext/pcntl/pcntl.stub.php | 7 ++- ext/pcntl/pcntl_arginfo.h | 3 +- ext/pcntl/tests/pcntl_waitid.phpt | 10 ++-- ext/pcntl/tests/pcntl_waitid_rusage.phpt | 72 ++++++++++++++++++++++++ 8 files changed, 137 insertions(+), 11 deletions(-) create mode 100644 ext/pcntl/tests/pcntl_waitid_rusage.phpt diff --git a/NEWS b/NEWS index 930dbec180221..6ff942f86b2b7 100644 --- a/NEWS +++ b/NEWS @@ -134,6 +134,9 @@ PHP NEWS - Output: . Fixed calculation of aligned buffer size. (cmb) +- PCNTL: + . Extend pcntl_waitid with rusage parameter. (vrza) + - PCRE: . Upgraded to pre2lib from 10.44 to 10.45. (nielsdos) . Remove PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK from pcre compile options. diff --git a/UPGRADING b/UPGRADING index 98537007f65cd..4d968ef4daf80 100644 --- a/UPGRADING +++ b/UPGRADING @@ -289,6 +289,8 @@ PHP 8.5 UPGRADE NOTES - PCNTL: . pcntl_exec() now has a formal return type of false. + . pcntl_waitid() takes an additional resource_usage argument to + gather various platform specific metrics about the child process. - PDO_PGSQL: . PDO::pgsqlCopyFromArray also supports inputs as Iterable. diff --git a/ext/pcntl/config.m4 b/ext/pcntl/config.m4 index ce26a6efd2ead..3efa8a53cad1e 100644 --- a/ext/pcntl/config.m4 +++ b/ext/pcntl/config.m4 @@ -25,6 +25,8 @@ if test "$PHP_PCNTL" != "no"; then wait3 wait4 waitid + wait6 + syscall ])) AC_CHECK_FUNCS([WIFCONTINUED],, @@ -43,6 +45,9 @@ if test "$PHP_PCNTL" != "no"; then ]),,, [#include ]) + AC_CHECK_DECLS([SYS_waitid],,, + [#include ]) + dnl if unsupported, -1 means automatically ENOSYS in this context AC_CACHE_CHECK([if sched_getcpu is supported], [php_cv_func_sched_getcpu], [AC_RUN_IFELSE([AC_LANG_SOURCE([ diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 0481c0966c87a..1f061870ed453 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -125,7 +125,15 @@ typedef psetid_t cpu_set_t; #include #endif -#ifdef HAVE_PIDFD_OPEN +#if defined(__linux__) && defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1 && defined(HAVE_SYSCALL) +#define HAVE_LINUX_RAW_SYSCALL_WAITID 1 +#endif + +#if defined(HAVE_LINUX_RAW_SYSCALL_WAITID) +#include +#endif + +#if defined(HAVE_PIDFD_OPEN) || defined(HAVE_LINUX_RAW_SYSCALL_WAITID) #include #endif @@ -401,19 +409,49 @@ PHP_FUNCTION(pcntl_waitid) bool id_is_null = 1; zval *user_siginfo = NULL; zend_long options = WEXITED; + zval *z_rusage = NULL; - ZEND_PARSE_PARAMETERS_START(0, 4) + siginfo_t siginfo; + int status; + + ZEND_PARSE_PARAMETERS_START(0, 5) Z_PARAM_OPTIONAL Z_PARAM_LONG(idtype) Z_PARAM_LONG_OR_NULL(id, id_is_null) Z_PARAM_ZVAL(user_siginfo) Z_PARAM_LONG(options) + Z_PARAM_ZVAL(z_rusage) ZEND_PARSE_PARAMETERS_END(); errno = 0; - siginfo_t siginfo; + memset(&siginfo, 0, sizeof(siginfo_t)); - int status = waitid((idtype_t) idtype, (id_t) id, &siginfo, (int) options); +#if defined(HAVE_WAIT6) || defined(HAVE_LINUX_RAW_SYSCALL_WAITID) + if (z_rusage) { + z_rusage = zend_try_array_init(z_rusage); + if (!z_rusage) { + RETURN_THROWS(); + } + struct rusage rusage; +# if defined(HAVE_WAIT6) /* FreeBSD */ + struct __wrusage wrusage; + memset(&wrusage, 0, sizeof(struct __wrusage)); + pid_t pid = wait6((idtype_t) idtype, (id_t) id, &status, (int) options, &wrusage, &siginfo); + status = pid > 0 ? 0 : pid; + memcpy(&rusage, &wrusage.wru_self, sizeof(struct rusage)); +# else /* Linux */ + memset(&rusage, 0, sizeof(struct rusage)); + status = syscall(SYS_waitid, (idtype_t) idtype, (id_t) id, &siginfo, (int) options, &rusage); +# endif + if (status == 0) { + PHP_RUSAGE_TO_ARRAY(rusage, z_rusage); + } + } else { /* POSIX */ + status = waitid((idtype_t) idtype, (id_t) id, &siginfo, (int) options); + } +#else /* POSIX */ + status = waitid((idtype_t) idtype, (id_t) id, &siginfo, (int) options); +#endif if (status == -1) { PCNTL_G(last_error) = errno; diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index c62a40139d9ed..3f3800c50abe5 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -1006,8 +1006,11 @@ function pcntl_fork(): int {} function pcntl_waitpid(int $process_id, &$status, int $flags = 0, &$resource_usage = []): int {} #if defined (HAVE_WAITID) && defined (HAVE_POSIX_IDTYPES) && defined (HAVE_DECL_WEXITED) && HAVE_DECL_WEXITED == 1 - /** @param array $info */ - function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED): bool {} + /** + * @param array $info + * @param array $resource_usage + */ + function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED, &$resource_usage = []): bool {} #endif /** diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index bc6581d41e17e..8b2367a7c7042 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c637fe2de641cfd8f0ff83a908ac59bf63a68e44 */ + * Stub hash: 5e4b066d70fa264c7de3ba4b2113369c34c33e43 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -17,6 +17,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_waitid, 0, 0, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, id, IS_LONG, 1, "null") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, info, "[]") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "WEXITED") + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, resource_usage, "[]") ZEND_END_ARG_INFO() #endif diff --git a/ext/pcntl/tests/pcntl_waitid.phpt b/ext/pcntl/tests/pcntl_waitid.phpt index b00f26f81fa2e..e297cd107a473 100644 --- a/ext/pcntl/tests/pcntl_waitid.phpt +++ b/ext/pcntl/tests/pcntl_waitid.phpt @@ -26,10 +26,12 @@ if ($pid == -1) { } else { pcntl_signal(SIGUSR1, function ($_signo, $_siginfo) { exit(42); }); posix_kill(posix_getpid(), SIGSTOP); - pcntl_signal_dispatch(); - sleep(42); - pcntl_signal_dispatch(); - exit(6); + $nanoseconds = 100; + while (true) { + pcntl_signal_dispatch(); + time_nanosleep(0, $nanoseconds); + $nanoseconds *= 2; + } } ?> --EXPECTF-- diff --git a/ext/pcntl/tests/pcntl_waitid_rusage.phpt b/ext/pcntl/tests/pcntl_waitid_rusage.phpt new file mode 100644 index 0000000000000..8df148357d1c8 --- /dev/null +++ b/ext/pcntl/tests/pcntl_waitid_rusage.phpt @@ -0,0 +1,72 @@ +--TEST-- +pcntl_waitid() and rusage +--EXTENSIONS-- +pcntl +posix +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +int(%d) +int(%d) +bool(true) +int(%d) +int(%d) +bool(true) +int(%d) +int(42) +bool(false) +string(5) "array" +int(0) +bool(false) +string(5) "array" +int(0) +END From 41d3440658ed22193597239f3526ca099703e5ec Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Tue, 24 Jun 2025 13:05:52 -0700 Subject: [PATCH 55/62] NEWS: add a missing backtick [skip ci] --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6ff942f86b2b7..fe91a1f30ef74 100644 --- a/NEWS +++ b/NEWS @@ -59,7 +59,7 @@ PHP NEWS . Added support for `final` with constructor property promotion. (DanielEScherzer) . Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili) - . Make `clone() a function. (timwolla, edorian) + . Make `clone()` a function. (timwolla, edorian) - Curl: . Added curl_multi_get_handles(). (timwolla) From e7678cdaa4f11897d5d0afd10414c37a76abcb89 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:38:00 +0200 Subject: [PATCH 56/62] sqlite3: Use Z_TRY_ADDREF --- ext/sqlite3/sqlite3.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 5e402300980bb..99c4bea5105ee 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2479,9 +2479,7 @@ static zend_always_inline void php_sqlite3_fetch_one(int n_cols, php_sqlite3_res if (mode & PHP_SQLITE3_ASSOC) { if (mode & PHP_SQLITE3_NUM) { - if (Z_REFCOUNTED(data)) { - Z_ADDREF(data); - } + Z_TRY_ADDREF(data); } /* Note: we can't use the "add_new" variant here instead of "update" because * when the same column name is encountered, the last result should be taken. */ From 6d154758150d1a2f62fe33c3927fe5ad84de30b8 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:41:14 +0200 Subject: [PATCH 57/62] sqlite3: Split off column name cache generation Also no need to reset the cache unconditionally in fetchAll(). --- ext/sqlite3/sqlite3.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 99c4bea5105ee..21b6840a8d1b2 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1987,6 +1987,16 @@ PHP_METHOD(SQLite3Result, columnType) } /* }}} */ +static void sqlite3result_fill_column_names_cache(php_sqlite3_result *result_obj, int nb_cols) +{ + result_obj->column_names = safe_emalloc(nb_cols, sizeof(zend_string*), 0); + + for (int i = 0; i < nb_cols; i++) { + const char *column = sqlite3_column_name(result_obj->stmt_obj->stmt, i); + result_obj->column_names[i] = zend_string_init(column, strlen(column), 0); + } +} + /* {{{ Fetch a result row as both an associative or numerically indexed array or both. */ PHP_METHOD(SQLite3Result, fetchArray) { @@ -2019,12 +2029,7 @@ PHP_METHOD(SQLite3Result, fetchArray) /* Cache column names to speed up repeated fetchArray calls. */ if (mode & PHP_SQLITE3_ASSOC && !result_obj->column_names) { - result_obj->column_names = emalloc(n_cols * sizeof(zend_string*)); - - for (int i = 0; i < n_cols; i++) { - const char *column = sqlite3_column_name(result_obj->stmt_obj->stmt, i); - result_obj->column_names[i] = zend_string_init(column, strlen(column), 0); - } + sqlite3result_fill_column_names_cache(result_obj, n_cols); } array_init(return_value); @@ -2056,7 +2061,7 @@ static void sqlite3result_clear_column_names_cache(php_sqlite3_result *result) { PHP_METHOD(SQLite3Result, fetchAll) { - int i, nb_cols; + int nb_cols; bool done = false; php_sqlite3_result *result_obj; zval *object = ZEND_THIS; @@ -2071,14 +2076,8 @@ PHP_METHOD(SQLite3Result, fetchAll) SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result) nb_cols = sqlite3_column_count(result_obj->stmt_obj->stmt); - if (mode & PHP_SQLITE3_ASSOC) { - sqlite3result_clear_column_names_cache(result_obj); - result_obj->column_names = emalloc(nb_cols * sizeof(zend_string*)); - - for (i = 0; i < nb_cols; i++) { - const char *column = sqlite3_column_name(result_obj->stmt_obj->stmt, i); - result_obj->column_names[i] = zend_string_init(column, strlen(column), 0); - } + if (mode & PHP_SQLITE3_ASSOC && !result_obj->column_names) { + sqlite3result_fill_column_names_cache(result_obj, nb_cols); } result_obj->column_count = nb_cols; array_init(return_value); From 6233dc6210b159762a97b7759ea0883d027feac1 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 25 Jun 2025 01:57:07 +0530 Subject: [PATCH 58/62] Switch to windows-2022 in CI (#18927) * Switch to windows-2022 in CI windows-2019 runner will be dropped by GitHub on 2025-06-30. * xfail test cases that fail on windows-2022 --- .github/scripts/windows/build.bat | 4 +- .github/scripts/windows/find-vs-toolset.bat | 49 +++++++++++++++++++++ .github/scripts/windows/test.bat | 3 +- .github/workflows/push.yml | 2 +- .github/workflows/root.yml | 2 +- Zend/tests/bug70258.phpt | 3 ++ Zend/tests/gh11189.phpt | 3 ++ Zend/tests/gh11189_1.phpt | 3 ++ 8 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 .github/scripts/windows/find-vs-toolset.bat diff --git a/.github/scripts/windows/build.bat b/.github/scripts/windows/build.bat index ebe08c86b5ea9..139cce8be816e 100644 --- a/.github/scripts/windows/build.bat +++ b/.github/scripts/windows/build.bat @@ -43,7 +43,9 @@ if not exist "%SDK_RUNNER%" ( exit /b 3 ) -cmd /c %SDK_RUNNER% -t .github\scripts\windows\build_task.bat +for /f "delims=" %%T in ('call .github\scripts\windows\find-vs-toolset.bat %PHP_BUILD_CRT%') do set "VS_TOOLSET=%%T" +echo Got VS Toolset %VS_TOOLSET% +cmd /c %SDK_RUNNER% -s %VS_TOOLSET% -t .github\scripts\windows\build_task.bat if %errorlevel% neq 0 exit /b 3 exit /b 0 diff --git a/.github/scripts/windows/find-vs-toolset.bat b/.github/scripts/windows/find-vs-toolset.bat new file mode 100644 index 0000000000000..2d9e68e730318 --- /dev/null +++ b/.github/scripts/windows/find-vs-toolset.bat @@ -0,0 +1,49 @@ +@echo off + +setlocal enabledelayedexpansion + +if "%~1"=="" ( + echo ERROR: Usage: %~nx0 [vc14^|vc15^|vs16^|vs17] + exit /b 1 +) + +set "toolsets_vc14=14.0" +set "toolsets_vc15=" +set "toolsets_vs16=" +set "toolsets_vs17=" + + +for /f "usebackq tokens=*" %%I in (`vswhere.exe -latest -find "VC\Tools\MSVC"`) do set "MSVCDIR=%%I" + +if not defined MSVCDIR ( + echo ERROR: could not locate VC\Tools\MSVC + exit /b 1 +) + +for /f "delims=" %%D in ('dir /b /ad "%MSVCDIR%"') do ( + for /f "tokens=1,2 delims=." %%A in ("%%D") do ( + set "maj=%%A" & set "min=%%B" + if "!maj!"=="14" ( + if !min! LEQ 9 ( + set "toolsets_vc14=%%D" + ) else if !min! LEQ 19 ( + set "toolsets_vc15=%%D" + ) else if !min! LEQ 29 ( + set "toolsets_vs16=%%D" + ) else ( + set "toolsets_vs17=%%D" + ) + ) + ) +) + +set "KEY=%~1" +set "VAR=toolsets_%KEY%" +call set "RESULT=%%%VAR%%%" +if defined RESULT ( + echo %RESULT% + exit /b 0 +) else ( + echo ERROR: no toolset found for %KEY% + exit /b 1 +) diff --git a/.github/scripts/windows/test.bat b/.github/scripts/windows/test.bat index 510e9bc78f4ed..7ef60534cc780 100644 --- a/.github/scripts/windows/test.bat +++ b/.github/scripts/windows/test.bat @@ -11,7 +11,8 @@ if not exist "%SDK_RUNNER%" ( exit /b 3 ) -cmd /c %SDK_RUNNER% -t .github\scripts\windows\test_task.bat +for /f "delims=" %%T in ('call .github\scripts\windows\find-vs-toolset.bat %PHP_BUILD_CRT%') do set "VS_TOOLSET=%%T" +cmd /c %SDK_RUNNER% -s %VS_TOOLSET% -t .github\scripts\windows\test_task.bat if %errorlevel% neq 0 exit /b 3 exit /b 0 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 214798af62b5c..5353ef7d0ea44 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -147,7 +147,7 @@ jobs: WINDOWS: if: github.repository == 'php/php-src' || github.event_name == 'pull_request' name: WINDOWS_X64_ZTS - runs-on: windows-2019 + runs-on: windows-2022 env: PHP_BUILD_CACHE_BASE_DIR: C:\build-cache PHP_BUILD_OBJ_DIR: C:\obj diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index a98bb39ba0d92..78e0d47aa1d15 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -58,7 +58,7 @@ jobs: ubuntu_version: ${{ (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 5) || matrix.branch.version[0] >= 9) && '24.04') || '22.04' }} - windows_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '2022' || '2019' }} + windows_version: '2022' skip_laravel: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} skip_symfony: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} skip_wordpress: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} diff --git a/Zend/tests/bug70258.phpt b/Zend/tests/bug70258.phpt index 40915a286ef9e..d346dbdf3a35b 100644 --- a/Zend/tests/bug70258.phpt +++ b/Zend/tests/bug70258.phpt @@ -4,6 +4,9 @@ Bug #70258 (Segfault if do_resize fails to allocated memory) memory_limit=2M --SKIPIF-- --INI-- diff --git a/Zend/tests/gh11189_1.phpt b/Zend/tests/gh11189_1.phpt index 53727908e5e2a..17b9967bc3182 100644 --- a/Zend/tests/gh11189_1.phpt +++ b/Zend/tests/gh11189_1.phpt @@ -2,6 +2,9 @@ GH-11189: Exceeding memory limit in zend_hash_do_resize leaves the array in an invalid state (not packed array) --SKIPIF-- --INI-- From 2965fb843d732ff014000c8c293d515d17684bd5 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 24 Jun 2025 21:55:00 +0100 Subject: [PATCH 59/62] ext/pcntl: following up #15921 rework SYS_pidfd_open configure detection. (#18931) --- ext/pcntl/config.m4 | 4 +++- ext/pcntl/pcntl.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ext/pcntl/config.m4 b/ext/pcntl/config.m4 index 3efa8a53cad1e..cfe6e80ca1103 100644 --- a/ext/pcntl/config.m4 +++ b/ext/pcntl/config.m4 @@ -13,7 +13,6 @@ if test "$PHP_PCNTL" != "no"; then forkx getcpuid getpriority - pidfd_open pset_bind pthread_set_qos_class_self_np rfork @@ -48,6 +47,9 @@ if test "$PHP_PCNTL" != "no"; then AC_CHECK_DECLS([SYS_waitid],,, [#include ]) + AC_CHECK_DECLS([SYS_pidfd_open],,, + [#include ]) + dnl if unsupported, -1 means automatically ENOSYS in this context AC_CACHE_CHECK([if sched_getcpu is supported], [php_cv_func_sched_getcpu], [AC_RUN_IFELSE([AC_LANG_SOURCE([ diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 1f061870ed453..886d4b6b595ff 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -125,18 +125,20 @@ typedef psetid_t cpu_set_t; #include #endif -#if defined(__linux__) && defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1 && defined(HAVE_SYSCALL) -#define HAVE_LINUX_RAW_SYSCALL_WAITID 1 +#if defined(__linux__) && defined(HAVE_SYSCALL) +# include +# if defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1 +# define HAVE_LINUX_RAW_SYSCALL_WAITID 1 +# endif +# if defined(HAVE_DECL_SYS_PIDFD_OPEN) && HAVE_DECL_SYS_PIDFD_OPEN == 1 +# define HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN 1 +# endif #endif #if defined(HAVE_LINUX_RAW_SYSCALL_WAITID) #include #endif -#if defined(HAVE_PIDFD_OPEN) || defined(HAVE_LINUX_RAW_SYSCALL_WAITID) -#include -#endif - #ifdef HAVE_FORKX #include #endif @@ -1607,7 +1609,7 @@ PHP_FUNCTION(pcntl_forkx) #endif /* }}} */ -#ifdef HAVE_PIDFD_OPEN +#ifdef HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN // The `pidfd_open` syscall is available since 5.3 // and `setns` since 3.0. PHP_FUNCTION(pcntl_setns) From 359a21f102b5ca9e517253281228da68a053b3ae Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:55:11 +0200 Subject: [PATCH 60/62] Fix RCN violations in array functions When the array functions perform their operation in-place, the `@refcount 1` annotation is wrong and causes a failure under `ZEND_VERIFY_FUNC_INFO`. The test file tests all functions that have the in-place optimization, even those that didn't have the refcount annotation, just to prevent future regressions. Closes GH-18929. --- NEWS | 1 + Zend/Optimizer/zend_func_infos.h | 7 --- ext/standard/basic_functions.stub.php | 7 --- ext/standard/basic_functions_arginfo.h | 2 +- ext/standard/tests/array/rcn_in_place.phpt | 57 ++++++++++++++++++++++ 5 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 ext/standard/tests/array/rcn_in_place.phpt diff --git a/NEWS b/NEWS index 34866abfb21d8..624bcda9bdf44 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ PHP NEWS - Standard: . Fix misleading errors in printf(). (nielsdos) + . Fix RCN violations in array functions. (nielsdos) - Streams: . Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 125212d2292e6..c9229d638f433 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -450,8 +450,6 @@ static const func_info_t func_infos[] = { F1("compact", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), FN("array_fill", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY), F1("array_fill_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_replace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_replace_recursive", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), FN("array_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING), FN("array_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_count_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG), @@ -460,13 +458,8 @@ static const func_info_t func_infos[] = { F1("array_flip", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING), F1("array_change_key_case", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_intersect_key", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_intersect_ukey", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_intersect", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_uintersect", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_intersect_assoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_uintersect_assoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_intersect_uassoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), - F1("array_uintersect_uassoc", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_diff_key", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_diff_ukey", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), F1("array_udiff", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF), diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 3bdc3827b4d36..0bbdeeb72a2c3 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1678,13 +1678,11 @@ function array_merge_recursive(array ...$arrays): array {} /** * @compile-time-eval - * @refcount 1 */ function array_replace(array $array, array ...$replacements): array {} /** * @compile-time-eval - * @refcount 1 */ function array_replace_recursive(array $array, array ...$replacements): array {} @@ -1757,19 +1755,16 @@ function array_intersect_key(array $array, array ...$arrays): array {} /** * @param array|callable $rest - * @refcount 1 */ function array_intersect_ukey(array $array, ...$rest): array {} /** * @compile-time-eval - * @refcount 1 */ function array_intersect(array $array, array ...$arrays): array {} /** * @param array|callable $rest - * @refcount 1 */ function array_uintersect(array $array, ...$rest): array {} @@ -1787,13 +1782,11 @@ function array_uintersect_assoc(array $array, ...$rest): array {} /** * @param array|callable $rest - * @refcount 1 */ function array_intersect_uassoc(array $array, ...$rest): array {} /** * @param array|callable $rest - * @refcount 1 */ function array_uintersect_uassoc(array $array, ...$rest): array {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 1361cf6062797..23ee75fe18dc3 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2a3d8da0b92134dcca74f2ac70454bd27768f20e */ + * Stub hash: 60960e59f6310521a958b6fb0917650854d19612 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) diff --git a/ext/standard/tests/array/rcn_in_place.phpt b/ext/standard/tests/array/rcn_in_place.phpt new file mode 100644 index 0000000000000..e6a7b5b6d695f --- /dev/null +++ b/ext/standard/tests/array/rcn_in_place.phpt @@ -0,0 +1,57 @@ +--TEST-- +RCN check for in-place array modifications +--FILE-- + 0)); +var_dump(array_intersect(range(0, 1), [])); +var_dump(array_uintersect(range(0, 1), [], fn () => 0)); +var_dump(array_intersect_uassoc(range(0, 1), [], fn () => 0)); +var_dump(array_uintersect_uassoc(range(0, 1), [], fn () => 0, fn () => 0)); +?> +--EXPECT-- +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} +array(2) { + [0]=> + int(0) + [1]=> + int(1) +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} From ea6a7a97255b939539cf92d43ce4c5c8b24b3199 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 25 Jun 2025 03:15:10 +0530 Subject: [PATCH 61/62] Fix CI for windows-2022 This is a continuation of GH-18927 to fix CI for windows-2022 --- Zend/tests/bug40770.phpt | 3 +++ Zend/tests/gh12073.phpt | 3 +++ tests/basic/timeout_variation_0.phpt | 3 +++ tests/basic/timeout_variation_7.phpt | 3 +++ tests/func/005a.phpt | 3 +++ tests/lang/bug45392.phpt | 3 +++ 6 files changed, 18 insertions(+) diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt index f37d96d5ff333..bdbae4cf8f1a2 100644 --- a/Zend/tests/bug40770.phpt +++ b/Zend/tests/bug40770.phpt @@ -4,6 +4,9 @@ Bug #40770 (Apache child exits when PHP memory limit reached) memory_limit=8M --SKIPIF-- --FILE-- diff --git a/tests/basic/timeout_variation_7.phpt b/tests/basic/timeout_variation_7.phpt index 0401240ba953d..3d40b540677db 100644 --- a/tests/basic/timeout_variation_7.phpt +++ b/tests/basic/timeout_variation_7.phpt @@ -2,6 +2,9 @@ Timeout within for loop --SKIPIF-- --FILE-- diff --git a/tests/func/005a.phpt b/tests/func/005a.phpt index cf1e5713770a9..2f527d773adbe 100644 --- a/tests/func/005a.phpt +++ b/tests/func/005a.phpt @@ -2,6 +2,9 @@ Testing register_shutdown_function() with timeout. (Bug: #21513) --SKIPIF-- --FILE-- diff --git a/tests/lang/bug45392.phpt b/tests/lang/bug45392.phpt index 692fa0cdcf6fd..1a01bac3261a9 100644 --- a/tests/lang/bug45392.phpt +++ b/tests/lang/bug45392.phpt @@ -2,6 +2,9 @@ Bug #45392 (ob_start()/ob_end_clean() and memory_limit) --SKIPIF-- Date: Wed, 25 Jun 2025 03:15:10 +0530 Subject: [PATCH 62/62] Fix CI for windows-2022 This is a continuation of GH-18927 to fix CI for windows-2022 --- Zend/tests/bug40770.phpt | 3 +++ Zend/tests/gh12073.phpt | 3 +++ Zend/tests/traits/bugs/gh13177.phpt | 6 ++++++ tests/basic/timeout_variation_0.phpt | 3 +++ tests/basic/timeout_variation_7.phpt | 3 +++ tests/func/005a.phpt | 3 +++ tests/lang/bug45392.phpt | 3 +++ 7 files changed, 24 insertions(+) diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt index f37d96d5ff333..bdbae4cf8f1a2 100644 --- a/Zend/tests/bug40770.phpt +++ b/Zend/tests/bug40770.phpt @@ -4,6 +4,9 @@ Bug #40770 (Apache child exits when PHP memory limit reached) memory_limit=8M --SKIPIF-- --FILE-- --FILE-- diff --git a/tests/basic/timeout_variation_7.phpt b/tests/basic/timeout_variation_7.phpt index 0401240ba953d..3d40b540677db 100644 --- a/tests/basic/timeout_variation_7.phpt +++ b/tests/basic/timeout_variation_7.phpt @@ -2,6 +2,9 @@ Timeout within for loop --SKIPIF-- --FILE-- diff --git a/tests/func/005a.phpt b/tests/func/005a.phpt index cf1e5713770a9..2f527d773adbe 100644 --- a/tests/func/005a.phpt +++ b/tests/func/005a.phpt @@ -2,6 +2,9 @@ Testing register_shutdown_function() with timeout. (Bug: #21513) --SKIPIF-- --FILE-- diff --git a/tests/lang/bug45392.phpt b/tests/lang/bug45392.phpt index 692fa0cdcf6fd..1a01bac3261a9 100644 --- a/tests/lang/bug45392.phpt +++ b/tests/lang/bug45392.phpt @@ -2,6 +2,9 @@ Bug #45392 (ob_start()/ob_end_clean() and memory_limit) --SKIPIF--