Skip to content

Convert resources to objects in ext/zlib #5680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ PHP 8.0 UPGRADE NOTES

- Sysvmsg:
. msg_get_queue() will now return an SysvMessageQueue object rather than a
resource. Return value checks using is_resource() should be replaced with
resource. Return value checks using is_resource() should be replaced with
checks for `false`.

- Sysvsem:
Expand Down Expand Up @@ -469,6 +469,12 @@ PHP 8.0 UPGRADE NOTES

- Zlib:
. gzgetss() has been removed.
. inflate_init() will now return an InflateContext object rather than a
resource. Return value checks using is_resource() should be replaced with
checks for `false`.
. deflate_init() will now return a DeflateContext object rather than a
resource. Return value checks using is_resource() should be replaced with
checks for `false`.

========================================
2. New Features
Expand Down
1 change: 1 addition & 0 deletions ext/zlib/php_zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef struct _php_zlib_context {
int status;
size_t inflateDictlen;
php_zlib_buffer buffer;
zend_object std;
} php_zlib_context;
Copy link
Member Author

@kocsismate kocsismate Jun 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, the same data structure is used during inflation and deflation... Which leads to the question if we should separate it to a zlib_inflate_context and a zlib_deflate_context?


ZEND_BEGIN_MODULE_GLOBALS(zlib)
Expand Down
4 changes: 2 additions & 2 deletions ext/zlib/tests/deflate_add_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ try {

?>
--EXPECT--
deflate_add(): supplied resource is not a valid zlib deflate resource
Flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH
deflate_add(): Argument #1 ($context) must be of type DeflateContext, resource given
deflate_add(): Argument #3 ($flush_behavior) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll commit these error message changes separately

10 changes: 5 additions & 5 deletions ext/zlib/tests/deflate_init_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ try {

?>
--EXPECT--
Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE
Compression level (42) must be within -1..9
Compression level (-2) must be within -1..9
Compression memory level (0) must be within 1..9
Compression memory level (10) must be within 1..9
deflate_init(): Argument #1 ($encoding) must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
deflate_init(): "level" option must be between -1 and 9
deflate_init(): "level" option must be between -1 and 9
deflate_init(): "memory" option must be between 1 and 9
deflate_init(): "memory" option must be between 1 and 9
1 change: 0 additions & 1 deletion ext/zlib/tests/dictionary_usage.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var_dump($dictStr_a === $a);
$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));

Expand Down
4 changes: 2 additions & 2 deletions ext/zlib/tests/inflate_add_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ try {

?>
--EXPECT--
inflate_add(): supplied resource is not a valid zlib inflate resource
Flush mode must be ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK or ZLIB_FINISH
inflate_add(): Argument #1 ($context) must be of type InflateContext, resource given
inflate_add(): Argument #3 ($flush_mode) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, ZLIB_FINISH
Loading