PDA

View Full Version : Error with plugin, only occurs for some people?


Ted S
11-06-2005, 10:00 PM
A plugin I released seems to be causing some errors for people, although I can not duplicate it. Can anyone find an issue with this code:

<plugins>
<plugin active="1">
<title><![CDATA[Inactivity Timer [Optional]]]></title>
<hookname>global_start</hookname>
<phpcode><![CDATA[$headerstime = time();]]></phpcode>
</plugin>
<plugin active="1">
<title><![CDATA[Welcome Headers [Alteration]]]></title>
<hookname>parse_templates</hookname>
<phpcode><![CDATA[
eval('$welcomeheaders = "' . fetch_template('welcome_headers') . '";');
]]></phpcode>
</plugin>
<plugin active="1">
<title><![CDATA[Welcome Headers [Template Cache]]]></title>
<hookname>fetch_userinfo</hookname>
<phpcode><![CDATA[
global $globaltemplates;
$globaltemplates = array_merge($globaltemplates, array('welcome_headers'));
]]></phpcode>
</plugin>
</plugins>

And the error peopel get:

I get an error at the top of the any of thr "Plugin Sytem" menu areas in the acp that says:

---------------------------------
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1051) : eval()'d code on line 9
---------------------------------

It seems though, when I goto the "Plugin Manager" and uncheck the "Hook Location : "Welcome Headers [Alteration]" under the "parse_templates" section, the error goes away.

Boofo
11-06-2005, 11:43 PM
Try changing this:

<hookname>fetch_userinfo</hookname>

to the cache_templates hook.

Paul M
11-07-2005, 12:12 AM
and after changing the hook location, change the code for that hook to this ;

$globaltemplates[] = 'welcome_headers';

Ted S
11-07-2005, 12:13 AM
Thanks guys!

Andreas
11-07-2005, 12:16 AM
Yes. array_merge() for a template that surely isn't already in $globatemplates isn't really necessary; use the assignment as Paul M suggested.

Ted S
11-07-2005, 12:27 AM
Will do! I'll post back if this solves the isse. Thanks again!

Boofo
11-07-2005, 12:48 AM
Yes. array_merge() for a template that surely isn't already in $globatemplates isn't really necessary; use the assignment as Paul M suggested.

Won't either way work, though?