2 September 2011

From Organic Design wiki
Revision as of 03:43, 3 September 2011 by Nad (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Warning.svg This is a blog item that needs to be converted to the new Bliki format


Difficult bug found and resolved

A bug cropped up today which was very difficult to track down so I thought I better document what happened in case it crops up again somewhere. The problem initially started after extensions on one of the server running some MediaWikis were updated. Afterwards a number of drop-down lists in forms around a few of the sites had stopped showing their selected state (the "selected" attribute was not being added to any of the "option" elements).

I picked one list it was happening to and started tracking the problem down. First I found that the option list was being generated by Template:FormSelectFromCategory which takes two parameters, the first the name of a category and the second an optional parameter which is the current value if any exists. This template returns the items in the passed category as an HTML option list with one of them selected if it matches the second parameter.

Outputting the values being passed to this template showed that for some reason the second parameter was empty even though it was being passed an expression which was the value of a variable that had been set with the Variables extension. I found that the variable was being cleared if there was a DPL query between its definition and subsequent recall.

Looking in the code of the variables extension I found that it clears all its defined variables in the ParserClearState hook. Commenting this out fixed the problem which means that the DPL extension must clear the parser state for some reason.

Both extensions may have a good reason for doing what they're doing, but for now I'll have to leave the line commented out and let the authors know that the problem is happening.