From f42b5a7d65ae9777c3d2f2b2a02725607ed8e0c3 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 26 Aug 2019 23:02:57 +0100 Subject: [PATCH] Warnings become errors hash stream functions (other than hash_init) --- ext/hash/hash.c | 8 +++++--- ext/hash/tests/reuse.phpt | 12 +++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 2fbff0d102299..7feb4a2cc4973 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -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; } } /* }}} */ diff --git a/ext/hash/tests/reuse.phpt b/ext/hash/tests/reuse.phpt index cd1419fd555eb..54ef56f08f4c6 100644 --- a/ext/hash/tests/reuse.phpt +++ b/ext/hash/tests/reuse.phpt @@ -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