Last modified: 2008-04-11 08:33:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 11891 - Add randomseed
Add randomseed
Product: MediaWiki extensions
Classification: Unclassified
DynamicPageList2 (Other open bugs)
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2007-11-07 01:45 UTC by John Erling Blad
Modified: 2008-04-11 08:33 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description John Erling Blad 2007-11-07 01:45:03 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()


>  * @version 1.5.1
>  *                    added: randomseed
< define('DPL2_VERSION', '1.5.0');               // current version 
> define('DPL2_VERSION', '1.5.1');               // current version 
>        * Seed to be used when calling random.
>        */
>       'randomseed'           => array('default' => '', 'pattern' => '/^\d*$/'),
>       /**
>       $_sRandomSeed = $wgDPL2Options['randomseed']['default'];
>       $iRandomSeed = ($_sRandomSeed == '') ? NULL: intval($_sRandomSeed);
>                       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;
<               $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);
Comment 1 John Erling Blad 2007-11-07 01:51:31 UTC
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.
Comment 2 John Erling Blad 2008-04-11 08:33:32 UTC
This is now included in the DPL functionality.


Note You need to log in before you can comment on or make changes to this bug.