Skip to content

Commit 54079ba

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

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

ext/random/random.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,13 @@ PHP_FUNCTION(mt_srand)
480480
Z_PARAM_LONG(mode)
481481
ZEND_PARSE_PARAMETERS_END();
482482

483-
state->mode = mode;
484-
485-
/* Anything that is not MT_RAND_MT19937 was interpreted as MT_RAND_PHP. */
486-
if (state->mode != MT_RAND_MT19937) {
483+
switch (mode) {
484+
case MT_RAND_PHP:
485+
state->mode = MT_RAND_PHP;
487486
zend_error(E_DEPRECATED, "The MT_RAND_PHP variant of Mt19937 is deprecated");
487+
break;
488+
default:
489+
state->mode = MT_RAND_MT19937;
488490
}
489491

490492
if (seed_is_null) {
Lines changed: 24 additions & 0 deletions
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)