Warning: reset(): ....../cacti/lib/functions.php on line 146

Support for the Plugin Architecture

Moderators: Developers, Moderators

nifi
Posts: 15
Joined: Sun Aug 06, 2006 8:08 pm
Location: zhengzhou.china

Warning: reset(): ....../cacti/lib/functions.php on line 146

Post by nifi »

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?
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

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
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
incudie
Posts: 21
Joined: Thu Mar 06, 2008 12:03 pm

Post by incudie »

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
nifi
Posts: 15
Joined: Sun Aug 06, 2006 8:08 pm
Location: zhengzhou.china

Post by nifi »

I have no idea yet!
incudie
Posts: 21
Joined: Thu Mar 06, 2008 12:03 pm

Post by incudie »

Hmm do you happen to be running apache2 and php5 by any chance?
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

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
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
incudie
Posts: 21
Joined: Thu Mar 06, 2008 12:03 pm

Post by incudie »

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: Select all

$plugins = array();
$plugins[] = 'aggregate';
$plugins[] = 'reportit';
$plugins[] = 'monitor';
$plugins[] = 'settings';
$plugins[] = 'thold';
$plugins[] = 'tools';
$plugins[] = 'reports';
$plugins[] = 'killspike';
$plugins[] = 'weathermap';
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

The fix is as follows:

Edit lib/functions.php and change the code at or about line 125 to the code below:

Code: Select all

	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
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
incudie
Posts: 21
Joined: Thu Mar 06, 2008 12:03 pm

Resolved

Post by incudie »

TheWitness 's change has successfully resolved my issue.

(Lot better than having errors turned off in php...)

Thank you very much Sir!

--Incudie
outbreakmonkey
Posts: 2
Joined: Tue Mar 25, 2008 1:05 am

Post by outbreakmonkey »

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
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

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.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

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: Select all

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");
...
}
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

I have asked Roman and Ian to publish this patch. Still waiting...

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

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...
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
TheWitness
Developer
Posts: 17062
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

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
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest