Skip to content

Commit ea1b878

Browse files
committed
Fix #78969 Make PASSWORD_DEFAULT match PASSWORD_BCRYPT instead of being null
It was an unintentional BC break.
1 parent 1cccbb8 commit ea1b878

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ PHP NEWS
4343

4444
- Standard:
4545
. Fixed bug #78902 (Memory leak when using stream_filter_append). (liudaixiao)
46+
. Fixed bug #78969 (PASSWORD_DEFAULT should match PASSWORD_BCRYPT instead of being null). (kocsismate)
4647

4748
- Zip:
4849
. Add ZipArchive::CM_LZMA2 constant (since libzip 1.6.0). (remi)

UPGRADING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ PHP 7.4 UPGRADE NOTES
150150
. Password hashing algorithm identifiers are now nullable strings rather
151151
than integers.
152152

153-
* PASSWORD_DEFAULT was int 1; now is null
153+
* PASSWORD_DEFAULT was int 1; now is null in PHP <7.4.3 and string '2y' afterwards
154154
* PASSWORD_BCRYPT was int 1; now is string '2y'
155155
* PASSWORD_ARGON2I was int 2; now is string 'argon2i'
156156
* PASSWORD_ARGON2ID was int 3; now is string 'argon2id'
@@ -726,7 +726,7 @@ PHP 7.4 UPGRADE NOTES
726726
the INI directive opcache.cache_id. All processes with the same cache ID and
727727
user share an OPcache instance.
728728

729-
- The OpenSSL default config path has been changed to
729+
- The OpenSSL default config path has been changed to
730730
"C:\Program Files\Common Files\SSL\openssl.cnf" and
731731
"C:\Program Files (x86)\Common Files\SSL\openssl.cnf", respectively.
732732

ext/standard/password.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ const php_password_algo php_password_algo_argon2id = {
496496
PHP_MINIT_FUNCTION(password) /* {{{ */
497497
{
498498
zend_hash_init(&php_password_algos, 4, NULL, ZVAL_PTR_DTOR, 1);
499-
REGISTER_NULL_CONSTANT("PASSWORD_DEFAULT", CONST_CS | CONST_PERSISTENT);
499+
REGISTER_STRING_CONSTANT("PASSWORD_DEFAULT", "2y", CONST_CS | CONST_PERSISTENT);
500500

501501
if (FAILURE == php_password_algo_register("2y", &php_password_algo_bcrypt)) {
502502
return FAILURE;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Test that the value of PASSWORD_DEFAULT matches PASSWORD_BCRYPT
3+
--FILE--
4+
<?php
5+
echo PASSWORD_DEFAULT . "\n";
6+
echo PASSWORD_BCRYPT . "\n";
7+
--EXPECT--
8+
2y
9+
2y

0 commit comments

Comments
 (0)