Extension talk:Random
version 0.3 works with MW 1.17.0, --Erkan Yilmaz 15:51, 11 August 2011 (UTC)
Shuffled results
editAs of PHP version 5.2.10, "The resulting array of keys is no longer shuffled." by array_rand(). Thus, items will be randomly selected, but will remain in the order they start in. Add
shuffle($items)
just above
$keys = array_rand( $items, $count );
and
shuffle($args)
above
$keys = array_rand( $args, $count );
to restore the original behavior.
Not work with 1.22 - 1.23
editWith this error: Exception from line 316 of /includes/MagicWord.php: Error: invalid magic word 'random'. --UksusoFF (talk) 10:47, 29 April 2014 (UTC)
- I have the same problem with 1.23.0. --2A01:E35:2F06:89B0:224:54FF:FE65:19AE 19:55, 7 July 2014 (UTC)
- All 4 examples worked for me on a fresh Mediawiki 1.23.2. Can you try again? --Erkan Yilmaz (talk) 10:46, 12 August 2014 (UTC)
- Same here. Error:
- All 4 examples worked for me on a fresh Mediawiki 1.23.2. Can you try again? --Erkan Yilmaz (talk) 10:46, 12 August 2014 (UTC)
[ba...] /db/index.php?title=Foo Exception from line 318 of /path/includes/MagicWord.php: Error: invalid magic word 'random' Backtrace: #0 /path/includes/MagicWord.php(241): MagicWord->load(string) #1 /path/includes/parser/Parser.php(4984): MagicWord::get(string) #2 /path/extensions/Random/Random.php(33): Parser->setFunctionHook(string, string, integer) #3 [internal function]: efRandomExtension(Parser) #4 /path/includes/Hooks.php(206): call_user_func_array(string, array) #5 /path/includes/GlobalFunctions.php(4013): Hooks::run(string, array, NULL) #6 /path/includes/parser/Parser.php(275): wfRunHooks(string, array) #7 /path/includes/cache/MessageCache.php(1023): Parser->firstCallInit() #8 /path/includes/cache/MessageCache.php(1000): MessageCache->getParser() #9 /path/includes/Message.php(977): MessageCache->transform(string, boolean, Language, Title) #10 /path/includes/Message.php(669): Message->transformText(string) #11 /path/includes/Message.php(732): Message->toString() #12 /path/includes/OutputPage.php(853): Message->text() #13 /path/includes/OutputPage.php(899): OutputPage->setHTMLTitle(Message) #14 /path/includes/Article.php(556): OutputPage->setPageTitle(string) #15 /path/includes/actions/ViewAction.php(44): Article->view() #16 /path/includes/Wiki.php(428): ViewAction->show() #17 /path/includes/Wiki.php(292): MediaWiki->performAction(Article, Title) #18 /path/includes/Wiki.php(588): MediaWiki->performRequest() #19 /path/includes/Wiki.php(447): MediaWiki->main() #20 /path/index.php(46): MediaWiki->run() #21 {main}
- My guess you have to map the magic word. --Subfader (talk) 16:10, 1 October 2014 (UTC)
Database exception / error with MW 1.26.2
editInstalled this with 1.26.2 and got a Database error. Fixed (as far as I can tell) by following the "map magic word" instruction linked below.
Specifically, add this line to Random.php : $wgExtensionMessagesFiles['Random'] = dirname(__FILE__) . '/Random.i18n.magic.php';
Then, create a file called Random.i18n.magic.php and insert the following in:
<?php
$magicWords = array();
$magicWords['en'] = array( 'random' => array( 0, 'random' ), );