Hi all,
FOG Running Version 1.4.4 SVN Revision: 6077
Working on a plugin, I’m using the hooks method to call code on GROUP_DEPLOY_HOST:
->register(
'GROUP_DEPLOY_POST',
array(
$this,
'groupDeployPost'
)
)
So then my function “groupDeployPost” contains code like this:
public function groupDeployPost($arguments)
{
global $node;
global $sub;
global $id;
global $type;
if (!in_array($this->node, (array)self::$pluginsinstalled)) {
return;
}
self::getClass('MyPluginClass')->myclass_setvlan(113,"666",0);
}
(Note I’ve obviously cut a lot of it down, just to give an example.)
Now in MyPluginClass I have the function myclass_setvlan and I can call that from pretty much anywhere else (I do on the host display screens, other php pages, etc) so I know that calling the class and the function work great.
However, in this hook it doesn’t work, in fact there are a lot of defined variables, functions, etc that DO NOT work just in this GROUP_DEPLOY_POST hook, which makes me think this is different somehow. (e.g. it works on HOST_TASKING_COMPLETE or HOST_FIELDS etc)
I get the failure:
[Wed Jan 31 12:21:04.094317 2018] [php7:error] [pid 23333] [client x.x.x.x:12990] PHP Fatal error: Uncaught Error: Call to a member function getClass() on null in /var/www/fog/lib/plugins/myplugin/class/myplugin.class.php:49\nStack trace:\n#0 /var/www/fog/lib/plugins/myplugin/hooks/addmypluginhost.hook.php(461): MyPluginClass->myclass_setvlan('113', '666', 0)\n#1 /var/www/fog/lib/fog/hookmanager.class.php(83): AddMyPluginHost->groupDeployPost(Array)\n#2 /var/www/fog/lib/fog/fogpage.class.php(1372): HookManager->processEvent('GROUP_DEPLOY_PO...')\n#3 /var/www/fog/lib/fog/fogpagemanager.class.php(257): FOGPage->deployPost()\n#4 /var/www/fog/management/index.php(58): FOGPageManager->render()\n#5 {main}\n thrown in /var/www/fog/lib/plugins/myplugin/class/myplugin.class.php on line 49, referer: http://x.x.x.x/fog/management/index.php?node=group&sub=deploy&type=8&id=18
This makes me think there is something missing from the core code hook that’s not passing variables/classes through? Is there a quick and dirty way of forcing this to work, perhaps by referencing my class/php file directly as an include at this point? Just to get me working!
Thanks in advance.