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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T13891, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11891 - Add randomseed
Add randomseed
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
DynamicPageList2 (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  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: ---


Attachments

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()

-------------------

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);
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.

[[:no:Jeblad]]

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


Navigation
Links