]> granicus.if.org Git - php/commitdiff
Warnings become errors hash stream functions (other than hash_init)
authorMark <mrandall@digitellinc.com>
Mon, 26 Aug 2019 22:02:57 +0000 (23:02 +0100)
committerJoe Watkins <krakjoe@php.net>
Thu, 29 Aug 2019 14:10:08 +0000 (16:10 +0200)
ext/hash/hash.c
ext/hash/tests/reuse.phpt

index 82c27afd6421af3630cf1c48a4575e0bc5c0e757..a26b9a37673dfd8936775f699d06078095b4323b 100644 (file)
@@ -414,8 +414,8 @@ PHP_FUNCTION(hash_init)
 
 #define PHP_HASHCONTEXT_VERIFY(func, hash) { \
        if (!hash->context) { \
-               php_error(E_WARNING, "%s(): supplied resource is not a valid Hash Context resource", func); \
-               RETURN_NULL(); \
+               zend_throw_error(NULL, "%s(): supplied resource is not a valid Hash Context resource", func); \
+               return; \
        } \
 }
 
@@ -585,7 +585,9 @@ PHP_FUNCTION(hash_copy)
 
        if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) {
                zval_ptr_dtor(return_value);
-               RETURN_FALSE;
+
+               zend_throw_error(NULL, "Cannot copy hash");
+               return;
        }
 }
 /* }}} */
index cd1419fd555ebb1d54a10725459e72bd2046ee08..54ef56f08f4c6eafc48b7404c5452f032aee7905 100644 (file)
@@ -5,6 +5,12 @@ Hash: Attempt to reuse a closed hash context
 
 $h = hash_init('md5');
 hash_final($h);
-hash_update($h, 'foo');
---EXPECTF--
-Warning: hash_update(): supplied resource is not a valid Hash Context resource in %s%eext%ehash%etests%ereuse.php on line %d
+try { 
+    hash_update($h, 'foo');
+}
+catch (\Error $e) {
+    echo $e->getMessage() . "\n";
+}
+
+--EXPECT--
+hash_update(): supplied resource is not a valid Hash Context resource