Last modified: 2012-06-20 08:06:03 UTC
This bug report is in response to the reply from Platonides on not being able to add external stylesheets - http://lists.wikimedia.org/pipermail/mediawiki-l/2012-May/039318.html Details: Cannot load external style sheets ie., style sheets with a path like, 'http://mysite.com/css/screen.css'. This was seen when creating a new theme with mediawiki-1.18.1 and 1.19.0 code base and passing http urls to the styles array to $wgResourceModules, like this: $wgResourceModules['skins.uabvector'] = array( 'styles' => array( 'http://mysite.com/css/layout.css' => array( 'media' => 'screen' ), 'http://mysite.com/css/positional.css' => array( 'media' => 'screen' ), ), 'remoteBasePath' => &$GLOBALS['wgStylePath'], 'localBasePath' => &$GLOBALS['wgStyleDirectory'], ); Following is the error in the apache error log for the external style sheet. For 1.18.1, the error is: [error] [client ::1] PHP Warning: filemtime(): stat failed for /home/user/public_html/mw-1.18.1/skins/https://mysite.com/brand/styles/3.0/css/bg/backsplash-green_bg.css in /home/user/public_html/mw-1.18.1/includes/resourceloader/ResourceLoaderFileModule.php on line 380 For 1.19.0, the error is: error] [client ::1] PHP Warning: array_map(): An error occurred while invoking the map callback in /home/user/public_html/mediawiki-1.19.0/includes/resourceloader/ResourceLoaderFileModule.php on line 589 The style sheets are loaded if they are downloaded locally and a local file path is mentioned instead to the styles array. As Roan Kattouw mentioned in this bug - https://bugs.php.net/bug.php?id=55416&edit=1, the above errors originate from the array_map in the function 'readStyleFile' in the includes/resourceloader/ResourceLoaderFileModule.php - https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/resourceloader/ResourceLoaderFileModule.php;h=f0892ec2a82daa849f4feed4c274e6ed5b534a31;hb=HEAD#l597. The array_map returns empty when the stylesheet has a http path.
As a bug report, this is afaik INVALID. Because ResourceLoader is about packaging modules and delivering them to the client. External files (other than images referenced in CSS) don't play any role. To load those, use $out->addStyle( 'http://' ); not linked to any module. remoteBasePath/localBasePath is explicitly given even, emphasizing this these files oughta exist relative to those paths, so the failure makes perfect sense and is expected behavior. As a feature request, we could consider allowing a mixture of external and local files. But I'm not sure to what end that would improve the situation.
Thanks and you are right Krinkle. I deleted the external stylesheets from the $wgResourceModules array and instead added them the old way (pre-resource loader) with $out->addStyle('http://mysite.com/css/screen.css'); in the main skin file '<skin-identifier>.skin.php Its a great idea to add this as a feature request, if its possible to do so. Our main reason to reference external style sheets, is because, these style sheets are maintained by another group and we are adapting the vector theme to their styling.
You may want to consider still including them locally. That way: * Keep control over version. e.g. if you update MediaWiki of if they update something, you can make sure that your extension always uses the version that is compatible with the version of MediaWiki it is developed for. * Loads more efficient through the ResourceLoader framework Depending on how this external party makes their content available and how you develop the extension, you could use something like "git submodule" or "svn externals" to embed it from their repository into your extension. That way you don't duplicate it but don't have to use an external http request either.
(turn from bug into enhancement)