Content deleted Content added
Edgars2007 (talk | contribs) not such a big |
m Reverted edits by Athishraj081 (talk) to last version by Redrose64 |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1:
[[file:Wikimedia-Collab-logo.svg|39px|right]]
{{#invoke:Page|id|Nazi Party}}▼
__TOC__
== example ==
<code><nowiki>{{#invoke:Page|id|Nazi Party}}</nowiki></code> generates:
▲: {{#invoke:Page|id|Nazi Party}}
Modified by [[User:Gangleri|Gangleri]] ([[User talk:Gangleri|talk]]) 12:39, 17 December 2015 (UTC)
== wgCurRevisionId ==
att: / cc: @[[user:Darklama|Darklama]], @[[user:Liangent|Liangent]], @[[user:Wnt|Wnt]]
Hi! It is possible to add wgCurRevisionId to the list of parameters? One application is described under note a) at https://en.wikipedia.org/?curid=14574453#shortest_url . Kind regards [[User:Gangleri|Gangleri]] ([[User talk:Gangleri|talk]]) 12:39, 17 December 2015 (UTC)
== Script errors ==
@[[User:Petr Matas|Petr Matas]]: I'm trying to understand your recent changes to [[Module:Page]] which look great in principle but which have a glitch that is generating script errors in articles ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmprop=title&cmlimit=500&cmnamespace=0&format=xml&cmtitle=Category:Pages_with_script_errors current list]).
In callAssert, what is this?
<pre>
local result = { func(...) }
</pre>
I would have expected use of <code>pcall</code>. The following <code>join</code> should be <code><s>string.concat</s></code> <code>table.concat</code> and that is the immediate problem. If I get some time later I will try following instinct and replace the above with pcall. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:06, 18 August 2018 (UTC)
:On a closer look, I see that pcall was not wanted. The code is not catching an error in the call, it's detecting whether the call returned nil. Even closer inspection showed that throwing <code>error()</code> is not wanted either. I have never seen this module or its templates (apparently {{tl|Correct title}} and {{tl|Pageid to title}}) before so my quick work needs checking. However, {{tl|Correct title}} uses #iferror to test certain things and the error span class returned in the text is caught by #iferror. Throwing an error puts the article in [[:Category:Pages with script errors]] which is very undesirable. At any rate I fixed the immediate problem and the number of articles in the error category is down from 88 to 14. I'll investigate those 14 in due course. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:25, 18 August 2018 (UTC)
::The line <code>local result = { func(...) }</code> stores the (possibly multiple) values returned from the function in a table. Its counterpart is <code>return unpack(result)</code>, which returns the contents of the table as multiple values.
::To avoid throwing an error from the module, I have encapsulated the entire main in pcall. This way we can keep using error(), I hope. Thus, pcall at other places becomes unnecessary. <span style="font-family:Segoe Script">[[User:Petr Matas|Petr Matas]]</span> 09:47, 18 August 2018 (UTC)
:::That looks good. To avoid a maze of dependencies I wouldn't call [[Module:Error]] but I agree it has the advantage of being only one place to accommodate any change to how the error class works in the future. In callAssert there is no reason to use mw.ustring.format rather than the more efficient string.format. However, that's unimportant. I was going to add that the error category is now empty but I see that a problem in another module has filled it up again! Keeps me employed. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:11, 18 August 2018 (UTC)
|