Template talk:2018–19 NBA Northwest standings

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Script errors[edit]

JohnBlackburne has commented out some wikitext to remove errors in articles with script errors. I was also investigating that. For anyone interested, there were hidden errors (visible only in the HTML source) at 2018–19 Denver Nuggets season and other articles. I managed to work out the following which might help someone locate the problem. The error was that Template:Decimals uses Module:Decimals and it was giving an error because something was passing the following to {{decimals}}:

({{{-5}}} + {{{-3}}} - {{{-4}}} - {{{-2}}} -   0  -   0  +   0  +   0 ) / 2

I suspect Template:NBA team standings/gb format was being passed the above junk. Johnuniq (talk) 01:33, 13 May 2018 (UTC)[reply]

Yes, I commented it out as I could not find the error, beyond narrowing it down to this template then looking for clues in the page source but not enough for me to identify. Seemed safest just to disable the template. It has no data at the moment so removing it is no detriment to the articles. And the fact that it has no data might be one cause of it. I’ve seen similar problems before, where templates try to e.g. calculate win/loss ratios and fall over because it’s a divide by zero. But without actually seeing the error and being able to jump to it I got no further.--JohnBlackburnewordsdeeds 02:04, 13 May 2018 (UTC)[reply]
I'm sure you're right and thanks for fixing the problem. Johnuniq (talk) 03:37, 13 May 2018 (UTC)[reply]

More script errors[edit]

@Piranha249: The following templates are generating errors:

My edit summary was:

comment-out broken template which puts articles in Category:Pages with script errors, see Template talk:2018–19 NBA Northwest standings

Articles in the script-errors category are listed here. As of this comment, the articles listed were:

Unless a specific user preference is set, the fact that there is a script error may be hidden (see WP:HIDDENCAT). I have not examined exactly what is going on, although I did get as far as finding the broken code shown in the above section. Whatever the problem is, it has to be fixed. Are the templates finished? That is, are there outstanding events which feed junk into the template and which might be the cause of the problem? I'll ping JohnBlackburne so he can find this discussion. Johnuniq (talk) 05:17, 1 June 2018 (UTC)[reply]

I had a look at this again a week or two ago. The problem seems to be with {{NBA team standings}}. From the source it has two modes, 'DIVISION' and 'CONFERENCE' and it’s the latter that is generating errors when it is asked to generate a table with no data, i.e. before the season’s started. Simply removing the template seems best. The documentation at {{NBA team standings}} says it should not be used when the season is over as its computationally expensive. Perhaps there should be a similar note on it and derived templates for before the season. Not using it makes even before more sense as until the season starts it is pointlessly calculating a lot of zeros.--JohnBlackburnewordsdeeds 06:08, 1 June 2018 (UTC)[reply]
Johnuniq and JohnBlackburne, that's strange, because I do not understand the meaning of this problem. All templates are like this until we add a game onto the standings. Where is this "hidden script error?" –Piranha249 20:10, 2 June 2018 (UTC)[reply]
The script error is in the pages listed above, caused by the template, e.g. by {{2018–19 NBA Atlantic standings|team=BOS}} from 2018–19 Boston Celtics season. To show this you can copy that template and paste it in an otherwise empty page (I use my Sandbox). Hit 'Preview' and the page will have the category Pages with script errors. The error is invisible on the page, but you can inspect it by viewing the page source. Look for 'Error' until you see module names and error messages. The practical consequence of this is it adds the articles to the above category, which should be empty of articles.--JohnBlackburnewordsdeeds 21:06, 2 June 2018 (UTC)[reply]
In preferences there is a "Show hidden categories" option which is off by default. If you enable that option the script error category is seen at the bottom of the affected pages. Johnuniq (talk) 06:00, 3 June 2018 (UTC)[reply]
Another way to see the hidden category is the "Page information" in the left-hand tools. For example, view Template:2018–19 NBA Northwest standings then click Page information and search for "Hidden". Johnuniq (talk) 08:17, 3 June 2018 (UTC)[reply]

The problem is in {{NBA team standings/gb format}} which consists of the following single line:

{{#iferror:{{#ifeq:{{{1|0}}}|0|–|{{Decimals|{{{1}}}|1}}}}|–}}

When a season is not complete, parameter 1 is junk and that is passed to {{Decimals}}. That calls Module:Decimals which evaluates the junk using the module equivalent of {{#expr:junk}}. That causes the module to throw a script error. The #iferror captures the error and displays an en dash. However, the page is also included in the script errors category. I'm thinking I will add an error parameter to the decimals template and module to control what is displayed if the module throws an error. An alternative would be to uglify the above wikitext to somehow test parameter 1 so decimals is not called if the parameter contains {. I'll think about that. Johnuniq (talk) 06:00, 3 June 2018 (UTC)[reply]

I implemented the change in decimals. So far, so good. The errors have gone away. Johnuniq (talk) 10:35, 3 June 2018 (UTC)[reply]