Skip to content

Commit e6c0b09

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: random: Fix unknown `mt_srand()` compatibility for unknown modes (#13544) Removed `REPORT_EXIT_STATUS=no` in libmysql tests Revert "Fix GH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections." (#13546)
2 parents 116166c + e059498 commit e6c0b09

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.3.5
44

5+
- Random:
6+
. Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with
7+
unknown modes). (timwolla)
58

69
14 Mar 2024, PHP 8.3.4
710

ext/random/random.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,13 @@ PHP_FUNCTION(mt_srand)
486486
Z_PARAM_LONG(mode)
487487
ZEND_PARSE_PARAMETERS_END();
488488

489-
state->mode = mode;
490-
491-
/* Anything that is not MT_RAND_MT19937 was interpreted as MT_RAND_PHP. */
492-
if (state->mode != MT_RAND_MT19937) {
489+
switch (mode) {
490+
case MT_RAND_PHP:
491+
state->mode = MT_RAND_PHP;
493492
zend_error(E_DEPRECATED, "The MT_RAND_PHP variant of Mt19937 is deprecated");
493+
break;
494+
default:
495+
state->mode = MT_RAND_MT19937;
494496
}
495497

496498
if (seed_is_null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
mt_srand(): Test unknown modes
3+
--FILE--
4+
<?php
5+
// MT_RAND_MT19937
6+
mt_srand(1, 0);
7+
var_dump(mt_rand());
8+
// MT_RAND_PHP
9+
mt_srand(1, 1);
10+
var_dump(mt_rand());
11+
// Unknown
12+
mt_srand(1, 2);
13+
var_dump(mt_rand());
14+
// Equivalent to 0 when cast as unsigned 8-bit integer
15+
mt_srand(1, 256);
16+
var_dump(mt_rand());
17+
?>
18+
--EXPECTF--
19+
int(895547922)
20+
21+
Deprecated: The MT_RAND_PHP variant of Mt19937 is deprecated in %s on line %d
22+
int(1244335972)
23+
int(895547922)
24+
int(895547922)

0 commit comments

Comments
 (0)