diff --git a/ext/standard/tests/filters/filter_errors_zlib_inflate.phpt b/ext/standard/tests/filters/filter_errors_zlib_inflate.phpt index 608a8ad28dbd5..79af8894344ac 100644 --- a/ext/standard/tests/filters/filter_errors_zlib_inflate.phpt +++ b/ext/standard/tests/filters/filter_errors_zlib_inflate.phpt @@ -5,14 +5,14 @@ Filter errors: zlib.inflate --FILE-- getMessage() . \PHP_EOL; +} ?> --EXPECTF-- test filtering of buffered data -Notice: stream_filter_append(): zlib: data error in %s on line %d - Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s -test filtering of non buffered data - -Notice: stream_get_contents(): zlib: data error in %s on line %d +zlib: data error diff --git a/ext/zlib/tests/005.phpt b/ext/zlib/tests/005.phpt index 46c9115827861..1fdf6eb726b8b 100644 --- a/ext/zlib/tests/005.phpt +++ b/ext/zlib/tests/005.phpt @@ -7,7 +7,7 @@ zlib try { var_dump(gzcompress("", 1000)); -} catch (\ValueError $e) { +} catch (\Throwable $e) { echo $e->getMessage() . \PHP_EOL; } @@ -24,23 +24,36 @@ var_dump($data2 = gzcompress($string, 9)); try { var_dump(gzuncompress("", 1000)); -} catch (\ValueError $e) { +} catch (\Throwable $e) { echo $e->getMessage() . \PHP_EOL; } try { var_dump(gzuncompress("", -1)); -} catch (\ValueError $e) { +} catch (\Throwable $e) { echo $e->getMessage() . \PHP_EOL; } -var_dump(gzuncompress("")); -var_dump(gzuncompress("", 9)); +try { + var_dump(gzuncompress("")); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + var_dump(gzuncompress("", 9)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzuncompress($data1)); var_dump(gzuncompress($data2)); $data2[4] = 0; -var_dump(gzuncompress($data2)); +try { + var_dump(gzuncompress($data2)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- @@ -50,22 +63,14 @@ string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" - -Warning: gzuncompress(): %s error in %s on line %d -bool(false) +data error gzuncompress(): Argument #2 ($max_length) must be greater than or equal to 0 - -Warning: gzuncompress(): %s error in %s on line %d -bool(false) - -Warning: gzuncompress(): %s error in %s on line %d -bool(false) +data error +data error string(94) "Answer me, it can't be so hard Cry to relieve what's in your heart Desolation, grief and agony" string(94) "Answer me, it can't be so hard Cry to relieve what's in your heart Desolation, grief and agony" - -Warning: gzuncompress(): %s error in %s on line %d -bool(false) +data error diff --git a/ext/zlib/tests/006.phpt b/ext/zlib/tests/006.phpt index a004d83230ad3..6497ed0d041c3 100644 --- a/ext/zlib/tests/006.phpt +++ b/ext/zlib/tests/006.phpt @@ -7,7 +7,7 @@ zlib try { var_dump(gzcompress("", 1000)); -} catch (\ValueError $e) { +} catch (\Throwable $e) { echo $e->getMessage() . \PHP_EOL; } @@ -23,23 +23,44 @@ Desolation, grief and agony"; var_dump($data1 = gzdeflate($string)); var_dump($data2 = gzdeflate($string, 9)); -var_dump(gzinflate("")); -var_dump(gzinflate("asfwe", 1000)); +try { + var_dump(gzinflate("")); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + var_dump(gzinflate("asfwe", 1000)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} try { var_dump(gzinflate("asdf", -1)); -} catch (\ValueError $e) { +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + var_dump(gzinflate("asdf")); +} catch (\Throwable $e) { echo $e->getMessage() . \PHP_EOL; } -var_dump(gzinflate("asdf")); -var_dump(gzinflate("asdf", 9)); +try { + var_dump(gzinflate("asdf", 9)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(gzinflate($data1)); var_dump(gzinflate($data2)); $data2[4] = 0; -var_dump(gzinflate($data2)); - +try { + var_dump(gzinflate($data2)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- gzcompress(): Argument #2 ($level) must be between -1 and 9 @@ -48,25 +69,15 @@ string(%d) "%a" string(%d) "%a" string(%d) "%a" string(%d) "%a" - -Warning: gzinflate(): data error in %s on line %d -bool(false) - -Warning: gzinflate(): data error in %s on line %d -bool(false) +data error +data error gzinflate(): Argument #2 ($max_length) must be greater than or equal to 0 - -Warning: gzinflate(): data error in %s on line %d -bool(false) - -Warning: gzinflate(): data error in %s on line %d -bool(false) +data error +data error string(94) "Answer me, it can't be so hard Cry to relieve what's in your heart Desolation, grief and agony" string(94) "Answer me, it can't be so hard Cry to relieve what's in your heart Desolation, grief and agony" - -Warning: gzinflate(): data error in %s on line %d -bool(false) +data error diff --git a/ext/zlib/tests/bug61139.phpt b/ext/zlib/tests/bug61139.phpt index 1a6f2a1ac2c8b..0923b65034b0c 100644 --- a/ext/zlib/tests/bug61139.phpt +++ b/ext/zlib/tests/bug61139.phpt @@ -4,12 +4,14 @@ Bug #61139 (gzopen leaks when specifying invalid mode) zlib --FILE-- +try { + gzopen('someFile', 'c'); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} --CLEAN-- --EXPECTF-- -Warning: gzopen(): gzopen failed in %s on line %d +gzopen failed diff --git a/ext/zlib/tests/bug71417.phpt b/ext/zlib/tests/bug71417.phpt index eac0d7efed1de..7aa7c1438ad3e 100644 --- a/ext/zlib/tests/bug71417.phpt +++ b/ext/zlib/tests/bug71417.phpt @@ -45,15 +45,23 @@ function test($case) { // The gzdecode() function applied to the corrupted compressed data always // detects the error: // --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... - echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; + try { + echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } file_put_contents($fn, $compressed); $r = fopen($fn, "r"); stream_filter_append($r, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); while (!feof($r)) { - $s = fread($r, 100); - echo "read: "; var_dump($s); + try { + $s = fread($r, 100); + echo "read: "; var_dump($s); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } } fclose($r); unlink($fn); @@ -66,25 +74,11 @@ test(4); ?> --EXPECTF-- -gzdecode(): -Warning: gzdecode(): data error in %s on line %d - - -Notice: fread(): zlib: data error in %s on line %d -read: bool(false) -gzdecode(): -Warning: gzdecode(): data error in %s on line %d - +gzdecode(): data error +zlib: data error +gzdecode(): data error read: string(32) "The quick brown fox jumps over t" -gzdecode(): -Warning: gzdecode(): data error in %s on line %d - - -Notice: fread(): zlib: data error in %s on line %d -read: bool(false) -gzdecode(): -Warning: gzdecode(): data error in %s on line %d - - -Notice: fread(): zlib: data error in %s on line %d -read: bool(false) +gzdecode(): data error +zlib: data error +gzdecode(): data error +zlib: data error diff --git a/ext/zlib/tests/bug_52944.phpt b/ext/zlib/tests/bug_52944.phpt index 50f87063dda76..341c979c5b80c 100644 --- a/ext/zlib/tests/bug_52944.phpt +++ b/ext/zlib/tests/bug_52944.phpt @@ -14,13 +14,20 @@ require __DIR__ . "/bug_52944_corrupted_data.inc"; $fp = fopen('data://text/plain;base64,' . $data, 'r'); stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ); -var_dump(fread($fp,1)); -var_dump(fread($fp,1)); +try { + var_dump(fread($fp,1)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(fread($fp,1)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} fclose($fp); echo "Done.\n"; ?> --EXPECTF-- -Notice: fread(): zlib: data error in %s on line %d -bool(false) +zlib: data error string(0) "" Done. diff --git a/ext/zlib/tests/dictionary_usage.phpt b/ext/zlib/tests/dictionary_usage.phpt index f6f2b87386ed4..ffb5d51391843 100644 --- a/ext/zlib/tests/dictionary_usage.phpt +++ b/ext/zlib/tests/dictionary_usage.phpt @@ -19,13 +19,15 @@ $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]); var_dump(inflate_add($r, $a, ZLIB_FINISH)); $r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["8"] + range("a", "z")]); -var_dump(inflate_add($r, $a, ZLIB_FINISH)); +try { + var_dump(inflate_add($r, $a, ZLIB_FINISH)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- string(%d) "%s" bool(true) string(6) "abdcde" - -Warning: inflate_add(): Dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d -bool(false) +Dictionary does not match expected dictionary (incorrect adler32 hash) diff --git a/ext/zlib/tests/gzinflate-bug42663.phpt b/ext/zlib/tests/gzinflate-bug42663.phpt index cdaf53fb85d15..dcf1487a3c7dd 100644 --- a/ext/zlib/tests/gzinflate-bug42663.phpt +++ b/ext/zlib/tests/gzinflate-bug42663.phpt @@ -15,12 +15,14 @@ var_dump(strlen($deflated)); $truncated = substr($deflated, 0, 65535); var_dump(strlen($truncated)); // inflate $truncated string (check if it will not eat all memory) -var_dump(gzinflate($truncated)); +try { + var_dump(gzinflate($truncated)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- int(168890) int(66743) int(65535) - -Warning: gzinflate(): data error in %s on line %d -bool(false) +data error diff --git a/ext/zlib/tests/gzinflate_error1.phpt b/ext/zlib/tests/gzinflate_error1.phpt index 8d4abdf529b02..14d27b42cd58d 100644 --- a/ext/zlib/tests/gzinflate_error1.phpt +++ b/ext/zlib/tests/gzinflate_error1.phpt @@ -13,13 +13,15 @@ $data = 'string_val'; $short_len = strlen($data) - 1; $compressed = gzcompress($data); -var_dump(gzinflate($compressed, $short_len)); +try { + var_dump(gzinflate($compressed, $short_len)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- *** Testing gzinflate() : error conditions *** -- Testing with a buffer that is too small -- - -Warning: gzinflate(): data error in %s on line %d -bool(false) +data error diff --git a/ext/zlib/tests/gzinflate_length.phpt b/ext/zlib/tests/gzinflate_length.phpt index 5ab58c4a05261..8c6a4934cc6aa 100644 --- a/ext/zlib/tests/gzinflate_length.phpt +++ b/ext/zlib/tests/gzinflate_length.phpt @@ -13,13 +13,14 @@ if (strcmp($original,$unpacked)==0) echo "Strings are equal\n"; $unpacked=gzinflate($packed, strlen($original)*10); if (strcmp($original,$unpacked)==0) echo "Strings are equal\n"; -$unpacked=gzinflate($packed, 1); -if ($unpacked === false) echo "Failed (as expected)\n"; +try { + $unpacked=gzinflate($packed, 1); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- 5 15 Strings are equal Strings are equal - -Warning: gzinflate(): insufficient memory in %s on line %d -Failed (as expected) +insufficient memory diff --git a/ext/zlib/tests/gzopen_basic2.phpt b/ext/zlib/tests/gzopen_basic2.phpt index 2cb09af3ac176..597240b2a801b 100644 --- a/ext/zlib/tests/gzopen_basic2.phpt +++ b/ext/zlib/tests/gzopen_basic2.phpt @@ -13,20 +13,25 @@ $modes = array('w', 'w+'); $data = "This was the information that was written"; foreach($modes as $mode) { - echo "testing mode -- $mode --\n"; - $h = gzopen($filename, $mode); - if ($h !== false) { - gzwrite($h, $data); - gzclose($h); - $h = gzopen($filename, 'r'); - gzpassthru($h); - gzclose($h); - echo "\n"; - unlink($filename); - } - else { - var_dump($h); - } + echo "testing mode -- $mode --\n"; + $h = false; + try { + $h = gzopen($filename, $mode); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($h !== false) { + gzwrite($h, $data); + gzclose($h); + $h = gzopen($filename, 'r'); + gzpassthru($h); + gzclose($h); + echo "\n"; + unlink($filename); + } + else { + var_dump($h); + } } ?> @@ -35,6 +40,5 @@ foreach($modes as $mode) { testing mode -- w -- This was the information that was written testing mode -- w+ -- - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Cannot open a zlib stream for reading and writing at the same time! bool(false) diff --git a/ext/zlib/tests/gzopen_variation4.phpt b/ext/zlib/tests/gzopen_variation4.phpt index 1a33b63421253..3ea8306ab6687 100644 --- a/ext/zlib/tests/gzopen_variation4.phpt +++ b/ext/zlib/tests/gzopen_variation4.phpt @@ -31,42 +31,57 @@ function test_gzopen($mode) { global $scriptFile, $secondFile, $firstFile, $filename; // create a file in the middle directory - $h = gzopen($secondFile, "w"); - gzwrite($h, "This is a file in dir2"); - gzclose($h); + $handle = gzopen($secondFile, "w"); + gzwrite($handle, "This is a file in dir2"); + gzclose($handle); echo "\n** testing with mode=$mode **\n"; // should read dir2 file - $h = gzopen($filename, $mode, true); - if ($h) { - gzpassthru($h); - gzclose($h); + $handle = null; + try { + $handle = gzopen($filename, $mode, true); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($handle) { + gzpassthru($handle); + gzclose($handle); echo "\n"; } //create a file in dir1 - $h = gzopen($firstFile, "w"); - gzwrite($h, "This is a file in dir1"); - gzclose($h); + $handle = gzopen($firstFile, "w"); + gzwrite($handle, "This is a file in dir1"); + gzclose($handle); //should now read dir1 file - $h = gzopen($filename, $mode, true); - if ($h) { - gzpassthru($h); - gzclose($h); + $handle = null; + try { + $handle = gzopen($filename, $mode, true); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($handle) { + gzpassthru($handle); + gzclose($handle); echo "\n"; } // create a file in working directory - $h = gzopen($filename, "w"); - gzwrite($h, "This is a file in working dir"); - gzclose($h); + $handle = gzopen($filename, "w"); + gzwrite($handle, "This is a file in working dir"); + gzclose($handle); //should still read dir1 file - $h = gzopen($filename, $mode, true); - if ($h) { - gzpassthru($h); - gzclose($h); + $handle = null; + try { + $handle = gzopen($filename, $mode, true); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($handle) { + gzpassthru($handle); + gzclose($handle); echo "\n"; } @@ -74,23 +89,33 @@ function test_gzopen($mode) { unlink($secondFile); //should read the file in working dir - $h = gzopen($filename, $mode, true); - if ($h) { - gzpassthru($h); - gzclose($h); + $handle = null; + try { + $handle = gzopen($filename, $mode, true); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($handle) { + gzpassthru($handle); + gzclose($handle); echo "\n"; } // create a file in the script directory - $h = gzopen($scriptFile, "w"); - gzwrite($h, "This is a file in script dir"); - gzclose($h); + $handle = gzopen($scriptFile, "w"); + gzwrite($handle, "This is a file in script dir"); + gzclose($handle); //should read the file in script dir - $h = gzopen($filename, $mode, true); - if ($h) { - gzpassthru($h); - gzclose($h); + $handle = null; + try { + $handle = gzopen($filename, $mode, true); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } + if ($handle) { + gzpassthru($handle); + gzclose($handle); echo "\n"; } @@ -113,16 +138,11 @@ This is a file in working dir This is a file in script dir ** testing with mode=r+ ** - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Cannot open a zlib stream for reading and writing at the same time! +Cannot open a zlib stream for reading and writing at the same time! +Cannot open a zlib stream for reading and writing at the same time! +Cannot open a zlib stream for reading and writing at the same time! +Cannot open a zlib stream for reading and writing at the same time! ** testing with mode=rt ** This is a file in dir2 diff --git a/ext/zlib/tests/gzopen_variation9.phpt b/ext/zlib/tests/gzopen_variation9.phpt index 27198378bd447..f3dbb4d380b23 100644 --- a/ext/zlib/tests/gzopen_variation9.phpt +++ b/ext/zlib/tests/gzopen_variation9.phpt @@ -12,7 +12,12 @@ $file = __DIR__."/004.txt.gz"; foreach ($modes as $mode) { echo "mode=$mode\n"; - $h = gzopen($file, $mode); + $h = false; + try { + $h = gzopen($file, $mode); + } catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; + } echo "gzopen="; var_dump($h); if ($h !== false) { @@ -24,16 +29,14 @@ foreach ($modes as $mode) { --EXPECTF-- *** Testing gzopen() : variation *** mode=r+ - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Cannot open a zlib stream for reading and writing at the same time! gzopen=bool(false) mode=rf gzopen=resource(%d) of type (stream) mode=w+ - -Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d +Cannot open a zlib stream for reading and writing at the same time! gzopen=bool(false) mode=e diff --git a/ext/zlib/tests/gzseek_variation6.phpt b/ext/zlib/tests/gzseek_variation6.phpt index 45071193578b6..504c92f6594eb 100644 --- a/ext/zlib/tests/gzseek_variation6.phpt +++ b/ext/zlib/tests/gzseek_variation6.phpt @@ -12,7 +12,11 @@ gzread($h, 40); echo "tell="; var_dump(gztell($h)); echo "move to the end\n"; -var_dump(gzseek( $h, 0, SEEK_END ) ); +try { + var_dump(gzseek( $h, 0, SEEK_END ) ); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "tell="; var_dump(gztell($h)); echo "eof="; @@ -25,9 +29,7 @@ gzclose($h); move 40 bytes tell=int(40) move to the end - -Warning: gzseek(): SEEK_END is not supported in %s on line %d -int(-1) +SEEK_END is not supported tell=int(40) eof=bool(false) string(10) "iny flying" diff --git a/ext/zlib/tests/gzseek_variation7.phpt b/ext/zlib/tests/gzseek_variation7.phpt index 01994514a25b8..bf23dcc0dc563 100644 --- a/ext/zlib/tests/gzseek_variation7.phpt +++ b/ext/zlib/tests/gzseek_variation7.phpt @@ -14,7 +14,11 @@ var_dump(gztell($h)); //seek to the end which is not sensible of course. echo "move to the end of the file\n"; -var_dump(gzseek($h, 0, SEEK_END)); +try { + var_dump(gzseek($h, 0, SEEK_END)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "tell="; var_dump(gztell($h)); gzwrite($h, $str2); @@ -31,9 +35,7 @@ unlink($f); --EXPECTF-- tell=int(23) move to the end of the file - -Warning: gzseek(): SEEK_END is not supported in %s on line %d -int(-1) +SEEK_END is not supported tell=int(23) tell=int(47) diff --git a/ext/zlib/tests/gzuncompress_error1.phpt b/ext/zlib/tests/gzuncompress_error1.phpt index b5fe388c9e72a..ef6b0b8c96eba 100644 --- a/ext/zlib/tests/gzuncompress_error1.phpt +++ b/ext/zlib/tests/gzuncompress_error1.phpt @@ -11,21 +11,25 @@ $data = 'string_val'; $short_len = strlen($data) - 1; $compressed = gzcompress($data); -var_dump(gzuncompress($compressed, $short_len)); +try { + var_dump(gzuncompress($compressed, $short_len)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "\n-- Testing with incorrect arguments --\n"; -var_dump(gzuncompress(123)); +try { + var_dump(gzuncompress(123)); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- *** Testing gzuncompress() : error conditions *** -- Testing with a buffer that is too small -- - -Warning: gzuncompress(): insufficient memory in %s on line %d -bool(false) +insufficient memory -- Testing with incorrect arguments -- - -Warning: gzuncompress(): data error in %s on line %d -bool(false) +data error diff --git a/ext/zlib/tests/zlib_filter_inflate2.phpt b/ext/zlib/tests/zlib_filter_inflate2.phpt index a135bfe3b347f..6605010f0faab 100644 --- a/ext/zlib/tests/zlib_filter_inflate2.phpt +++ b/ext/zlib/tests/zlib_filter_inflate2.phpt @@ -11,7 +11,11 @@ fclose($a); $fp = fopen(__DIR__ . '/test.txt.gz', 'r'); stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ); -echo fread($fp, 2000); +try { + echo fread($fp, 2000); +} catch (\Throwable $e) { + echo $e->getMessage() . \PHP_EOL; +} fclose($fp); echo "1\n"; $fp = fopen(__DIR__ . '/test.txt.gz', 'r'); @@ -34,7 +38,7 @@ fclose($fp); @unlink(__DIR__ . '/test.txt.gz'); ?> --EXPECTF-- -Notice: fread(): zlib: data error in %s on line %d +zlib: data error 1 2 This is quite the thing ain't it diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 8b593f1f451b0..e93bdd3b42967 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -412,7 +412,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod } } - php_error_docref(NULL, E_WARNING, "%s", zError(status)); + zend_throw_error(NULL, "%s", zError(status)); return NULL; } /* }}} */ @@ -503,7 +503,7 @@ static int php_zlib_decode(const char *in_buf, size_t in_len, char **out_buf, si *out_buf = NULL; *out_len = 0; - php_error_docref(NULL, E_WARNING, "%s", zError(status)); + zend_throw_error(NULL, "%s", zError(status)); return FAILURE; } /* }}} */ @@ -914,8 +914,8 @@ PHP_FUNCTION(inflate_init) if (inflateInit2(&ctx->Z, encoding) != Z_OK) { zval_ptr_dtor(return_value); - php_error_docref(NULL, E_WARNING, "Failed allocating zlib.inflate context"); - RETURN_FALSE; + zend_throw_error(NULL, "Failed allocating zlib.inflate context"); + RETURN_THROWS(); } if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) { @@ -925,9 +925,10 @@ PHP_FUNCTION(inflate_init) ctx->inflateDict = NULL; break; case Z_DATA_ERROR: - php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); + zend_throw_error(NULL, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); efree(ctx->inflateDict); ctx->inflateDict = NULL; + RETURN_THROWS(); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -1024,19 +1025,19 @@ PHP_FUNCTION(inflate_add) efree(ctx->inflateDict); ctx->inflateDict = NULL; zend_string_release_ex(out, 0); - php_error_docref(NULL, E_WARNING, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); - RETURN_FALSE; + zend_throw_error(NULL, "Dictionary does not match expected dictionary (incorrect adler32 hash)"); + RETURN_THROWS(); EMPTY_SWITCH_DEFAULT_CASE() } break; } else { - php_error_docref(NULL, E_WARNING, "Inflating this data requires a preset dictionary, please specify it in the options array of inflate_init()"); - RETURN_FALSE; + zend_throw_error(NULL, "Inflating this data requires a preset dictionary, please specify it in the options array of inflate_init()"); + RETURN_THROWS(); } default: zend_string_release_ex(out, 0); - php_error_docref(NULL, E_WARNING, "%s", zError(status)); - RETURN_FALSE; + zend_throw_error(NULL, "%s", zError(status)); + RETURN_THROWS(); } } while (1); @@ -1160,8 +1161,8 @@ PHP_FUNCTION(deflate_init) if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) { zval_ptr_dtor(return_value); - php_error_docref(NULL, E_WARNING, "Failed allocating zlib.deflate context"); - RETURN_FALSE; + zend_throw_error(NULL, "Failed allocating zlib.deflate context"); + RETURN_THROWS(); } if (dict) { @@ -1248,8 +1249,8 @@ PHP_FUNCTION(deflate_add) break; default: zend_string_release_ex(out, 0); - php_error_docref(NULL, E_WARNING, "zlib error (%s)", zError(status)); - RETURN_FALSE; + zend_throw_error(NULL, "zlib error (%s)", zError(status)); + RETURN_THROWS(); } } /* }}} */ diff --git a/ext/zlib/zlib.stub.php b/ext/zlib/zlib.stub.php index 1083564f76505..85c8dec165032 100644 --- a/ext/zlib/zlib.stub.php +++ b/ext/zlib/zlib.stub.php @@ -270,13 +270,13 @@ function gzread($stream, int $length): string|false {} */ function gzgets($stream, ?int $length = null): string|false {} -function deflate_init(int $encoding, array $options = []): DeflateContext|false {} +function deflate_init(int $encoding, array $options = []): DeflateContext {} -function deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {} +function deflate_add(DeflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string {} -function inflate_init(int $encoding, array $options = []): InflateContext|false {} +function inflate_init(int $encoding, array $options = []): InflateContext {} -function inflate_add(InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string|false {} +function inflate_add(InflateContext $context, string $data, int $flush_mode = ZLIB_SYNC_FLUSH): string {} function inflate_get_status(InflateContext $context): int {} diff --git a/ext/zlib/zlib_arginfo.h b/ext/zlib/zlib_arginfo.h index 743662fd036bd..e3d43234e96a8 100644 --- a/ext/zlib/zlib_arginfo.h +++ b/ext/zlib/zlib_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3660ad3239f93c84b6909c36ddfcc92dd0773c70 */ + * Stub hash: d1cc7df4fbc9df0b7b92b83898632187d62dcd44 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_gzhandler, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) @@ -104,23 +104,23 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzgets, 0, 1, MAY_BE_STRING|MAY_ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_deflate_init, 0, 1, DeflateContext, MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_deflate_init, 0, 1, DeflateContext, 0) ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_deflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_deflate_add, 0, 2, IS_STRING, 0) ZEND_ARG_OBJ_INFO(0, context, DeflateContext, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flush_mode, IS_LONG, 0, "ZLIB_SYNC_FLUSH") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_inflate_init, 0, 1, InflateContext, MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_inflate_init, 0, 1, InflateContext, 0) ZEND_ARG_TYPE_INFO(0, encoding, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_inflate_add, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_inflate_add, 0, 2, IS_STRING, 0) ZEND_ARG_OBJ_INFO(0, context, InflateContext, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flush_mode, IS_LONG, 0, "ZLIB_SYNC_FLUSH") diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index 24d418ae04cfa..3935da269f1a1 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -90,7 +90,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( exit_status = PSFS_PASS_ON; } else if (status != Z_OK && status != Z_BUF_ERROR) { /* Something bad happened */ - php_error_docref(NULL, E_NOTICE, "zlib: %s", zError(status)); + zend_throw_error(NULL, "zlib: %s", zError(status)); php_stream_bucket_delref(bucket); /* reset these because despite the error the filter may be used again */ data->strm.next_in = data->inbuf; @@ -289,7 +289,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* Create this filter */ data = pecalloc(1, sizeof(php_zlib_filter_data), persistent); if (!data) { - php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data)); + zend_throw_error(NULL, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data)); return NULL; } @@ -301,14 +301,14 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f data->strm.avail_out = data->outbuf_len = data->inbuf_len = 0x8000; data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent); if (!data->inbuf) { - php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len); + zend_throw_error(NULL, "Failed allocating %zd bytes", data->inbuf_len); pefree(data, persistent); return NULL; } data->strm.avail_in = 0; data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent); if (!data->outbuf) { - php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len); + zend_throw_error(NULL, "Failed allocating %zd bytes", data->outbuf_len); pefree(data->inbuf, persistent); pefree(data, persistent); return NULL; @@ -327,7 +327,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* log-2 base of history window (9 - 15) */ zend_long tmp = zval_get_long(tmpzval); if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 32) { - php_error_docref(NULL, E_WARNING, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp); + zend_throw_error(NULL, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp); } else { windowBits = tmp; } @@ -359,7 +359,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* Memory Level (1 - 9) */ tmp = zval_get_long(tmpzval); if (tmp < 1 || tmp > MAX_MEM_LEVEL) { - php_error_docref(NULL, E_WARNING, "Invalid parameter given for memory level (" ZEND_LONG_FMT ")", tmp); + zend_throw_error(NULL, "Invalid parameter given for memory level (" ZEND_LONG_FMT ")", tmp); } else { memLevel = tmp; } @@ -369,7 +369,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* log-2 base of history window (9 - 15) */ tmp = zval_get_long(tmpzval); if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 16) { - php_error_docref(NULL, E_WARNING, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp); + zend_throw_error(NULL, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp); } else { windowBits = tmp; } @@ -389,13 +389,13 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f factory_setlevel: /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */ if (tmp < -1 || tmp > 9) { - php_error_docref(NULL, E_WARNING, "Invalid compression level specified. (" ZEND_LONG_FMT ")", tmp); + zend_throw_error(NULL, "Invalid compression level specified. (" ZEND_LONG_FMT ")", tmp); } else { level = tmp; } break; default: - php_error_docref(NULL, E_WARNING, "Invalid filter parameter, ignored"); + zend_throw_error(NULL, "Invalid filter parameter, ignored"); } } status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0); diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index b414b33a8724e..d903293abf75d 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -60,7 +60,7 @@ static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zen assert(self != NULL); if (whence == SEEK_END) { - php_error_docref(NULL, E_WARNING, "SEEK_END is not supported"); + zend_throw_error(NULL, "SEEK_END is not supported"); return -1; } *newoffs = gzseek(self->gz_file, offset, whence); @@ -114,7 +114,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, con /* sanity check the stream: it can be either read-only or write-only */ if (strchr(mode, '+')) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "Cannot open a zlib stream for reading and writing at the same time!"); + zend_throw_error(NULL, "Cannot open a zlib stream for reading and writing at the same time!"); } return NULL; } @@ -152,7 +152,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, con efree(self); if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "gzopen failed"); + zend_throw_error(NULL, "gzopen failed"); } }