|
|
| Author |
Message |
nifi
Joined: 06 Aug 2006 Posts: 13
|
Posted: Mon Mar 03, 2008 10:21 pm Post subject: Warning: reset(): ....../cacti/lib/functions.php on line 146 |
|
|
i used cacti0.8.7b and PA2
with no PA2,my cacti works ok,but after i patch the PA2,and i have changed the global.php,plugins.php and so on,there is a warning message to me:
Warning: reset(): Passed variable is not an array or object in /var/www/cacti/lib/functions.php on line 146
Warning: Variable passed to each() is not an array or object in /var/www/cacti/lib/functions.php on line 147
i searched in forums,but have no idea to solve it.i don't know what should i do!
about pa.sql,should i import it into cacti.sql,or replace the cacti.sql with pa.sql? |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Tue Mar 04, 2008 9:29 pm Post subject: |
|
|
I saw a note related to this the other day. I asked the user to fill out a bug report at http://bugs.cacti.net. Check there, or google the reset() thingy. It had something to do with PHP versions and the user posted a fix.
TheWitness |
|
| Back to top |
|
 |
incudie
Joined: 06 Mar 2008 Posts: 21
|
Posted: Thu Mar 06, 2008 12:12 pm Post subject: |
|
|
Nifi have you had any luck finding a resolution?
I have run into the same problem after a fresh install and am currently looking for a solution. Have not had any luck finding what TheWitness was referencing.
If you have any more information that would be appreciated,
Thanks |
|
| Back to top |
|
 |
nifi
Joined: 06 Aug 2006 Posts: 13
|
Posted: Fri Mar 07, 2008 2:24 am Post subject: |
|
|
| I have no idea yet! |
|
| Back to top |
|
 |
incudie
Joined: 06 Mar 2008 Posts: 21
|
Posted: Fri Mar 07, 2008 11:43 am Post subject: |
|
|
| Hmm do you happen to be running apache2 and php5 by any chance? |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Sun Mar 16, 2008 10:37 pm Post subject: |
|
|
This would appear to be plugin related. I am experiencing it now. Superlinks was causing the issue. Don't know why as of yet.
TheWitness |
|
| Back to top |
|
 |
incudie
Joined: 06 Mar 2008 Posts: 21
|
Posted: Mon Mar 17, 2008 10:49 am Post subject: |
|
|
So far I have had this problem with only the latest plugin architecture installed (without any plugins). But for comparison to anyone else here are my plugins,
| Code: | $plugins = array();
$plugins[] = 'aggregate';
$plugins[] = 'reportit';
$plugins[] = 'monitor';
$plugins[] = 'settings';
$plugins[] = 'thold';
$plugins[] = 'tools';
$plugins[] = 'reports';
$plugins[] = 'killspike';
$plugins[] = 'weathermap';
|
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Mon Mar 17, 2008 2:53 pm Post subject: |
|
|
The fix is as follows:
Edit lib/functions.php and change the code at or about line 125 to the code below:
| Code: | if (is_array($settings)) {
reset($settings);
while (list($tab_name, $tab_array) = each($settings)) {
if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
return $tab_array[$config_name]["default"];
}else{
while (list($field_name, $field_array) = each($tab_array)) {
if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name])) && (isset($field_array["items"][$config_name]["default"]))) {
return $field_array["items"][$config_name]["default"];
}
}
}
}
} |
This should solve the problem. Don't forget to backup you file first.
Regards,
TheWitenss |
|
| Back to top |
|
 |
incudie
Joined: 06 Mar 2008 Posts: 21
|
Posted: Mon Mar 17, 2008 5:17 pm Post subject: Resolved |
|
|
TheWitness 's change has successfully resolved my issue.
(Lot better than having errors turned off in php...)
Thank you very much Sir!
--Incudie |
|
| Back to top |
|
 |
outbreakmonkey
Joined: 25 Mar 2008 Posts: 2
|
Posted: Tue Mar 25, 2008 10:31 pm Post subject: |
|
|
I upgraded from 8.6i to 8.7b and as well as the adodb.inc.php issue, I have encountered this reset() problem.
I applied the fix as suggested but it completely breaks cacti.
The error message I get instead is
Parse error: syntax error, unexpected $end in /usr/share/cacti/site/lib/functions.php on line 1942 |
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2135 Location: United Kingdom
|
Posted: Wed Mar 26, 2008 3:16 am Post subject: |
|
|
| outbreakmonkey wrote: | I upgraded from 8.6i to 8.7b and as well as the adodb.inc.php issue, I have encountered this reset() problem.
I applied the fix as suggested but it completely breaks cacti.
The error message I get instead is
Parse error: syntax error, unexpected $end in /usr/share/cacti/site/lib/functions.php on line 1942 |
Get the file back out of the original zip/tar and try again... that's usually a sign that you have missed a } somewhere. |
|
| Back to top |
|
 |
phalek Cacti User
Joined: 31 Jan 2008 Posts: 157 Location: Kressbronn, Germany
|
Posted: Wed Mar 26, 2008 5:21 am Post subject: |
|
|
Hi, I had the same issue and I actually found this related to the $user_auth_real_filenames and the $nav array.
you'll need to have the plugin file (e.g. nimd.php) configured in both arrays. If it's not present in the $nav array, the error you described occurs.
Example:
| Code: |
function nmid_config_arrays () {
...
$user_auth_realm_filenames['nmid.php'] = 1191;
...
}
function nmid_draw_navigation_text ($nav) {
...
$nav["nmid.php:"] = array("title" => "NMID", "mapping" => "index.php:", "url" => "nmid.php", "level" => "1");
...
}
|
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Wed Apr 02, 2008 6:08 am Post subject: |
|
|
I have asked Roman and Ian to publish this patch. Still waiting...
TheWitness |
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2135 Location: United Kingdom
|
Posted: Wed Apr 02, 2008 6:18 am Post subject: |
|
|
| Just so I understand, is this a patch to 'defend' against something bad that superlinks is doing, or is it actually an error in the way Cacti does it? I have never full understood how this particular part of Cacti works internally... |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Wed Apr 02, 2008 6:23 am Post subject: |
|
|
Well, it depends on how you look at it What you are doing in superlinks is making a database connection out of order so that you can modify the various arrays. By doing so, you run into the uninitialized array, which is a bad practice on our part. Ian always warned, don't ever assume an array is initialized by doing something stupid like "reset()" prior to if (is_array(blah)).
So, by doing things out of order, you introduced a new failure mode. However, because I LOVE Superlinks SOOO much, I decided to fix our poor coding.
I think there is another fix, to connect to the database much sooner in the global.php initialization process, but that would require me to think. Since my brain is quite close to exploding, I took the shortcut.
Regards,
Larry |
|
| Back to top |
|
 |
|