[php-src] master: Get rid of remaining usages of zval_try_get_string() (#14041)
| From: | Niels Dossche via GitHub | Date: | Wed, 24 Apr 2024 21:47:17 +0000 |
| Subject: | [php-src] master: Get rid of remaining usages of zval_try_get_string() (#14041) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128234@lists.php.net to get a copy of this message | ||
Author: Niels Dossche (nielsdos)
Committer: GitHub (web-flow)
Pusher: nielsdos
Date: 2024-04-24T23:47:10+02:00
Commit: https://github.com/php/php-src/commit/3626e2d552307abed24337237074f78157e46b31
Raw diff: https://github.com/php/php-src/commit/3626e2d552307abed24337237074f78157e46b31.diff
Get rid of remaining usages of zval_try_get_string() (#14041)
This isn't necessary because the cases where we use it will always
succeed because the properties always have the type string|null.
Changed paths:
M ext/dom/document.c
M ext/dom/node.c
Diff:
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 5e2457483f6d..f6a778f086dd 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -194,10 +194,8 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);
- zend_string *str = zval_try_get_string(newval);
- if (UNEXPECTED(!str)) {
- return FAILURE;
- }
+ /* Cannot fail because the type is either null or a string. */
+ zend_string *str = zval_get_string(newval);
if (php_dom_follow_spec_intern(obj)) {
if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str,
"1.1")) {
@@ -396,10 +394,8 @@ zend_result dom_document_document_uri_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlDocPtr, docp, obj);
- zend_string *str = zval_try_get_string(newval);
- if (UNEXPECTED(!str)) {
- return FAILURE;
- }
+ /* Cannot fail because the type is either null or a string. */
+ zend_string *str = zval_get_string(newval);
if (docp->URL != NULL) {
xmlFree(BAD_CAST docp->URL);
@@ -1780,7 +1776,6 @@ PHP_METHOD(DOMDocument, xinclude)
} else {
RETVAL_FALSE;
}
-
}
/* }}} */
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 1f36b222b54b..86585c085deb 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -179,10 +179,8 @@ zend_result dom_node_node_value_write(dom_object *obj, zval *newval)
{
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
- zend_string *str = zval_try_get_string(newval);
- if (UNEXPECTED(!str)) {
- return FAILURE;
- }
+ /* Cannot fail because the type is either null or a string. */
+ zend_string *str = zval_get_string(newval);
/* Access to Element node is implemented as a convenience method */
switch (nodep->type) {