Skip to content

Commit 273674c

Browse files
committed
Get rid of remaining usages of zval_try_get_string()
This isn't necessary because the cases where we use it will always succeed because the properties always have the type string|null.
1 parent a707863 commit 273674c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

ext/dom/document.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,8 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)
194194
{
195195
DOM_PROP_NODE(xmlDocPtr, docp, obj);
196196

197-
zend_string *str = zval_try_get_string(newval);
198-
if (UNEXPECTED(!str)) {
199-
return FAILURE;
200-
}
197+
/* Cannot fail because the type is either null or a string. */
198+
zend_string *str = zval_get_string(newval);
201199

202200
if (php_dom_follow_spec_intern(obj)) {
203201
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)
396394
{
397395
DOM_PROP_NODE(xmlDocPtr, docp, obj);
398396

399-
zend_string *str = zval_try_get_string(newval);
400-
if (UNEXPECTED(!str)) {
401-
return FAILURE;
402-
}
397+
/* Cannot fail because the type is either null or a string. */
398+
zend_string *str = zval_get_string(newval);
403399

404400
if (docp->URL != NULL) {
405401
xmlFree(BAD_CAST docp->URL);
@@ -1775,12 +1771,20 @@ PHP_METHOD(DOMDocument, xinclude)
17751771

17761772
php_libxml_invalidate_node_list_cache(intern->document);
17771773

1778-
if (err) {
1779-
RETVAL_LONG(err);
1774+
if (php_dom_follow_spec_intern(intern)) {
1775+
if (err < 0) {
1776+
RETURN_FALSE;
1777+
} else {
1778+
RETURN_LONG(err);
1779+
}
17801780
} else {
1781-
RETVAL_FALSE;
1781+
/* Legacy, bizarre return value behaviour */
1782+
if (err) {
1783+
RETURN_LONG(err);
1784+
} else {
1785+
RETURN_FALSE;
1786+
}
17821787
}
1783-
17841788
}
17851789
/* }}} */
17861790

ext/dom/node.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ zend_result dom_node_node_value_write(dom_object *obj, zval *newval)
179179
{
180180
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
181181

182-
zend_string *str = zval_try_get_string(newval);
183-
if (UNEXPECTED(!str)) {
184-
return FAILURE;
185-
}
182+
/* Cannot fail because the type is either null or a string. */
183+
zend_string *str = zval_get_string(newval);
186184

187185
/* Access to Element node is implemented as a convenience method */
188186
switch (nodep->type) {

0 commit comments

Comments
 (0)