Topic on Project:Support desk

Need clarification for loading extensions in MW 1.27.0

3
Yolo33s (talkcontribs)

Hello,

I'm struggling with the load of extensions. I saw in documentation that we are supposed to use wfLoadExtension instead of include or require_once functions. Before, I tried to run update.php with includes in my LocalSettings.php. I had the following error message : "failed to open stream: No such file or directory" while the rights, permissions and path are correct.

So I tried wfLoadExtension but this time, the error message is : "PHP Fatal error:  Uncaught exception 'Exception' with message '/var/www/wiki/extensions/LaunchExternal/extension.json does not exist!".

And yes, I don't have a .json file for the good reason that my extension was working well before without .json and because I did not see anything in documentation about the creation of such a .json file.

Anyway, any precise clue on doing it would be much appreciate. Please don't redirect me to Manual:Upgrading, I come from there and followed the examples at the letter.

Thanks for support.

87.123.10.25 (talkcontribs)

Extensions can be loaded in two different ways:

  • You can use a require_once call. This is the old method. It will work, whenever the required file is present, e.g. if the extension has a MyExtension/MyExtension.php file, then you can require that file.
  • You can use wfLoadExtension() in LocalSettings.php. This approach is recommended. It will only work, if the extension has an extension.json file. If it does not yet have one, you can create one using the convertExtensionToRegistration.php maintenance script. So if this is your extension or if you want to help update it, you should use this script and add the result to the official code repository of that extension!
Yolo33s (talkcontribs)

First thanks for reply. Next, I already read that, and I actually tried it. So let me give an example. At line 199 of my LocalSettings.php, I have an include line : include("./extensions/simplepie_mediawiki.php");

In the extensions folder, I have the correct file at the correct path, with open rights (chmod 777). If I try to access this file from the same level as LocalSettings.php, I can, THERE IS NO DOUBT ABOUT THE PATH.

  1. when I run update.php, I have an error message : PHP Warning:  include(./extensions/simplepie_mediawiki.php): failed to open stream: No such file or directory in /var/www/wiki/LocalSettings.php on line 199
  2. So I thought that I should use wfLoadExtension instead. I changed my LocalSettings.php according to the documentation and I ran php convertExtensionToRegistration.php ../extensions/simplepie_mediawiki.php.

And I still have this error noticing me the file does not exist.

Any clue about that ? I think it's something about rights but the folder is in www-data:www-data and the file is chmod 777...

Reply to "Need clarification for loading extensions in MW 1.27.0"