]> granicus.if.org Git - php/commitdiff
Promote warning to exception in parse_url()
authorMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 10 Dec 2019 22:54:26 +0000 (23:54 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 11 Dec 2019 17:47:48 +0000 (18:47 +0100)
ext/standard/tests/url/parse_url_error_002.phpt
ext/standard/url.c

index 5af4232e0cd78d112cfc5cb549bb3f9e3669a0d3..07188c57c7cf6f723271c33eb0b300c145c466e1 100644 (file)
@@ -14,8 +14,12 @@ $url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=m
 echo "--> Below range:";
 var_dump(parse_url($url, -1));
 
-echo "\n\n--> Above range:";
-var_dump(parse_url($url, 99));
+echo "\n\n--> Above range:\n";
+try {
+    parse_url($url, 99);
+} catch (ValueError $exception) {
+    echo $exception->getMessage() . "\n";
+}
 
 echo "Done"
 ?>
@@ -42,6 +46,5 @@ echo "Done"
 
 
 --> Above range:
-Warning: parse_url(): Invalid URL component identifier 99 in %s on line 15
-bool(false)
+Invalid URL component identifier: 99
 Done
index 622c4aa6937d8a4158fc1adfcc82d11228a9fb05..c2d9340e1c16ea2083ce1d125f490bcbd9d0524a 100644 (file)
@@ -363,8 +363,8 @@ PHP_FUNCTION(parse_url)
                                if (resource->fragment != NULL) RETVAL_STR_COPY(resource->fragment);
                                break;
                        default:
-                               php_error_docref(NULL, E_WARNING, "Invalid URL component identifier " ZEND_LONG_FMT, key);
-                               RETVAL_FALSE;
+                               zend_value_error("Invalid URL component identifier: " ZEND_LONG_FMT, key);
+                               break;
                }
                goto done;
        }