PHP Warning: array_merge(): Argument #1 is not an array

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
doiggl
Cacti User
Posts: 222
Joined: Wed Dec 16, 2009 6:32 am

PHP Warning: array_merge(): Argument #1 is not an array

Post by doiggl »

# perl add_device.php --description="BiPAC 7401VGPR3" --ip=192.168.1.254 --template=1 --version=2 --community="public"
PHP Notice: Undefined variable: plugins in /usr/share/cacti/include/plugins.php on line 31
PHP Warning: array_merge(): Argument #1 is not an array in /usr/share/cacti/include/plugins.php on line 31
Adding BiPAC 7401VGPR3 (192.168.1.254) as "Generic SNMP-enabled Host" using SNMP v2 with community "public"
Success - new device-id: (4)

Looks like its its complaining about this section of code. Any ideas on how to fix. Thanks Glenn ?
Software installed - cacti-0.8.7g and cacti-plugin-0.8.7g-PA-v2.8 and autom8-v0.35.

# head -31 /usr/share/cacti/include/plugins.php | tail

/**
* This function executes a hook.
* @param string $name Name of hook to fire
* @return mixed $data
*/

$oldplugins = read_config_option('oldplugins');
$oldplugins = explode(',', $oldplugins);
$plugins = array_merge($plugins, $oldplugins);
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: PHP Warning: array_merge(): Argument #1 is not an array

Post by gandalf »

If possible, use PIA 2.9
To cure the error, please change function to look like

Code: Select all

/**
 * This function executes a hook.
 * @param string $name Name of hook to fire
 * @return mixed $data
 */
if (!is_array($plugins)) {
	$plugins = array();
}

$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
	$oldplugins = explode(',', $oldplugins);
	$plugins    = array_merge($plugins, $oldplugins);
}
R.
smehra76
Posts: 1
Joined: Tue May 17, 2011 3:05 am

Re: PHP Warning: array_merge(): Argument #1 is not an array

Post by smehra76 »

Hello,
I still continue to have issues even after changing the fuctions. My include/plugin.php looks as follows
<?php

/*
* Copyright (c) 1999-2005 The SquirrelMail Project Team (http://squirrelmail.org)
* Licensed under the GNU GPL. For full terms see the file COPYING.
*/


global $plugin_hooks, $plugins_system;
$plugin_hooks = array();
$plugins_system = array('settings', 'boost', 'dsstats');

function use_plugin ($name) {
global $config;
if (file_exists($config['base_path'] . "/plugins/$name/setup.php")) {
include_once($config['base_path'] . "/plugins/$name/setup.php");
$function = "plugin_init_$name";
if (function_exists($function)) {
$function();
}
}
}

/**
* This function executes a hook.
* @param string $name Name of hook to fire
* @return mixed $data
*/

if (!is_array($plugins)) {
$plugins = array();
}

$oldplugins = read_config_option('oldplugins');
if (strlen(trim($oldplugins))) {
$oldplugins = explode(',', $oldplugins);
$plugins = array_merge($plugins, $oldplugins);
}


/* On startup, register all plugins configured for use. */
if (isset($plugins) && is_array($plugins)) {
foreach ($plugins as $name) {
use_plugin($name);
}
}


And the error still remains.

PHP Notice: Undefined variable: plugins in /var/www/html/cacti/include/plugins.php on line 30, referer: http://<server ip>/cacti/index.php
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: PHP Warning: array_merge(): Argument #1 is not an array

Post by gandalf »

Did you import pa.sql into cacti database?
R.
jmwallach
Posts: 1
Joined: Tue Oct 04, 2011 1:32 pm

Re: PHP Warning: array_merge(): Argument #1 is not an array

Post by jmwallach »

Greetings,

Running in to the same problem even with the suggested changes to plugin.php. Did you ever get this resolved?

Thanks,
jmw
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: PHP Warning: array_merge(): Argument #1 is not an array

Post by TheWitness »

I suggest that you don't change base PIA files. The only file you need to change in Cacti 0.8.7h should be config.php.

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?
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests