Page MenuHomePhabricator

Add randomseed
Closed, ResolvedPublic

Description

Author: vacuum

Description:
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);

Version: unspecified
Severity: enhancement

Details

Reference
bz11891

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:54 PM
bzimport set Reference to bz11891.
bzimport added a subscriber: Unknown Object (MLST).

vacuum wrote:

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.

vacuum wrote:

This is now included in the DPL functionality.

[[:no:Jeblad]]