Hi Florian, Thanks! For my immediate purposes, I think just doing the isLoaded() check will probably suffice, as I don't actually have any need to check versions at the moment. But I agree with your suggestion, extending the 'requires' section of extension.json does seem like it would be very helpful and extension developer-friendly, and that's a great idea.
I've opened a Phabricator task here <https://phabricator.wikimedia.org/T117277>, but feel free to tweak it if I've described something poorly or didn't tag it correctly - I've never actually created a task in Phabricator before. Thanks! -- Jason Ji jason.y...@gmail.com On Fri, Oct 30, 2015 at 2:06 PM, Florian Schmidt < florian.schmidt.wel...@t-online.de> wrote: > You can, in your php extension code, so not inside the extension.json, > check, if another extension is installed or not: > > ExtensionRegistry::getInstance()->isLoaded( 'ExtensionName' ); > > There's also a "requires" section, which is parsed in extension.json, but > it currently only supports MediaWiki core versions (it behaves like > composer's requires section). I'm wondering, if dependencies like yours are > widely used and if extending the requires section support to extensions > would help to solve your problem (with that you could specify a specific > version, a range of version or any version above a specific one, or all > versions, too, so your VIKIJS_VERSION wouldn't be needed anymore, too). > Would you like to open a task in phabricator to discuss this? > > Best, > Florian > > -----Ursprüngliche Nachricht----- > Von: Wikitech-l [mailto:wikitech-l-boun...@lists.wikimedia.org] Im > Auftrag von Jason Ji > Gesendet: Freitag, 30. Oktober 2015 17:00 > An: wikitech-l@lists.wikimedia.org > Betreff: [Wikitech-l] MW 1.25 new extension registration - PHP constants > > Hi there, > > I'm the primary developer of the VIKI > <https://www.mediawiki.org/wiki/Extension:VIKI> extension and its two > companion extensions, VikiSemanticTitle < > https://www.mediawiki.org/wiki/Extension:VikiSemanticTitle> and > VikiTitleIcon <https://www.mediawiki.org/wiki/Extension:VikiTitleIcon>. > > I thought I'd take a look at converting these three extensions to the new > extension registration < > https://www.mediawiki.org/wiki/Manual:Extension_registration> format, but > I ran into a problem. According to the documentation, the new extension > registration does not support PHP constants < > https://www.mediawiki.org/wiki/Manual:Extension_registration/Limitations>. > > I use a PHP constant to declare an explicit dependency on VIKI for > VikiSemanticTitle and VikiTitleIcon. In my VIKI.php file, I declare: > > *define( 'VIKIJS_VERSION', '1.3');* > > And then in VikiSemanticTitle and VikiTitleIcon, I have a check that looks > something like: > > *if( !defined( 'VIKIJS_VERSION' ) ) {* > * die('Error: The extension VikiSemanticTitle requires VIKI to be > installed first.');* > *}* > > (As an aside, I also happen to use VIKIJS_VERSION as my version number, > which I increment as I release new versions. But that's not as important.) > > Because the new extension registration format doesn't support PHP > constants, this no longer works, and I can't run VikiSemanticTitle and > VikiTitleIcon alongside VIKI - the VIKIJS_VERSION constant is seemingly no > longer defined, so any page load dies with the error message above. > > If I can't use PHP constants anymore, does anyone have a better > recommendation for declaring explicit dependencies? Or should I just avoid > migrating the VIKI extensions to the new registration format? > > Thanks, > > -- > Jason Ji > jason.y...@gmail.com > _______________________________________________ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l > > > _______________________________________________ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l