Last modified: 2008-04-11 08:33:32 UTC
It is useful to be able to add a random seed. This will make it possible to use random lists which changes content in a controllable fashion. In addition a call to srand() is changed to mt_srand() ------------------- 219a220,221 > * @version 1.5.1 > * added: randomseed 222c224 < define('DPL2_VERSION', '1.5.0'); // current version --- > define('DPL2_VERSION', '1.5.1'); // current version 308a311,314 > * Seed to be used when calling random. > */ > 'randomseed' => array('default' => '', 'pattern' => '/^\d*$/'), > /** 1071a1078,1080 > $_sRandomSeed = $wgDPL2Options['randomseed']['default']; > $iRandomSeed = ($_sRandomSeed == '') ? NULL: intval($_sRandomSeed); > 1507a1517,1524 > case 'randomseed': > //ensure that $iRandomSeed is a number; > if( preg_match($wgDPL2Options['randomseed']['pattern'], $sArg) ) > $iRandomSeed = ($sArg == '') ? NULL: intval($sArg); > else // wrong value > $output .= $logger->msgWrongParam('randomseed', $sArg); > break; > 2653,2654c2670,2672 < $nResults = $dbr->numRows( $res ) - $iOffset; < srand((float) microtime() * 10000000); --- > $nResults = $dbr->numRows( $res ) - $iOffset; > if (isset($iRandomSeed)) mt_srand($iRandomSeed); > else mt_srand((float) microtime() * 10000000);
A typical call can be extended with "randomseed={{#time:Ymd}}" to make a dynamic list change once each day, or like "randomseed={{#time:YW}}" to change it once a week. Note that the page with the list still needs to be purged or updated in some other fashion.
This is now included in the DPL functionality. [[:no:Jeblad]]