Skip to content

Commit bf0c1ce

Browse files
committed
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.
1 parent 1c50784 commit bf0c1ce

File tree

7 files changed

+66
-9
lines changed

7 files changed

+66
-9
lines changed

UPGRADING

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ PHP 8.1 UPGRADE NOTES
337337
favor of date_sun_info().
338338
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
339339

340+
- Hash:
341+
. The mhash(), mhash_keygen_s2k(), mhash_count(), mhash_get_block_size() and
342+
mhash_get_hash_name() functions are deprecated. Use the hash_*() APIs
343+
instead.
344+
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
345+
340346
- Intl:
341347
. Calling IntlCalendar::roll() with bool argument is deprecated. Pass 1 and -1
342348
instead of true and false respectively.

ext/hash/hash.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@ function hash_equals(string $known_string, string $user_string): bool {}
3434
function hash_hkdf(string $algo, string $key, int $length = 0, string $info = "", string $salt = ""): string {}
3535

3636
#ifdef PHP_MHASH_BC
37+
/** @deprecated */
3738
function mhash_get_block_size(int $algo): int|false {}
3839

40+
/** @deprecated */
3941
function mhash_get_hash_name(int $algo): string|false {}
4042

43+
/** @deprecated */
4144
function mhash_keygen_s2k(int $algo, string $password, string $salt, int $length): string|false {}
4245

46+
/** @deprecated */
4347
function mhash_count(): int {}
4448

49+
/** @deprecated */
4550
function mhash(int $algo, string $data, ?string $key = null): string|false {}
4651
#endif
4752

ext/hash/hash_arginfo.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3973a03a64b0939de0c3677da55a5104c29b1b99 */
2+
* Stub hash: 8c35168fb1c95e76c5c77fd0c0e8d295e13a0414 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
@@ -180,19 +180,19 @@ static const zend_function_entry ext_functions[] = {
180180
ZEND_FE(hash_equals, arginfo_hash_equals)
181181
ZEND_FE(hash_hkdf, arginfo_hash_hkdf)
182182
#if defined(PHP_MHASH_BC)
183-
ZEND_FE(mhash_get_block_size, arginfo_mhash_get_block_size)
183+
ZEND_DEP_FE(mhash_get_block_size, arginfo_mhash_get_block_size)
184184
#endif
185185
#if defined(PHP_MHASH_BC)
186-
ZEND_FE(mhash_get_hash_name, arginfo_mhash_get_hash_name)
186+
ZEND_DEP_FE(mhash_get_hash_name, arginfo_mhash_get_hash_name)
187187
#endif
188188
#if defined(PHP_MHASH_BC)
189-
ZEND_FE(mhash_keygen_s2k, arginfo_mhash_keygen_s2k)
189+
ZEND_DEP_FE(mhash_keygen_s2k, arginfo_mhash_keygen_s2k)
190190
#endif
191191
#if defined(PHP_MHASH_BC)
192-
ZEND_FE(mhash_count, arginfo_mhash_count)
192+
ZEND_DEP_FE(mhash_count, arginfo_mhash_count)
193193
#endif
194194
#if defined(PHP_MHASH_BC)
195-
ZEND_FE(mhash, arginfo_mhash)
195+
ZEND_DEP_FE(mhash, arginfo_mhash)
196196
#endif
197197
ZEND_FE_END
198198
};

ext/hash/tests/mhash_001.phpt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,57 @@ foreach ($supported_hash_al as $hash=>$wanted) {
3434
echo "\n";
3535
}
3636
?>
37-
--EXPECT--
37+
--EXPECTF--
38+
Deprecated: Function mhash() is deprecated in %s on line %d
3839
MHASH_MD5
3940
ok
4041

42+
43+
Deprecated: Function mhash() is deprecated in %s on line %d
4144
MHASH_SHA1
4245
ok
4346

47+
48+
Deprecated: Function mhash() is deprecated in %s on line %d
4449
MHASH_HAVAL256
4550
ok
4651

52+
53+
Deprecated: Function mhash() is deprecated in %s on line %d
4754
MHASH_HAVAL192
4855
ok
4956

57+
58+
Deprecated: Function mhash() is deprecated in %s on line %d
5059
MHASH_HAVAL224
5160
ok
5261

62+
63+
Deprecated: Function mhash() is deprecated in %s on line %d
5364
MHASH_HAVAL160
5465
ok
5566

67+
68+
Deprecated: Function mhash() is deprecated in %s on line %d
5669
MHASH_RIPEMD160
5770
ok
5871

72+
73+
Deprecated: Function mhash() is deprecated in %s on line %d
5974
MHASH_GOST
6075
ok
6176

77+
78+
Deprecated: Function mhash() is deprecated in %s on line %d
6279
MHASH_TIGER
6380
ok
6481

82+
83+
Deprecated: Function mhash() is deprecated in %s on line %d
6584
MHASH_CRC32
6685
ok
6786

87+
88+
Deprecated: Function mhash() is deprecated in %s on line %d
6889
MHASH_CRC32B
6990
ok

ext/hash/tests/mhash_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
MHash: mhash_get_block_size() & mhash_get_hash_name() test
33
--SKIPIF--
44
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
5+
--INI--
6+
error_reporting=E_ALL&~E_DEPRECATED
57
--FILE--
68
<?php
79
$supported_hash_al = array(

ext/hash/tests/mhash_003.phpt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,57 @@ foreach ($supported_hash_al as $hash=>$wanted) {
3434
echo "\n";
3535
}
3636
?>
37-
--EXPECT--
37+
--EXPECTF--
38+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
3839
MHASH_MD5
3940
ok
4041

42+
43+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
4144
MHASH_SHA1
4245
ok
4346

47+
48+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
4449
MHASH_HAVAL256
4550
ok
4651

52+
53+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
4754
MHASH_HAVAL224
4855
ok
4956

57+
58+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
5059
MHASH_HAVAL192
5160
ok
5261

62+
63+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
5364
MHASH_HAVAL160
5465
ok
5566

67+
68+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
5669
MHASH_RIPEMD160
5770
ok
5871

72+
73+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
5974
MHASH_GOST
6075
ok
6176

77+
78+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
6279
MHASH_TIGER
6380
ok
6481

82+
83+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
6584
MHASH_CRC32
6685
ok
6786

87+
88+
Deprecated: Function mhash_keygen_s2k() is deprecated in %s on line %d
6889
MHASH_CRC32B
6990
ok

ext/hash/tests/mhash_004.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ var_dump(bin2hex(mhash($algo, "test")));
1111
var_dump($algo);
1212

1313
?>
14-
--EXPECT--
14+
--EXPECTF--
1515
int(1)
16+
17+
Deprecated: Function mhash() is deprecated in %s on line %d
1618
string(32) "098f6bcd4621d373cade4e832627b4f6"
1719
int(1)

0 commit comments

Comments
 (0)