[php-src] master: bz2: deprecate passing objects as array

From: Date: Mon, 10 Aug 2026 17:21:43 +0000
Subject: [php-src] master: bz2: deprecate passing objects as array
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140602@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-08-10T18:21:19+01:00 Commit: https://github.com/php/php-src/commit/3fda4e9c187929cb95d0eec90c7fcd82e4161600 Raw diff: https://github.com/php/php-src/commit/3fda4e9c187929cb95d0eec90c7fcd82e4161600.diff bz2: deprecate passing objects as array RFC: https://wiki.php.net/rfc/deprecations_php_8_6#passing_objects_as_parameters_to_the_bzip2decompress_and_bzip2compress_stream_filters Changed paths: M ext/bz2/bz2_filter.c M ext/bz2/tests/filter_broken_object_options.phpt Diff: diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c index 845c11865f15..47fc9fc6e62f 100644 --- a/ext/bz2/bz2_filter.c +++ b/ext/bz2/bz2_filter.c @@ -402,12 +402,19 @@ static php_stream_filter *php_bz2_decompress_filter_create(zval *filter_params, && Z_TYPE_P(filter_params) != IS_ARRAY && Z_TYPE_P(filter_params) != IS_OBJECT )) { - php_error_docref(NULL, E_WARNING, + php_error_docref("filters.compression", E_WARNING, "Filter parameters for bzip2.decompress filter must be of type array|object|bool, %s given", zend_zval_type_name(filter_params) ); return NULL; } + if (Z_TYPE_P(filter_params) == IS_OBJECT) { + php_error_docref("filters.compression", E_DEPRECATED, + "Passing an object for filter parameters for bzip2.decompress is deprecated, call get_object_vars() first instead"); + if (UNEXPECTED(EG(exception))) { + return NULL; + } + } if (Z_TYPE_P(filter_params) == IS_TRUE || Z_TYPE_P(filter_params) == IS_FALSE) { small_footprint = Z_TYPE_P(filter_params) == IS_TRUE; @@ -448,12 +455,19 @@ static php_stream_filter *php_bz2_compress_filter_create(zval *filter_params, bo if (filter_params) { if (UNEXPECTED(Z_TYPE_P(filter_params) != IS_ARRAY && Z_TYPE_P(filter_params) != IS_OBJECT)) { - php_error_docref(NULL, E_WARNING, + php_error_docref("filters.compression", E_WARNING, "Filter parameters for bzip2.compress filter must be of type array|object, %s given", zend_zval_type_name(filter_params) ); return NULL; } + if (Z_TYPE_P(filter_params) == IS_OBJECT) { + php_error_docref("filters.compression", E_DEPRECATED, + "Passing an object for filter parameters for bzip2.compress is deprecated, call get_object_vars() first instead"); + if (UNEXPECTED(EG(exception))) { + return NULL; + } + } const HashTable *filter_params_ht = HASH_OF(filter_params); /* TODO: convert php_stream_filter_parse_write_seek_mode() to take HashTable */ @@ -468,10 +482,10 @@ static php_stream_filter *php_bz2_compress_filter_create(zval *filter_params, bo /* How much memory to allocate (1 - 9) x 100kb */ zend_long blocks = zval_try_get_long(blocks_zv, &failed); if (UNEXPECTED(failed)) { - php_error_docref(NULL, E_WARNING, "Number of blocks parameter must be of type int, %s given", zend_zval_type_name(blocks_zv)); + php_error_docref("filters.compression", E_WARNING, "Number of blocks parameter must be of type int, %s given", zend_zval_type_name(blocks_zv)); return NULL; } else if (blocks < 1 || blocks > 9) { - php_error_docref(NULL, E_WARNING, "Number of blocks to allocate must be between 1 and 9, " ZEND_LONG_FMT " given", blocks); + php_error_docref("filters.compression", E_WARNING, "Number of blocks to allocate must be between 1 and 9, " ZEND_LONG_FMT " given", blocks); return NULL; } else { blockSize100k = (int) blocks; @@ -485,10 +499,10 @@ static php_stream_filter *php_bz2_compress_filter_create(zval *filter_params, bo /* Work Factor (0 - 250) */ zend_long work = zval_try_get_long(work_zv, &failed); if (UNEXPECTED(failed)) { - php_error_docref(NULL, E_WARNING, "Work factor parameter must be of type int, %s given", zend_zval_type_name(work_zv)); + php_error_docref("filters.compression", E_WARNING, "Work factor parameter must be of type int, %s given", zend_zval_type_name(work_zv)); return NULL; } else if (work < 0 || work > 250) { - php_error_docref(NULL, E_WARNING, "Work factor must be between 0 and 250, " ZEND_LONG_FMT " given", work); + php_error_docref("filters.compression", E_WARNING, "Work factor must be between 0 and 250, " ZEND_LONG_FMT " given", work); return NULL; } else { workFactor = (int) work; diff --git a/ext/bz2/tests/filter_broken_object_options.phpt b/ext/bz2/tests/filter_broken_object_options.phpt index 84e49a64ccb6..c24e2893c2b9 100644 --- a/ext/bz2/tests/filter_broken_object_options.phpt +++ b/ext/bz2/tests/filter_broken_object_options.phpt @@ -21,5 +21,8 @@ stream_filter_append($fp, 'bzip2.decompress', STREAM_FILTER_WRITE, new ParamsDec fwrite($fp, "Hello world, hopefully not broken\n"); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: stream_filter_append(): Passing an object for filter parameters for bzip2.compress is deprecated, call get_object_vars() first instead in %s on line %d + +Deprecated: stream_filter_append(): Passing an object for filter parameters for bzip2.decompress is deprecated, call get_object_vars() first instead in %s on line %d Hello world, hopefully not broken

« previous php.cvs (#140602) next »