A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

Is there anything that needs to be fixed with this skin?

Newman22

https://github.com/Newman22/MediaWiki-Candy/tree/Newman22-patch-1

MediaWiki Version: 1.30
PHP Version: 5.6.36
MySQL Version: 5.6.39-cll-lve

Hello. I have been working on a skin called Candy (which can be viewed in the link above), and I get errors when attempting to preview the skin on my wiki. Of the errors I have gotten, the ones now are errors that I still haven’t figured out how to fix. These are the errors I currently get:

PHP Fatal error: Class 'CandyRenderer' not found in /home/gjlxrtap/public_html/mw19/skins/Candy/MediaWiki-Candy.skin.php on line 53

PHP Fatal error: Class 'SkinCandy' not found in /home/gjlxrtap/public_html/mw19/includes/ServiceWiring.php on line 142

Is there anything outdated in the skin? What is wrong with the code in any of the skin files? What further steps do I need to do in order to get the skin up and running? I need some help now.

Foxtrott

Looks like you did not correctly load the skin.

Newman22

How can I correctly load the skin? I don’t know what you mean by that.

Foxtrott
  • The error messages suggest that the classes CandyRenderer and SkinCandy are not found.
  • To be found classes need to be known by the MediaWiki autoloader (1).
  • Classes are registered with the MediaWiki autoloader by adding them to the $wgAutoloadClasses array.
  • This is done in MediaWiki-Candy.php in your case.
  • So to ensure, that the registration is actually taking place you need to load that file, which is usually done in LocalSettings.php by adding something like
require_once "$IP/skins/MediaWiki-Candy/MediaWiki-Candy.php";

(1) Or some other active autoloader, but that’s besides the point here.

Tgr

Ideally you would use extension registration, wfLoadSkin and PSR-4 these days.

Newman22

I tried the require_once method, and it worked. The only thing wrong now is that my CSS and skin design are not showing on my page. Is it the browser I am using, or is there something that needs to be fixed?

RazeSoldier

About class load, should not use require_once or other directly in the skin code, it is not graceful. We should use class autoloader. In specifically, add AutoloadClasses key in your skin.json, like this.

Newman22

I did use AutoLoadClasses. The require_once method helped the site work with the skin, without it previewing the skin would give an error 500. If the require_once method fixed an error, then what else do I need to do to make the CSS show up properly?

Osnard

Regarding you question about how to make the CSS show up properly, please refer to https://www.mediawiki.org/wiki/Manual:Skinning_Part_1 and https://www.mediawiki.org/wiki/ResourceLoader#Tutorials

In general, you will need to specify a “resource loader module”, that references your CSS/LESS files. This can be done in skin.json. After that you will need to load the module using the addModuleStyles method of the OutputPage object. The OutputPage object can for example be accessed from within the Skin.