1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Deprecate mhash

Deprecate mhash(), mhash_keygen_s2k(), mhash_count(),
mhash_get_block_size() and mhash_get_hash_name() in favor of the
normal hash_*() functions.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
This commit is contained in:
Nikita Popov
2021-07-08 12:14:25 +02:00
parent 1c50784ae7
commit bf0c1ce1a0
7 changed files with 66 additions and 9 deletions

View File

@@ -337,6 +337,12 @@ PHP 8.1 UPGRADE NOTES
favor of date_sun_info().
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
- Hash:
. The mhash(), mhash_keygen_s2k(), mhash_count(), mhash_get_block_size() and
mhash_get_hash_name() functions are deprecated. Use the hash_*() APIs
instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
- Intl:
. Calling IntlCalendar::roll() with bool argument is deprecated. Pass 1 and -1
instead of true and false respectively.

View File

@@ -34,14 +34,19 @@ function hash_equals(string $known_string, string $user_string): bool {}
function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = ""): string {}
#ifdef PHP_MHASH_BC
/** @deprecated */
function mhash_get_block_size(int $algo): int|false {}
/** @deprecated */
function mhash_get_hash_name(int $algo): string|false {}
/** @deprecated */
function mhash_keygen_s2k(int $algo, string $password, string $salt, int $length): string|false {}
/** @deprecated */
function mhash_count(): int {}
/** @deprecated */
function mhash(int $algo, string $data, ?string $key = null): string|false {}
#endif

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3973a03a64b0939de0c3677da55a5104c29b1b99 */
* Stub hash: 8c35168fb1c95e76c5c77fd0c0e8d295e13a0414 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
@@ -180,19 +180,19 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(hash_equals, arginfo_hash_equals)
ZEND_FE(hash_hkdf, arginfo_hash_hkdf)
#if defined(PHP_MHASH_BC)
ZEND_FE(mhash_get_block_size, arginfo_mhash_get_block_size)
ZEND_DEP_FE(mhash_get_block_size, arginfo_mhash_get_block_size)
#endif
#if defined(PHP_MHASH_BC)
ZEND_FE(mhash_get_hash_name, arginfo_mhash_get_hash_name)
ZEND_DEP_FE(mhash_get_hash_name, arginfo_mhash_get_hash_name)
#endif
#if defined(PHP_MHASH_BC)
ZEND_FE(mhash_keygen_s2k, arginfo_mhash_keygen_s2k)
ZEND_DEP_FE(mhash_keygen_s2k, arginfo_mhash_keygen_s2k)
#endif
#if defined(PHP_MHASH_BC)
ZEND_FE(mhash_count, arginfo_mhash_count)
ZEND_DEP_FE(mhash_count, arginfo_mhash_count)
#endif
#if defined(PHP_MHASH_BC)
ZEND_FE(mhash, arginfo_mhash)
ZEND_DEP_FE(mhash, arginfo_mhash)
#endif
ZEND_FE_END
};

View File

@@ -34,36 +34,57 @@ foreach ($supported_hash_al as $hash=>$wanted) {
echo "\n";
}
?>
--EXPECT--
--EXPECTF--
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_MD5
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_SHA1
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_HAVAL256
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_HAVAL192
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_HAVAL224
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_HAVAL160
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_RIPEMD160
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_GOST
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_TIGER
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_CRC32
ok
Deprecated: Function mhash() is deprecated in %s on line %d
MHASH_CRC32B
ok

View File

@@ -2,6 +2,8 @@
MHash: mhash_get_block_size() & mhash_get_hash_name() test
--SKIPIF--
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
$supported_hash_al = array(

View File

@@ -34,36 +34,57 @@ foreach ($supported_hash_al as $hash=>$wanted) {
echo "\n";
}
?>
--EXPECT--
--EXPECTF--
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_MD5
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_SHA1
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_HAVAL256
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_HAVAL224
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_HAVAL192
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_HAVAL160
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_RIPEMD160
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_GOST
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_TIGER
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_CRC32
ok
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
MHASH_CRC32B
ok

View File

@@ -11,7 +11,9 @@ var_dump(bin2hex(mhash($algo, "test")));
var_dump($algo);
?>
--EXPECT--
--EXPECTF--
int(1)
Deprecated: Function mhash() is deprecated in %s on line %d
string(32) "098f6bcd4621d373cade4e832627b4f6"
int(1)