Thank you Florian! I moved the dependency check to a function in
$wgExtensionFunctions and that did the trick.

Jason

--
Jason Ji
jason.y...@gmail.com

On Mon, Nov 2, 2015 at 11:48 AM, Florian Schmidt <
florian.schmidt.wel...@t-online.de> wrote:

> Hi Jason,
>
> you're right, the call to the callback is before[1] the loaded extensions
> are added to the array[2] which is the backend for isLoaded(). You need to
> put the dependency check after the extensions are loaded, e.g. into the
> wgExtensionFunctions array[3], which is currently loaded after the load and
> execution of LocalSettings.php (including wfLoadExtensions()s execution).
>
> [1]
> https://github.com/wikimedia/mediawiki/blob/e87668e86ce9ad20df05c1baa8e7cf3f58900524/includes/registration/ExtensionRegistry.php#L279
> [2]
> https://github.com/wikimedia/mediawiki/blob/e87668e86ce9ad20df05c1baa8e7cf3f58900524/includes/registration/ExtensionRegistry.php#L282
> [3] https://www.mediawiki.org/wiki/Manual:$wgExtensionFunctions
>
> -----Ursprüngliche Nachricht-----
> Von: Wikitech-l [mailto:wikitech-l-boun...@lists.wikimedia.org] Im
> Auftrag von Jason Ji
> Gesendet: Montag, 2. November 2015 17:15
> An: Wikimedia developers <wikitech-l@lists.wikimedia.org>
> Betreff: Re: [Wikitech-l] MW 1.25 new extension registration - PHP
> constants
>
> Hi Florian (or others),
>
> This morning I tried to implement Florian's suggestion of using
> ExtensionRegistry::getInstance()->isLoaded( 'ExtensionName' ) to check
> dependencies, but ran into a roadblock. Hoping someone can help me out, and
> I'll try to summarize what the problem is.
>
> I've converted *VIKI *and *VikiTitleIcon *to the new extension
> registration format. VikiTitleIcon depends on VIKI and prior to the new
> extension registration format, it used to check for the *VIKIJS_VERSION*
> PHP constant, else die(), as I described in my previous email. I wasn't
> sure exactly where to use the new isLoaded() call in VikiTitleIcon, so I
> took a best guess and used custom registration <
> https://www.mediawiki.org/wiki/Manual:Extension_registration#Customizing_registration
> >
> to specify a 'callback' function, wherein I check for isLoaded('VIKI') or
> die() otherwise. I've confirmed that my callback is being called, but
> unfortunately, this always causes the system to think that VIKI is not
> loaded and dies, regardless of whether I've included
> wfLoadExtension('VIKI') in LocalSettings.php.
>
> I'm guessing that this has something to do with the order of execution for
> registering extensions, and perhaps VIKI is only queued up for registration
> with the ExtensionRegistry but hasn't finished registration before the
> VikiTitleIcon registration callback gets called, so isLoaded('VIKI') is
> returning false. But I'm not sure, because I don't know anything about the
> internal workings of ExtensionRegistry. If the callback of VikiTitleIcon is
> not the correct place to check for the loading of VIKI, is there a better
> place?
>
> Thanks,
>
> --
> Jason Ji
> jason.y...@gmail.com
>
> On Fri, Oct 30, 2015 at 3:36 PM, Jason Ji <jason.y...@gmail.com> wrote:
>
> > And thanks to you for suggesting the idea and getting on it so quickly!
> >
> > --
> > Jason Ji
> > jason.y...@gmail.com
> >
> > On Fri, Oct 30, 2015 at 3:35 PM, Florian Schmidt <
> > florian.schmidt.wel...@t-online.de> wrote:
> >
> >> Hi,
> >>
> >> thanks for opening the task! :) I was free and started to work on
> >> this some minutes ago, because I really like the idea, so I already
> >> added a change to gerrit, before anyone has the chance to discuss
> >> this :( But I hope, that we get such a function into
> >> ExtensionRegistration! Big thanks again for bringing this up.
> >>
> >> 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 20:25
> >> An: Wikimedia developers <wikitech-l@lists.wikimedia.org>
> >> Betreff: Re: [Wikitech-l] MW 1.25 new extension registration - PHP
> >> constants
> >>
> >> 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/Limitati
> >> ons
> >> >.
> >> >
> >> > 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
> >>
> >>
> >> _______________________________________________
> >> 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
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to