File tree 3 files changed +33
-4
lines changed
3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? ????, PHP 8.3.5
4
4
5
+ - Random:
6
+ . Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with
7
+ unknown modes). (timwolla)
5
8
6
9
14 Mar 2024, PHP 8.3.4
7
10
Original file line number Diff line number Diff line change @@ -486,11 +486,13 @@ PHP_FUNCTION(mt_srand)
486
486
Z_PARAM_LONG (mode )
487
487
ZEND_PARSE_PARAMETERS_END ();
488
488
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 ;
493
492
zend_error (E_DEPRECATED , "The MT_RAND_PHP variant of Mt19937 is deprecated" );
493
+ break ;
494
+ default :
495
+ state -> mode = MT_RAND_MT19937 ;
494
496
}
495
497
496
498
if (seed_is_null ) {
Original file line number Diff line number Diff line change
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)
You can’t perform that action at this time.
0 commit comments