Jump to content

Extension talk:RandomInclude

Add topic
From mediawiki.org
Latest comment: 10 years ago by Oliepedia in topic Bugs

Feedback about version 1.0

[edit]

Questions

[edit]

Feature requests

[edit]
  • Ignore text between "noinclude" tags. This would allow to insert in the random text templates some text that would be shown to users viewing the template, but that would not be inserted as random text. --Fernando Correia 19:40, 21 December 2006 (UTC)Reply
  • I realize that this might be out of date (good news, btw, it works on version 1.11.x!), but I was wondering if it would be possible to use it in a template. As of now, if you include {{#random:}} in a template, it spits out the entire list, not just the individual ones. Unless I'm doing something wrong. 66.168.102.87 21:15, 3 February 2008 (UTC)Reply
  • I'm having the same issue with {{#random:}} spitting out the entire list. 207.154.82.33 05:21, 27 March 2008 (UTC)Reply
    Same problem here. In your output which includes the entire list, did you see surrounding <random> tags? That's what I saw, and I think it means that {{#random:}} is getting parsed and translating its contents to <random>, but that the <random> tag isn't subsequently getting parsed, too. So as a work-around I chose to just use the <random> in the first place, and that seems to be working. This is in MediaWiki version 1.14.0, by the way. 68.101.39.250 17:52, 3 May 2010 (UTC)Reply

Bugs

[edit]

Eats white space (solved)

[edit]
  • If using the "white space at begining of line" to show a box around the text, it seems that the white space is "eaten" by the RandomInclude just for the first line of each section. I mean, if I write this (note the blank at the begining):
Line 1
Line 2
Line 3
  • It is showed like this:

Line 1

Line 2
Line 3
Version 1.1.0 allows the use of spaces on the first line of an entry. But this doesn't seem to work on the first entry, because when the extension receives it, the first space has already been removed. To circumvent this create a blank entry before the first entry. Blank entries are now ignored. See example below. --Fernando Correia 17:19, 8 February 2007 (UTC)Reply
----
 first entry, line 1
 first entry, line 2
 first entry, line 3
----
 second entry, line 1
 second entry, line 2
 second entry, line 3

Template Spits out Entire List (workaround exists)

[edit]

This was previously listed as a requested feature, but I think it's a bug. When using the

{{#random:{{Tips}}}}

tag, we get the entire list wrapped with

<random></random>

instead of a single element. --Yoderj 23:07, 4 May 2008 (UTC) An alternative to the {{#random:{{Tips}}}} syntax is to useReply

{{#tag:random | {{Tips}}}}

. This worked with MW 1.12 for me. --98.223.150.194 01:15, 5 May 2008 (UTC)Reply

This sounds like a bug in the new parser. I'll try to get time to look into it. Jeblad 00:27, 28 August 2008 (UTC)Reply
The work-around, apparently, is to just use the <random> tag instead of {{#random:}}; they're really equivalent, and the one gets translated into the other as an intermediate step. 68.101.39.250 17:55, 3 May 2010 (UTC)Reply
It also doesn't work within raw HTML sections:
<div>
{{#tag:random | {{:Tips}} }}
</div>
This is pretty much totally broken for me. None of the suggested workarounds give anything other than a blank page. If I just use my template, that displays fine, but I can't get anything to select a random quote. Best I can do is the whole list between random html-tags. A fix and/or updated install instructions would be cool. Thanks! Oliepedia (talk) 18:07, 6 May 2014 (UTC)Reply

Contributors

[edit]

Source code contributors:

Version history

[edit]

1.0.0

[edit]

Release date: 2006-12-21

  • Initial release.

1.0.1

[edit]

Release date: 2006-12-21

  • Hide section edit links.

1.0.2

[edit]

Release date: 2006-12-21

  • Disable parser cache for pages that use this extension.
  • Solve a bug with a title on the first line.

1.1.0

[edit]

Release date: 2007-02-08

  • Ignores blank entries.
  • Supports spaces on the first line of an entry. Note: this doesn't work on the very first entry.

1.2.0

[edit]

Release date: 2008-04-14

  • Additional keywords
    • pattern to use as boundary between items
    • separator rendered between items
    • count number of items
    • limit on runaway loop
    • period as minute, hour, day, week or seconds (integer)
    • mode is none or ordered depending on count
    • cache strategy, set to 'disable' to do no caching

1.3.0

[edit]

Release date: 2008-04-14

  • Additional keyword
    • format string to do dpl-style of formating

1.3.1

[edit]

Release date: 2008-04-14

  • Bugfix, missing format keyword in parser function

1.3.2

[edit]

Release date: 2008-04-22

  • Bugfix, int changed with intval
  • added seed keyword

1.3.3

[edit]

Release date: 2008-04-22

  • Bugfix, noeditsection interfers with the parser

1.3.4

[edit]

Release date: 2008-04-23

  • Bugfix, pattern was not consistently handled

1.3.5

[edit]

Release date: 2008-04-27

  • added hash keyword (avoid use of seed as it might interfer with other functions)

Formatstring as dpl

[edit]

There should be an option to use a formatstring like the one used for DPL. 87.248.11.164 08:44, 14 April 2008 (UTC)Reply

Better cache strategy

[edit]

There should be a better cache strategy to avoid completly disabling the cache. Jeblad 10:11, 14 April 2008 (UTC)Reply

Random seed

[edit]

Use of random seed interfers with other use of the rand function. Also not every implementation respects setting the seed value. Jeblad 09:58, 26 April 2008 (UTC)Reply

Not Working With MW 1.13

[edit]

I just installed MW 1.13, and tried to use RandomInclude as I had before, But the include only adds the entire text of the RandomInclude.php file into my page instead of working as an extension, if that makes any sense at all. Anyone else experiencing this? Any Fix?

See [1] Jeblad 00:28, 28 August 2008 (UTC)Reply

The "period" parameter

[edit]

Hi everybody,

I'd like to put a random text every day, so I used the syntax : {{#tag:random | {{MyPage}} | period=day}}

But when I refresh, my text keeps changing during the day. Do you have an idea about how to fix this problem ?

Thank you for your help --Marineam 17:39, 19 March 2009 (UTC)Reply

What kind of system is the host for the wiki? Is it a Unix system? If "time" does not return a unix epoch integer it may behave like you describe. Jeblad 16:41, 25 April 2009 (UTC)Reply

Line Breaks

[edit]

I can't seem to get the extension to respect line-break (<br />) embedded in the random text. Is there a way to force this? Thanks for the extension! 128.183.226.220 16:08, 4 December 2009 (UTC)Reply

Not sure what you ask about… As a separator you can use \n, but I guess you want to use a linebreak inside a random note…
Ah, I see, it uses internalParse and htmlspecialchars. It could be rewritten without some of the htmlspecialchars-calls and rely on the parser to do further cleanup. I'll see if I can fix it someday, but I don't have the time right now. Jeblad 21:11, 8 December 2009 (UTC)Reply

Undefined Index Error

[edit]

I have RandomInclude on the main page of my Wiki. I'm seeing the following error in my Apache logs whenever I access the main page:

[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  count in /var/www/wiki/extensions/RandomInclude.php on line 158
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  limit in /var/www/wiki/extensions/RandomInclude.php on line 159
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  cache in /var/www/wiki/extensions/RandomInclude.php on line 160
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  seed in /var/www/wiki/extensions/RandomInclude.php on line 161
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  hash in /var/www/wiki/extensions/RandomInclude.php on line 166
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  period in /var/www/wiki/extensions/RandomInclude.php on line 171
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  mode in /var/www/wiki/extensions/RandomInclude.php on line 193
[Sat Feb 27 13:44:12 2010] [error] [client 172.28.64.130] PHP Notice:  Undefined
 index:  format in /var/www/wiki/extensions/RandomInclude.php on line 224

Any idea what might be causing this? --Gkullberg 13:43, 27 February 2010 (UTC)Reply

I (MediaWiki 1.15.1 PHP 5.2.8 (cgi-fcgi) MySQL 4.1.22-max-log) receive the same it seems. Here is the copy I have in my /extensions/RandomInclude.php and a copy from the error output.
Notice: Undefined index: pattern in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 155
Notice: Undefined index: separator in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 157
Notice: Undefined index: count in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 158
Notice: Undefined index: limit in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 159
Notice: Undefined index: cache in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 160
Notice: Undefined index: seed in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 161
Notice: Undefined index: hash in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 166
Notice: Undefined index: period in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 171
Notice: Undefined index: mode in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 193
Notice: Undefined index: format in /home/content/d/a/v/davidyoga/html/mediawiki/extensions/RandomInclude.php on line 224
--SomaticJourney 13:48, 2 March 2010 (UTC)Reply
Bump (I'd like to see this extension work) --SomaticJourney 18:52, 8 March 2010 (UTC)Reply
It's a notice, not an error. But if you want to turn it off notices just for that function, try changing the code as follows:
function wfRenderRandomInclude( $input, $argv, $parser ) {

$errorLevel = error_reporting(E_ALL ^ E_NOTICE);

global $wgUser;

...

error_reporting($errorLevel);

return $parser->internalParse($output . " __NOEDITSECTION__");

}
GreenReaper 01:36, 26 May 2010 (UTC)Reply

making extension/RandomInclude/RandomInclude.php instead of...

[edit]

putting it by default in extensions/ Will that break the script? I would test it but I have a previous issue Extension_talk:RandomInclude#Undefined_Index_Error which already breaks this extension. My need is to keep my extensions/ dir organized. Thank you for this eat extension --SomaticJourney 13:36, 3 March 2010 (UTC)Reply

The script should work, but I guess I know whats the problem. If the setup of the PHP environment is sufficient paranoid it can croak. My basic setup is with the extension as extensions/RandomInclude/RandomInclude.php. Jeblad 18:01, 8 March 2010 (UTC)Reply

Not working with MW 1.15.1?

[edit]

I followed your instruction and it worked fine with MW 1.9.1.

But with MW 1.15.1 I receive the complete list of my quotes.

{{:randomAbsence makes the heart grow fonder.
Actions speak louder than words.
An ounce of prevention is worth a pound of cure.
Test 122333
}}


With { {#tag:random | { {Tips}}}} instead of {{#random:{ {Tips}}}} I receive

Unbekannter Extension-Tag „Tips“


Buggy

[edit]

This is a great extension and I'd like it to work, but there are a few problems, all of which have been mentioned.

  • HTML outputting as raw HTML when calling quotes from a template from within a (div).
  • the PHP notices (and under certain contexts I get "Warnings" too).
  • the tag syntax issue.

Any chance of this extension being updated to address these issues?

--DoubleSuitedChris 23:49, 1 June 2010 (UTC)Reply