There are cases where it would be useful to run hooks from inside extensions. For example, there's a hook in an extension that Jim Wilson and I just wrote, and I wish there were hooks in Cite.php.
Seems to me that this should be accompanied by registering the hook name with mediawiki to avoid name collisions. Should extension authors just go and add these to the mediawiki.org and meta hooks documentation? Or should there be some recommendation for hook names from extensions?
Jim ===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
Thanks for bringing this up, Jim.
For reference, what he's referring to is the practice of creating one's own hooks from within an extension. In this case, we did so via a line like this:
wgRunHooks('PagesOnDemand', array( &$title, &$article));
The key here being that it would be up to another extension to hook onto 'PagesOnDemand' and perform some processing. (We refer to these extensions as 'extension modules' casually amongst ourselves to distinguish them from first-order extensions).
The question is, should we document publicly (other than in our own documentation) the hook "PagesOnDemand" in order to reduce the likelihood of collisions with other extensions' hooks? If so, where would be a good place for it?
This presupposes - to an extent - that others also are in the practice of writing "meta extensions" - extensions which provide hooks for other extensions. I'm not sure how widely this is done.
Regarding Cite in particular - it would be useful to some if there were strategically placed calls to wfRunHooks which expose some of the internals to third-party extensions.
In Jim's case, he needs to be able to modify a <ref>'s inner text based on the value of the 'name' key (if provided). This could be met by injecting the following at the beginning of the stack() method:
wfRunHooks('CiteBeforeStack', array( &$str, &$key ));
''Note: I'll be happy to provide a patch if necessary''
He could then hook 'CiteBeforeStack' and modify $str to be whatever he needed. As it is today, he hacks the Cite extension to do what he wants.
So, in general, what is the community's standpoint on extensions hooking into extensions? Is this encouraged, discouraged, common or uncommon? We'd like to hear your thoughts.
Thanks in advance,
Jim R. Wilson (jimbojw)
On 2/21/07, Jim Hu jimhu@tamu.edu wrote:
There are cases where it would be useful to run hooks from inside extensions. For example, there's a hook in an extension that Jim Wilson and I just wrote, and I wish there were hooks in Cite.php.
Seems to me that this should be accompanied by registering the hook name with mediawiki to avoid name collisions. Should extension authors just go and add these to the mediawiki.org and meta hooks documentation? Or should there be some recommendation for hook names from extensions?
Jim
Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
Thanks for bringing this up, Jim.
For reference, what he's referring to is the practice of creating one's own hooks from within an extension. In this case, we did so via a line like this:
wgRunHooks('PagesOnDemand', array( &$title, &$article));
The key here being that it would be up to another extension to hook onto 'PagesOnDemand' and perform some processing. (We refer to these extensions as 'extension modules' casually amongst ourselves to distinguish them from first-order extensions).
The question is, should we document publicly (other than in our own documentation) the hook "PagesOnDemand" in order to reduce the likelihood of collisions with other extensions' hooks? If so, where would be a good place for it?
This presupposes - to an extent - that others also are in the practice of writing "meta extensions" - extensions which provide hooks for other extensions. I'm not sure how widely this is done.
Regarding Cite in particular - it would be useful to some if there were strategically placed calls to wfRunHooks which expose some of the internals to third-party extensions.
In Jim's case, he needs to be able to modify a <ref>'s inner text based on the value of the 'name' key (if provided). This could be met by injecting the following at the beginning of the stack() method:
wfRunHooks('CiteBeforeStack', array( &$str, &$key ));
''Note: I'll be happy to provide a patch if necessary''
He could then hook 'CiteBeforeStack' and modify $str to be whatever he needed. As it is today, he hacks the Cite extension to do what he wants.
So, in general, what is the community's standpoint on extensions hooking into extensions? Is this encouraged, discouraged, common or uncommon? We'd like to hear your thoughts.
Thanks in advance,
Jim R. Wilson (jimbojw)
On 2/21/07, Jim Hu jimhu@tamu.edu wrote:
There are cases where it would be useful to run hooks from inside extensions. For example, there's a hook in an extension that Jim Wilson and I just wrote, and I wish there were hooks in Cite.php.
Seems to me that this should be accompanied by registering the hook name with mediawiki to avoid name collisions. Should extension authors just go and add these to the mediawiki.org and meta hooks documentation? Or should there be some recommendation for hook names from extensions?
Jim
Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
Sorry all for the dupe - Gmail's wigging out on me :(
On 2/21/07, Jim Wilson wilson.jim.r@gmail.com wrote:
Thanks for bringing this up, Jim.
For reference, what he's referring to is the practice of creating one's own hooks from within an extension. In this case, we did so via a line like this:
wgRunHooks('PagesOnDemand', array( &$title, &$article));
The key here being that it would be up to another extension to hook onto 'PagesOnDemand' and perform some processing. (We refer to these extensions as 'extension modules' casually amongst ourselves to distinguish them from first-order extensions).
The question is, should we document publicly (other than in our own documentation) the hook "PagesOnDemand" in order to reduce the likelihood of collisions with other extensions' hooks? If so, where would be a good place for it?
This presupposes - to an extent - that others also are in the practice of writing "meta extensions" - extensions which provide hooks for other extensions. I'm not sure how widely this is done.
Regarding Cite in particular - it would be useful to some if there were strategically placed calls to wfRunHooks which expose some of the internals to third-party extensions.
In Jim's case, he needs to be able to modify a <ref>'s inner text based on the value of the 'name' key (if provided). This could be met by injecting the following at the beginning of the stack() method:
wfRunHooks('CiteBeforeStack', array( &$str, &$key ));
''Note: I'll be happy to provide a patch if necessary''
He could then hook 'CiteBeforeStack' and modify $str to be whatever he needed. As it is today, he hacks the Cite extension to do what he wants.
So, in general, what is the community's standpoint on extensions hooking into extensions? Is this encouraged, discouraged, common or uncommon? We'd like to hear your thoughts.
Thanks in advance,
Jim R. Wilson (jimbojw)
On 2/21/07, Jim Hu < jimhu@tamu.edu> wrote:
There are cases where it would be useful to run hooks from inside extensions. For example, there's a hook in an extension that Jim Wilson and I just wrote, and I wish there were hooks in Cite.php.
Seems to me that this should be accompanied by registering the hook name with mediawiki to avoid name collisions. Should extension authors just go and add these to the mediawiki.org and meta hooks documentation? Or should there be some recommendation for hook names from extensions?
Jim
Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
Well, the good old-fashioned way to reduce the likelihood of collisions is just to name it using some prefix convention like "MyExtensionName_" (assuming your extension name isn't some common English word). That should be effective.
On Wed, 2007-21-02 at 20:55 -0500, Simetrical wrote:
Well, the good old-fashioned way to reduce the likelihood of collisions is just to name it using some prefix convention like "MyExtensionName_" (assuming your extension name isn't some common English word). That should be effective.
There simply aren't enough extensions out there that this could be a problem.
If someone's concerned, using a page on the MediaWiki wiki like http://www.mediawiki.org/wiki/Hooks_Registry to maintain a list of hooks in extensions would probably be more than adequate.
~Evan
________________________________________________________________________ Evan Prodromou evan@prodromou.name http://evan.prodromou.name/
OK, on the "Be bold" principle, I created a page on mediawiki.org
http://www.mediawiki.org/wiki/Extension_Hooks_Registry
This is a slight variation on the page name suggested by Evan. I linked to it from
http://www.mediawiki.org/wiki/Category:Extensions ===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On Feb 22, 2007, at 3:17 PM, Evan Prodromou wrote:
On Wed, 2007-21-02 at 20:55 -0500, Simetrical wrote:
Well, the good old-fashioned way to reduce the likelihood of collisions is just to name it using some prefix convention like "MyExtensionName_" (assuming your extension name isn't some common English word). That should be effective.
There simply aren't enough extensions out there that this could be a problem.
If someone's concerned, using a page on the MediaWiki wiki like http://www.mediawiki.org/wiki/Hooks_Registry to maintain a list of hooks in extensions would probably be more than adequate.
~Evan
__ Evan Prodromou evan@prodromou.name http://evan.prodromou.name/ _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org