Author: herd
Description:
In /includes/Skin.php in the gen=js, "skin" and "stylepath" are each defined twice. Once in the in-page <script> tag, and once in the gen=js handler:
$s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
As the gen=js script (MediaWiki:Skinname.js and MediaWiki:Common.js) is loaded later, this overwrites the former definition. This causes a problem with the &useskin URL parameter and "skin" variable, as the gen=js script is cached with the "skin" variable defined by the site default or user preference skin choice. This means, that any check for skin, like "if(skin=='monobook')" is doomed to failure when used with &useskin
Live example: http://test.wikipedia.org/wiki/Skin_Alert_Thingy
Suggested fix: As the skin definition in gen=js appears to be a legacy issue it could probably simply be removed, along with stylepath. However, for backwards support, a simple if-defined check would work just as well (to check if defined, check if the parent object has such an attribute; for a global variable, this is the window object) :
$s .= "if(!window.skin) var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
Version: 1.11.x
Severity: normal
URL: http://test.wikipedia.org/w/index.php?title=-&action=raw&smaxage=0&gen=js