Extension talk:Loops

Jump to navigation Jump to search

About this board

Old messages until January 2, 2012 are archived.


Call to undefined function wfMsgForContent()

4
Summary by Kghbln

Upgrading the extension will solve the issue

SgtLion (talkcontribs)

Sadly, I've never really understood Git systems well enough. When we exceed max loops, our MW 1.31 freaks out and reports PHP error as above. Issue is in Loops.php, line 361:

return $output .= '<div class="error">' . wfMsgForContent( 'loops_max' ) . '</div>';

wfMsgForContent needs updating to wfMessage. That's all!

Kghbln (talkcontribs)

Thanks for suggesting the code change. A change to this line was done more than two years ago. I suspect that you did not update the Loops extension when you updated MediaWiki. Try to download the version meant for MW 1.31

SgtLion (talkcontribs)

Well aren't I just a dummy? I seem to remember this being because of some bug I had in that version, but I'll return with tears on my face if that happens after updatin'. Thanks kindly. --~~~~

Kghbln (talkcontribs)

There are so many things to think of when upgrading. Sometimes something like this just slips one's attention. No worries.

<nowiki /> tag removal from some examples

2
Summary by Kghbln

nowiki tags added back to the examples

JamesDriscoll (talkcontribs)

at some point in the history the example

{{#vardefine: i | 0 }}{{#while:
 | {{#ifexpr: {{#var: i }} < 5 | true }}
 |<nowiki/>
* {{#var: i }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }}
}}

changed to

{{#vardefine: i | 0 }}{{#while:
 | {{#ifexpr: {{#var: i }} < 5 | true }}
 |
* {{#var: i }}{{#vardefine: i | {{#expr: {{#var: i }} + 1 }} }}
}}

this, and other examples will only work with a the <nowiki /> tag to force a new line in the output but I don't feel qualified enough to provide a definitive answer as to which (or if there was a legitimate reason for their removal I haven't found)

Kghbln (talkcontribs)

This was removed in 2015 by an IP. (diff) Thanks for your note so I added these back in.

Could pages where max loops have been performed get added to a category?

2
RheingoldRiver (talkcontribs)

Similar to pages with script errors etc. I tried to add a category to the system message but it didn't work.

Kghbln (talkcontribs)

Indeed this wile be a nice enhancement.

Reply to "Could pages where max loops have been performed get added to a category?"

Works with MW 1.30.X ?

3
Summary by Kghbln

It should or report a respective bug.

Yukii (talkcontribs)

can someone say if this extension works with MW1.30.x?

Skunark (talkcontribs)

It doesn't... missing extension.json file

Kghbln (talkcontribs)

It should. If not you will have to report a bug. A missing "extension.json" only means that you have to invoke the extension as before.

Broken in 1.28: PHP Fatal error: Call to undefined method Message::escape() in Loops.php on line 360

1
Summary by Kghbln

Also use the version for MW 1.29 for MW 1.28

Ciencia Al Poder (talkcontribs)

This download extensions are antivirus software alarm Trojan

2
齐天大圣者行孙 (talkcontribs)

1.28 and 1.27 seems have trojan. can you pure it? ~~~

Kghbln (talkcontribs)

I guess you have a local problem.

Dg.de (talkcontribs)

I don't understand how to increase maxLoops. What I finally have to write into the LocalSettings? I tried: $maxLoops = 120; or: ExtLoops::$maxLoops = 120; but failed, no effect at all. May anyone help me writing the correct syntax?

Danwe (talkcontribs)

There was a bug in the extension so the variable had no effect. If you require this feature you should update to the latest version.

Reply to "how to increase maxLoops?"

$egLoopsEnabledFunctions - Backwards settings

4
Alexia E. Smith (talkcontribs)

All functions are enabled by default, but there is a setting to enable functions. This logic is broken. There really should be a setting for which functions to disable.

Danwe (talkcontribs)

In your opinion, what is broken about this? You can have problems both ways, when only having a setting to enable or disable certain functions. The reason why I chose to allow enabling only certain functions instead of defining which ones should be disabled is because when introducing new functions, the admin who is updating the extension might not realize that there are new ones. Suddenly users of the wiki could start writing new templates using that function which should actually be disabled. This doesn't happen when having the option for exclusively enabling because here all previously enabled functions will still work, only newly introduced ones might not until some admin explicitly adds them. Anyhow, admins should always read the changelog when updating extensions to adjust configs if desired.

76.164.170.2 (talkcontribs)

I can see Alexia's point on the extension. I've had to do some edits to help build this extension into my wiki farm. If you don't mind, I would like to commit it to the repo for your review when I finish making sure it's hundred percent ready.

This post was posted by 76.164.170.2, but signed as ProgramCeltic.

Reply to "$egLoopsEnabledFunctions - Backwards settings"
86.165.19.110 (talkcontribs)

Can this extension be used to loop through predetermined arrays to create a nicely formatted table? I want to be able to call a template (eg Journal), which defines two array-style parameters (stage and journal, with values being comma delimited [eg stage=0,10,20,30 and entry=test,test,test]) and generates a row for each (starting the row with

, with each iteration placing the next value from each into each ), but all I get are "maximum loops reached" and poorly created tables. Please assist, thanks.
110.149.188.132 (talkcontribs)
81.154.133.185 (talkcontribs)

@110.149.188.132: Alrighty, time for me to learn a new scripting language! Thanks.

81.154.133.185 (talkcontribs)

Since the editing box is broken....

I looked into Scribunto, it looks quite complicated and I'm not very good with interpreter style languages like that. I understand it's "hacky", but if I could pull off what I want using just generic MediaWiki extensions like Loops and Arrays, I would appreciate any advice. :)

110.149.188.132 (talkcontribs)

You can increase the maximum allowed loops, but it has a limit there for a reason. It would have pretty poor performance. Making a loop in lua is simple.

local p = {}
p.loop = function(frame)
	local stage = frame.args.stage
	local rows = {}
	-- the actual looping part
	for value in mw.text.gsplit(stage, ',') do
		table.insert(rows, '|' .. value)
	end
	
	return ' {|\n' .. table.concat(rows, '\n|-\n') .. '\n|}'
end
return p

This outputs each value on a separate row. I'm not sure exactly what format of table you're looking for, but maybe you get the gist of it?

Pastakhov (talkcontribs)

Making a loop in PhpTags is simpler for me :-)

It is the same:

$stage = explode( ',', $argv['stage'] );
$rows = [];
// the actual looping part
foreach( $stage as $value ) {
	$rows[] = '|' . $value;
}
echo "\n{|\n" . implode( "\n|-\n", $rows ) . "\n|}";

Demo

Have more fun!

81.131.83.91 (talkcontribs)

Thanks for the posts. @Pastakhov: Sorry, that won't work because this is for a Wikia wiki, so yeah....

@110.149.188.132: Thanks! I'll have a look at the code and see if I can piece it together.

Reply to "table loop?"
95.157.239.252 (talkcontribs)

Hello, sorry for my bad english ^^. So, i installed with success the loops extension, but, on my wiki's pages, an error appear about the maxloops:"Maximum number of loops have been performed". But i set '-1' to the $maxloops in Loops.php file so i don't understand why he return me this error because normaly, if i set "-1" to the $MaxLoops, there is no limit for loops no??

Danwe (talkcontribs)

Check the spelling of your variable, it is ExtLoops::$maxLoops

95.157.233.100 (talkcontribs)

hello, i checked and my variable is well spelt $maxLoops. whatever the value added (-1 or 4000), it doesn't change anything. If i put the $maxLoops at -1 in the localsetting.php file, it doesn't change anything, but once i put a positive value and the error message disappear to be replaced by another message (i have too many templates called)

Here is the sourcecode of the template:

<includeonly><div style="display:none"> {{#vardefine:nt|{{lc:{{{nation}}}}}}} {{#vardefine:i|1}} {{#vardefine:tr|0}} {{#vardefine:nm|0}} {{#vardefine:ar|0}} {{#vardefine:tt|0}} {{#vardefine:vr|0}} {{#vardefine:pr|0}} {{#vardefine:wt|0}} {{#vardefine:cm|0}} {{#switch:{{#var:nt}}|usa={{#vardefine:nt|[[image:graffiti_stickers_usa_a.png|40px|link=|]] Tourelles Américaines}}|allemagne={{#vardefine:nt|[[image:graffiti_stickers_germany_s.png|40px|link=|]] Tourelles Allemandes}}|france={{#vardefine:nt|[[image:Graffiti_stickers_france_A.png|40px|link=|]] French Turrets}}|ussr={{#vardefine:nt|[[image:Graffiti_stickers_ussr_S.png|40px|link=|]] Soviet Turrets}}|china={{#vardefine:nt|[[image:Graffiti_stickers_china.png|40px|link=|]] Chinese Turrets}}|uk={{#vardefine:nt|[[image:Graffiti_stickers_uk.png|40px|link=|]] British Turrets}}|#default={{#vardefine:nt|Turrets}}}}</div> <div id="Panel" class="ModuleList"> <h3>{{#var:nt}}</h3> <table class="sortable" style="text-indent:0;"> <tr class="titlebar"> <th style="min-width:55px">Tier</th> <th style="min-width:70px">Name</th> <th style="min-width:5px">Armor</th> <th style="min-width:125px">Turret Traverse</th> <th style="min-width:105px">View Range</th> <th style="min-width:65px">Price</th> <th style="min-width:75px">Weight</th> <th class="unsortable" style="max-width:50%">Compatibility</th> </tr> {{#while:|{{#if:{{{{{#var:i}}|}}}|true}} |{{#if:{{#explode:{{{{{#var:i}}|}}}|,|8}}|<tr><td><p class="error">too many variables</p></td></tr>| {{#if:{{#explode:{{{{{#var:i}}|}}}|,|7}} |{{#switch:{{#explode:{{{{{#var:i}}|}}}|,|1}}|1={{#vardefine:tr|<span style="display:none">01</span>I}}|2={{#vardefine:tr|<span style="display:none">02</span>II}}|3={{#vardefine:tr|<span style="display:none">03</span>III}}|4={{#vardefine:tr|<span style="display:none">04</span>IV}}|5={{#vardefine:tr|<span style="display:none">05</span>V}}|6={{#vardefine:tr|<span style="display:none">06</span>VI}}|7={{#vardefine:tr|<span style="display:none">07</span>VII}}|8={{#vardefine:tr|<span style="display:none">08</span>VIII}}|9={{#vardefine:tr|<span style="display:none">09</span>IX}}|10={{#vardefine:tr|<span style="display:none">10</span>X}}|#default={{#vardefine:tr|error}}}} {{#vardefine:nm|{{#explode:{{{{{#var:i}}|}}}|,|0}}}} {{#vardefine:ar|{{#explode:{{{{{#var:i}}|}}}|,|2}}}} {{#vardefine:tt|{{#explode:{{{{{#var:i}}|}}}|,|3}}}} {{#vardefine:vr|{{#explode:{{{{{#var:i}}|}}}|,|4}}}} {{#vardefine:pr|{{#explode:{{{{{#var:i}}|}}}|,|5}}}} {{#vardefine:wt|{{#explode:{{{{{#var:i}}|}}}|,|6}}}} {{#vardefine:cm|{{#explode:{{{{{#var:i}}|}}}|,|7}}}} <tr><td><center><span style="color:orange"><b>{{#var:tr}}</b></span></center></td> <td><center><div id="{{#var:nm}}"></div><b>{{#var:nm}}</b></center></td> <td><center><span style="display:none">{{padleft:{{#var:ar}}|9|0}} </span>{{#var:ar}}<span style="color:gray"> mm</span></center></td> <td><center><span style="display:none">{{padleft:{{#var:tt}}|3|0}} </span>{{#var:tt}}<span style="color:gray"> deg/sec</span></center></td> <td><center><span style="display:none">{{padleft:{{#var:vr}}|4|0}} </span>{{#var:vr}}<span style="color:gray"> m</span></center></td> {{#ifeq:{{#var:pr}}|premium |<td><center><span style="display:none">0 </span><span style="opacity:0.8">[[image:PremiumIcon.png|link=]]</span></center></td> |<td><center><span style="display:none">{{padleft:{{#var:pr}}|9|0}} </span>{{f2Num|{{#var:pr}}}}<span style="opacity:0.8"> [[image:Credits.png|link=|]]</span></center></td>}} <td><center><span style="display:none">{{padleft:{{#var:wt}}|8|0}} </span>{{f2Num|{{#var:wt}}}}<span style="color:gray"> kg</span></center></td> <td>{{#var:cm}}</td></tr> |<tr><td></td><td><p class="error">too few variables</p></td></tr> }}}} {{#vardefine:i|{{#expr:{{#var:i}}+1}}}} }} </table></div>__NOTOC__ </includeonly><noinclude> ==Notes== *If you have too few or too many variables the module name will be in red. *Continue to add | (pipes) to how ever many modules you need. *Place variables in order, separated by a comma. **name = name of the module **tier = tier of the module, acceptable only numbers(1,2,..,10) **armor = turret armor, in millimeters, do not include "(mm)" **turret traverse = the turret traverse speed, in degrees per second, do not include "(deg/sec)" **view range = th turret view range, in meters, no not include "(m)" **price = price of the module, in credits **weight = weight of the module, in kilograms, do not include "(kg)" **compatibility = the vehicle(s) the module is compatible with, arranged by tier, then alphabetically, use <nowiki>{{Link|"exact pagename"}}.

Template

{{Turret
<!--|name, tier, armor, turret traverse, view range, price, weight, compatibility-->
|name, tier, armor, turret traverse, view range, price, weight, compatibility
}}

</nowiki>

Danwe (talkcontribs)

Should be the other way around, if you put 4000 as the value, the message about the max number of loops should show. Are you sure it is not this way around?

About your other error message: This might be an indicator for running into an endless loop. Check whether you poperly redefine your var i. Or better, use #forargs or #fornumargs instead.

95.157.233.100 (talkcontribs)

no, if i put -1 , the message about the max number of loops appear. but i don't understand how use forargs or fornumargs.

192.171.4.126 (talkcontribs)

ExtLoops::maxLoopsPerformed is buggy. Should be something like

public static function maxLoopsPerformed( Parser &$parser ) {
	$count = $parser->mExtLoopsCounter;
	return self::$maxLoops > -1 && $count >= self::$maxLoops;
}
Reply to "Maxloops error??"