Hello,
I'm having a little trouble getting a custom hook to perform the actions I
want
it to after upgrading from PHP 5.3 / MW 1.19.2 to PHP 5.4 / MW 1.22.3.
I am hacking an existing extension, ProcessCite, that integrates into the
Cite
extension by adding a custom hook to one of Cite's functions:
# from Cite_body.php
function stack( $str, $key = null, $group, $follow, $call ) {
# add the call to the CiteBeforeStackEntry hook
wfRunHooks( 'CiteBeforeStackEntry', array( &$str, &$call ) );
ProcessCite runs code that creates a value for $str based on the contents of
$call. Here are the relevant parts of ProcessCite:
# Declare the hook:
$wgHooks['CiteBeforeStackEntry'][] = 'wfProcessCite';
# the function itself
function wfProcessCite($str, $argv){
# process $argv and $str to create a new version of $str
# $argv remains unchanged, $str is set to new value
$str = "new string";
return true;
}
Debug statements reveal that wfProcessCite is creating the correct value for
$str, but the value is not altered when wfProcessCite finishes. I am not
sure
if I am calling the hook in the wrong way, given that I want to alter the
value of $str.
The MW manual page on hooks (
http://www.mediawiki.org/wiki/Manual:Hooks) is
somewhat confusing -- what is the difference between passing $someData to a
function versus passing a set of parameters?!
Any help would be appreciated!
Thank you,
Amelia.
--
Amelia Ireland
GMOD Community Support
Generic Model Organism Database project
http://gmod.org || @gmodproject