diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index f11e121bb386d..baae757154950 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -343,6 +343,13 @@ PHP_FUNCTION(finfo_buffer) RETURN_THROWS(); } + if (ZEND_NUM_ARGS() == 4 || (hasThis() && ZEND_NUM_ARGS() == 3)) { + php_error_docref(NULL, E_DEPRECATED, "The $context parameter has no effect for finfo_buffer()"); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } + } + if (!Z_FINFO_P(self)->magic) { zend_throw_error(NULL, "Invalid finfo object"); RETURN_THROWS(); diff --git a/ext/fileinfo/tests/finfo_buffer_deprecated_context_param.phpt b/ext/fileinfo/tests/finfo_buffer_deprecated_context_param.phpt new file mode 100644 index 0000000000000..ef4c736999d80 --- /dev/null +++ b/ext/fileinfo/tests/finfo_buffer_deprecated_context_param.phpt @@ -0,0 +1,20 @@ +--TEST-- +finfo_buffer() deprecated $context param +--EXTENSIONS-- +fileinfo +--FILE-- +buffer($buffer, FILEINFO_NONE, null)); + +?> +--EXPECTF-- +Deprecated: finfo_buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d +string(36) "ASCII text, with no line terminators" + +Deprecated: finfo::buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d +string(36) "ASCII text, with no line terminators" diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 68fd2dedfba85..28debad4133c4 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -98,10 +98,24 @@ const char *intl_locale_get_default( void ) return INTL_G(default_locale); } +static PHP_INI_MH(OnUpdateErrorLevel) +{ + zend_long *p = (zend_long *) ZEND_INI_GET_ADDR(); + *p = zend_ini_parse_quantity_warn(new_value, entry->name); + if (*p) { + php_error_docref("session.configuration", E_DEPRECATED, + "Using a value different than 0 for intl.error_level is deprecated," + " as the intl.error_level INI setting is deprecated." + " Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors" + " or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors"); + } + return SUCCESS; +} + /* {{{ INI Settings */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals) - STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals) + STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateErrorLevel, error_level, zend_intl_globals, intl_globals) STD_PHP_INI_BOOLEAN("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals) PHP_INI_END() /* }}} */ diff --git a/ext/intl/tests/gh17469.phpt b/ext/intl/tests/gh17469.phpt index ab222ff89f428..5a22636844227 100644 --- a/ext/intl/tests/gh17469.phpt +++ b/ext/intl/tests/gh17469.phpt @@ -28,9 +28,10 @@ try { } ?> --EXPECTF-- +Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d -Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line 5 +Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in %s on line %d UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt index b6471795dd7be..e03c991ae05f2 100644 --- a/ext/intl/tests/ini_use_exceptions_basic.phpt +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -18,5 +18,7 @@ var_dump($t->transliterate('a', 3)); --EXPECTF-- string(133) "Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" +Deprecated: ini_set(): Using a value different than 0 for intl.error_level is deprecated, as the intl.error_level INI setting is deprecated. Instead the intl.use_exceptions INI setting should be enabled to throw exceptions on errors or intl_get_error_code()/intl_get_error_message() should be used to manually deal with errors in %s on line %d + Notice: Transliterator::transliterate(): Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d bool(false) diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt index 62e68938ae845..1e6791a172ca6 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error_64bit.phpt @@ -14,4 +14,4 @@ try { } ?> --EXPECT-- -ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #1 ($type) must be between -2147483648 and 2147483647 +ValueError: IntlTimeZone::createTimeZoneIDEnumeration(): Argument #3 ($rawOffset) must be between -2147483648 and 2147483647 diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt index 8acf604ec7f06..6c53055086f0b 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt @@ -4,7 +4,6 @@ IntlTimeZone::createTimeZoneIDEnumeration(): variant without region intl --FILE-- initialized) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "DateTimeZone object is unconstructed"); - RETURN_NULL(); + zend_throw_error(NULL, "DateTimeZone object is unconstructed"); + RETURN_THROWS(); } tz = timezone_convert_datetimezone(tzobj->type, tzobj, false, NULL); @@ -209,7 +208,7 @@ U_CFUNC PHP_FUNCTION(intltz_create_time_zone_id_enumeration) if (!arg3isnull) { if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(offset_arg))) { - zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX); + zend_argument_value_error(3, "must be between %d and %d", INT32_MIN, INT32_MAX); RETURN_THROWS(); } offset = static_cast(offset_arg); @@ -311,8 +310,9 @@ U_CFUNC PHP_FUNCTION(intltz_get_equivalent_id) Z_PARAM_LONG(index) ZEND_PARSE_PARAMETERS_END(); - if (UNEXPECTED(index < (zend_long)INT32_MIN || index > (zend_long)INT32_MAX)) { - RETURN_FALSE; + if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(index))) { + zend_argument_value_error(2, "must be between %d and %d", INT32_MIN, INT32_MAX); + RETURN_THROWS(); } UErrorCode status = UErrorCode(); diff --git a/ext/openssl/openssl_backend_common.c b/ext/openssl/openssl_backend_common.c index 272ebd6915a46..1cf82ee3c810e 100644 --- a/ext/openssl/openssl_backend_common.c +++ b/ext/openssl/openssl_backend_common.c @@ -1344,13 +1344,20 @@ EVP_PKEY *php_openssl_pkey_from_zval( return key; } -zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t key_size) -{ - EVP_PKEY_CTX *ctx = php_openssl_pkey_new_from_pkey(key); +zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t requested_key_size) { + size_t key_size = requested_key_size; + EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new(key, NULL); if (!ctx) { return NULL; } +#if OPENSSL_VERSION_NUMBER < 0x30000000L + /* OpenSSL 1.1 does not respect key_size for DH, so force size discovery so it can be compared later. */ + if (EVP_PKEY_base_id(key) == EVP_PKEY_DH && key_size != 0) { + key_size = 0; + } +#endif + if (EVP_PKEY_derive_init(ctx) <= 0 || EVP_PKEY_derive_set_peer(ctx, peer_key) <= 0 || (key_size == 0 && EVP_PKEY_derive(ctx, NULL, &key_size) <= 0)) { @@ -1359,6 +1366,14 @@ zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t k return NULL; } +#if OPENSSL_VERSION_NUMBER < 0x30000000L + /* Now compare the computed size for DH to mirror OpenSSL 3.0+ behavior. */ + if (EVP_PKEY_base_id(key) == EVP_PKEY_DH && requested_key_size > 0 && requested_key_size < key_size) { + EVP_PKEY_CTX_free(ctx); + return NULL; + } +#endif + zend_string *result = zend_string_alloc(key_size, 0); if (EVP_PKEY_derive(ctx, (unsigned char *)ZSTR_VAL(result), &key_size) <= 0) { php_openssl_store_errors(); diff --git a/ext/openssl/php_openssl_backend.h b/ext/openssl/php_openssl_backend.h index 86111e2997d1a..50f18e171c2fa 100644 --- a/ext/openssl/php_openssl_backend.h +++ b/ext/openssl/php_openssl_backend.h @@ -190,7 +190,7 @@ X509_STORE * php_openssl_setup_verify(zval * calist, uint32_t arg_num); STACK_OF(X509) * php_openssl_load_all_certs_from_file( char *cert_file, size_t cert_file_len, uint32_t arg_num); EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req); -zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t key_size); +zend_string *php_openssl_pkey_derive(EVP_PKEY *key, EVP_PKEY *peer_key, size_t requested_key_size); #define PHP_SSL_REQ_INIT(req) memset(req, 0, sizeof(*req)) #define PHP_SSL_REQ_DISPOSE(req) php_openssl_dispose_config(req) diff --git a/ext/openssl/tests/gh19428.phpt b/ext/openssl/tests/gh19428.phpt new file mode 100644 index 0000000000000..5d290f32e62a5 --- /dev/null +++ b/ext/openssl/tests/gh19428.phpt @@ -0,0 +1,44 @@ +--TEST-- +GH-19428: openssl_pkey_derive() DH with low key_length +--EXTENSIONS-- +openssl +--FILE-- + +--EXPECT-- +bool(false) diff --git a/ext/standard/dir.c b/ext/standard/dir.c index cced88e4ac8a5..2eb9d853eeb16 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -160,6 +160,8 @@ PHP_FUNCTION(dir) static php_stream* php_dir_get_directory_stream_from_user_arg(php_stream *dir_stream) { if (dir_stream == NULL) { + php_error_docref(NULL, E_DEPRECATED, + "Passing null is deprecated, instead the last opened directory stream should be provided"); if (UNEXPECTED(DIRG(default_dir) == NULL)) { zend_type_error("No resource supplied"); return NULL; diff --git a/ext/standard/tests/dir/closedir_basic-win32-mb.phpt b/ext/standard/tests/dir/closedir_basic-win32-mb.phpt index 05cb1889c9485..3754963a85009 100644 --- a/ext/standard/tests/dir/closedir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/closedir_basic-win32-mb.phpt @@ -44,6 +44,8 @@ rmdir($dir_path); *** Testing closedir() : basic functionality *** -- Call closedir() with no arguments: -- + +Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d NULL -- Check Directory Handle: -- resource(%d) of type (Unknown) diff --git a/ext/standard/tests/dir/closedir_basic.phpt b/ext/standard/tests/dir/closedir_basic.phpt index aa4be6fbaf279..82065f01419ab 100644 --- a/ext/standard/tests/dir/closedir_basic.phpt +++ b/ext/standard/tests/dir/closedir_basic.phpt @@ -38,6 +38,8 @@ rmdir($dir_path); *** Testing closedir() : basic functionality *** -- Call closedir() with no arguments: -- + +Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d NULL -- Check Directory Handle: -- resource(%d) of type (Unknown) diff --git a/ext/standard/tests/dir/closedir_without_arg.phpt b/ext/standard/tests/dir/closedir_without_arg.phpt index 27884c1a2b645..f248764ed2a69 100644 --- a/ext/standard/tests/dir/closedir_without_arg.phpt +++ b/ext/standard/tests/dir/closedir_without_arg.phpt @@ -8,5 +8,6 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d No resource supplied diff --git a/ext/standard/tests/dir/readdir_basic-win32-mb.phpt b/ext/standard/tests/dir/readdir_basic-win32-mb.phpt index d7e0804d57b35..dd97566db0796 100644 --- a/ext/standard/tests/dir/readdir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_basic-win32-mb.phpt @@ -65,6 +65,18 @@ string(9) "file3.tmp" -- Call readdir() without $path argument -- resource(%d) of type (stream) + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d string(1) "." string(2) ".." string(9) "file1.tmp" diff --git a/ext/standard/tests/dir/readdir_basic.phpt b/ext/standard/tests/dir/readdir_basic.phpt index 01ddd694adcbf..fbabfc6e9b2b3 100644 --- a/ext/standard/tests/dir/readdir_basic.phpt +++ b/ext/standard/tests/dir/readdir_basic.phpt @@ -59,6 +59,18 @@ string(9) "file3.tmp" -- Call readdir() without $path argument -- resource(%d) of type (stream) + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d string(1) "." string(2) ".." string(9) "file1.tmp" diff --git a/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt b/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt index 91062e76bd4f9..c2bfe7d1a2b4a 100644 --- a/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt @@ -61,7 +61,7 @@ closedir(); $dir_path = __DIR__ . "/私はガラスを食べられますreaddir_variation6"; rmdir($dir_path); ?> ---EXPECT-- +--EXPECTF-- *** Testing readdir() : usage variations *** -- Reading Directory Contents with Previous Handle -- @@ -72,8 +72,22 @@ string(59) "私はガラスを食べられますreaddir_variation62.tmp" string(59) "私はガラスを食べられますreaddir_variation63.tmp" -- Reading Directory Contents with Current Handle (no arguments supplied) -- + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d string(1) "." string(2) ".." string(59) "私はガラスを食べられますreaddir_variation61.tmp" string(59) "私はガラスを食べられますreaddir_variation62.tmp" string(59) "私はガラスを食べられますreaddir_variation63.tmp" + +Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d diff --git a/ext/standard/tests/dir/readdir_variation6.phpt b/ext/standard/tests/dir/readdir_variation6.phpt index b017789f31ac8..9865a1d4fc608 100644 --- a/ext/standard/tests/dir/readdir_variation6.phpt +++ b/ext/standard/tests/dir/readdir_variation6.phpt @@ -55,7 +55,7 @@ closedir(); $dir_path = __DIR__ . "/readdir_variation6"; rmdir($dir_path); ?> ---EXPECT-- +--EXPECTF-- *** Testing readdir() : usage variations *** -- Reading Directory Contents with Previous Handle -- @@ -66,8 +66,22 @@ string(23) "readdir_variation62.tmp" string(23) "readdir_variation63.tmp" -- Reading Directory Contents with Current Handle (no arguments supplied) -- + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d string(1) "." string(2) ".." string(23) "readdir_variation61.tmp" string(23) "readdir_variation62.tmp" string(23) "readdir_variation63.tmp" + +Deprecated: closedir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d diff --git a/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt b/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt index a20501d3caded..2ec56418c85bf 100644 --- a/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt @@ -82,6 +82,14 @@ NULL bool(true) -- Read and rewind second directory (no argument supplied) -- + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d array(3) { [0]=> string(1) "." @@ -90,5 +98,9 @@ array(3) { [2]=> string(45) "私はガラスを食べられますfile2.tmp" } + +Deprecated: rewinddir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d NULL + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d bool(true) diff --git a/ext/standard/tests/dir/rewinddir_basic.phpt b/ext/standard/tests/dir/rewinddir_basic.phpt index faee6b9bd64a4..106c00051d6e7 100644 --- a/ext/standard/tests/dir/rewinddir_basic.phpt +++ b/ext/standard/tests/dir/rewinddir_basic.phpt @@ -76,6 +76,14 @@ NULL bool(true) -- Read and rewind second directory (no argument supplied) -- + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d array(3) { [0]=> string(1) "." @@ -84,5 +92,9 @@ array(3) { [2]=> string(9) "file2.tmp" } + +Deprecated: rewinddir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d NULL + +Deprecated: readdir(): Passing null is deprecated, instead the last opened directory stream should be provided in %s on line %d bool(true) diff --git a/php.ini-development b/php.ini-development index 2d3c8bf32a5d9..b6b2ee40a8bc2 100644 --- a/php.ini-development +++ b/php.ini-development @@ -1021,8 +1021,12 @@ cli_server.color = On ; This directive allows you to produce PHP errors when some error ; happens within intl functions. The value is the level of the error produced. ; Default is 0, which does not produce any errors. +; This directive is deprecated. ;intl.error_level = E_WARNING -;intl.use_exceptions = 0 +; If enabled this directive indicates that when an error occurs within an +; intl function a IntlException should be thrown. +; Default is Off, which means errors need to be handled manually. +;intl.use_exceptions = On [sqlite3] ; Directory pointing to SQLite3 extensions diff --git a/php.ini-production b/php.ini-production index 13d3f66c93c4f..c363bcb6e5fa3 100644 --- a/php.ini-production +++ b/php.ini-production @@ -1023,8 +1023,12 @@ cli_server.color = On ; This directive allows you to produce PHP errors when some error ; happens within intl functions. The value is the level of the error produced. ; Default is 0, which does not produce any errors. +; This directive is deprecated. ;intl.error_level = E_WARNING -;intl.use_exceptions = 0 +; If enabled this directive indicates that when an error occurs within an +; intl function a IntlException should be thrown. +; Default is Off, which means errors need to be handled manually. +;intl.use_exceptions = On [sqlite3] ; Directory pointing to SQLite3 extensions