Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[Fix How to] PHP 5 and array_merge errors
Brad
Join Date: Nov 2001
Posts: 4,765

Washington
by Brad Brad is offline 30 Aug 2006

If you've upgraded to php 5 on your server you may have seen some of your plug-in's and add-ons throwing errors like this:

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /index.php(486) : eval()'d code on line 79
This is a common error, we updated our server to php 5 yesterday and I've already seen the error come up twice for two plug-ins on our forum. Another site on the server is running vBadvanced, its news module also threw the same error.

The reason this came up is due to a change in the way array_merge works in php 5. Basically it will no longer accept anything but an array without throwing an error. Thankfully it's just an 'incorrect usage' error and our code still works as it should, it just throws an error now.

The correct way to fix this is not using array merge with anything but arrays. However we already have a lot of code lying around doing things like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Obviously most of us aren't looking to re-write some of this code just so it works under php 5. Thankfully there is a very simple fix for this that won't force us to change much of anything.

Just change your code so it looks like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Notice the (array) next to $var now? That is the only change needed. Your code should now work under php 5 and no longer throw array_merge errors.

Last edited by Brad; 30 Aug 2006 at 10:07..
Views: 16644
Reply With Quote
Comments
  #2  
Old 16 Mar 2007, 06:13
Abe1's Avatar
Abe1 Abe1 is offline
 
Join Date: Feb 2004
Real name: Abe
If you do just this change? Will this script work for php4?
__________________
MY HACKS -

Active Link Security 3.0.X | Add Title to Rank Images 3.5.X | Admin Log In As User 3.5.X 3.6.X | Advanced BBCode Permissions 3.5.X 3.6.X | Can't See Attachments Before Thanking a Post 3.5.X | Can't Thank and Groan the Same Post 3.5.X | Delete Post when Giving Infraction 3.6.X | Edit New Thread Button 3.5.X | External Data Provider Usergroup Permissions Setting 3.5.X | Forms Hack 3.5.X, 3.6.X | Log Logins Hack 3.5.X 3.6.X | Moderator Statistics 3.5.X | Post Award Hack 3.0.X 3.5.X | [AJAX] Post Thank You Hack 3.0.X 3.5.X 3.6.X | [AJAX] Post Groan Hack 3.5.X 3.6.X | Post Thank You Hack Stats for vBadvanced CMPS 2.x 3.5.X | Search Title only in search drop-down 3.5.X, 3.6.X | 'vBMenu' DHTML User Option 3.5.X 3.6.X | vBShout on all pages! 3.5.X
Reply With Quote
  #3  
Old 16 Mar 2007, 07:07
Guest190829
Guest
 
Yes, the fix is just type casting the value into the array, however, if you know that you are only adding other types of data on to the array, just use array_push() or $var[] = 'option1';


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #4  
Old 19 May 2007, 10:20
deathemperor's Avatar
deathemperor deathemperor is offline
 
Join Date: Jul 2003
Real name: Lucius Hunk
this small fix helps
Reply With Quote
  #5  
Old 11 Jan 2008, 22:44
mystic10 mystic10 is offline
 
Join Date: Sep 2007
i have the same problem but with functions.php

this is my error: array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5

i tried to look for the above things in fuctions.php but was unscusseful...maybe u can help me as well
Reply With Quote
  #6  
Old 12 Jan 2008, 00:43
Opserty Opserty is offline
 
Join Date: Apr 2007
Originally Posted by mystic10 View Post
Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5

i tried to look for the above things in fuctions.php but was unscusseful...maybe u can help me as well
eval()'d code normally refers to when a template/plugin is executed. Find the plugin(s) that use the hook in functions.php on line 1259, it will be on the 5th line of the Plugin PHP Code.
Reply With Quote
  #7  
Old 18 Feb 2008, 07:25
seangworld's Avatar
seangworld seangworld is offline
 
Join Date: Sep 2002
Real name: Sean G
im fn lost. this sh.it doesnt help when you cant find the stupid code at all. then what the hell is the option 1, 2, 3, 4???
__________________
http://www.seangworld.com
Reply With Quote
  #8  
Old 28 Feb 2008, 19:38
allaf2 allaf2 is offline
 
Join Date: Feb 2007
I have the same problem as mystic10 i get the same error and the error is this (array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5) and i dont know what i should do or what to do can you plz help me
Reply With Quote
  #9  
Old 29 Feb 2008, 20:20
Brad Brad is offline
 
Join Date: Nov 2001
Originally Posted by seangworld View Post
im fn lost. this sh.it doesnt help when you cant find the stupid code at all. then what the hell is the option 1, 2, 3, 4???
If you're having problems finding the code throwing the error you probably shouldn't be poking around in the files in the first place. At the very least you shouldn't be acting all high and mighty and calling my thread "shit".

Try asking nicely for help, and add a please, and include full error messages and I'll try to help you.

Yes I'm an ass hole, but only when provoked. I'm pretty friendly if you come at me with respect.

Originally Posted by allaf2
I have the same problem as mystic10 i get the same error and the error is this (array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5) and i dont know what i should do or what to do can you plz help me
You have an error in one of your plug-ins at the hook located at line 1259 of /includes/functions.php.

Open functions.php and locate that line, on it you'll find a line of code similar to this one:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In the above example "hook_name" is the name of the hook location we need to find.

Once you have the name of the hook location go into the plug-in manager in the admincp and find all plug-ins using that location. The code throwing the error is located in one of them.
Reply With Quote
  #10  
Old 17 Mar 2008, 06:35
dancue dancue is offline
 
Join Date: Feb 2008
This is my error:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /index.php(537) : eval()'d code on line 119

I've found the plug-in causing the error. I opened it saw an array and did as instructed above, but still received the same error.

Can anyone help me with this please?

Here is the code within the plug-in:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by dancue; 17 Mar 2008 at 15:40.
Reply With Quote
  #11  
Old 18 Mar 2008, 13:17
Abe1's Avatar
Abe1 Abe1 is offline
 
Join Date: Feb 2004
Real name: Abe
Originally Posted by dancue View Post
This is my error:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /index.php(537) : eval()'d code on line 119

I've found the plug-in causing the error. I opened it saw an array and did as instructed above, but still received the same error.

Can anyone help me with this please?

Here is the code within the plug-in:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Try changing this:
$tmp = unserialize($user["phrasegroup_siteteam"]);
to this:
$tmp[] = unserialize($user["phrasegroup_siteteam"]);

You have to feed it an array in order for you not to get an error.
__________________
MY HACKS -

Active Link Security 3.0.X | Add Title to Rank Images 3.5.X | Admin Log In As User 3.5.X 3.6.X | Advanced BBCode Permissions 3.5.X 3.6.X | Can't See Attachments Before Thanking a Post 3.5.X | Can't Thank and Groan the Same Post 3.5.X | Delete Post when Giving Infraction 3.6.X | Edit New Thread Button 3.5.X | External Data Provider Usergroup Permissions Setting 3.5.X | Forms Hack 3.5.X, 3.6.X | Log Logins Hack 3.5.X 3.6.X | Moderator Statistics 3.5.X | Post Award Hack 3.0.X 3.5.X | [AJAX] Post Thank You Hack 3.0.X 3.5.X 3.6.X | [AJAX] Post Groan Hack 3.5.X 3.6.X | Post Thank You Hack Stats for vBadvanced CMPS 2.x 3.5.X | Search Title only in search drop-down 3.5.X, 3.6.X | 'vBMenu' DHTML User Option 3.5.X 3.6.X | vBShout on all pages! 3.5.X
Reply With Quote
  #12  
Old 19 Mar 2008, 02:14
dancue dancue is offline
 
Join Date: Feb 2008
That worked Abe, Thanks!!
Reply With Quote
  #13  
Old 22 Mar 2008, 10:26
dave9720 dave9720 is offline
 
Join Date: Dec 2007
Abe1 Can you help me with my problem?
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5

Plugin Code;
if($vbulletin->options['siteteam_active'] == 1) {
$userid = $vbulletin->userinfo['userid'];
$languageid = $vbulletin->userinfo['languageid'];
$user = $vbulletin->db->query_first_slave("
SELECT language.phrasegroup_siteteam AS phrasegroup_siteteam
FROM ".TABLE_PREFIX."user AS user
LEFT JOIN ".TABLE_PREFIX."language AS language
ON (language.languageid = " . (!empty($languageid) ? $languageid : "IF(user.languageid = 0, " . intval($vbulletin->options['languageid']) . ", user.languageid)") . ")
WHERE user.userid = $userid
");
$tmp[] = unserialize($user["phrasegroup_siteteam"]);
$vbphrase = array_merge($vbphrase, $tmp);

require_once('includes/functions_user.php');
require_once('includes/functions_bigthree.php');

$limit = $vbulletin->options['siteteam_count'];
$teamarray = $vbulletin->db->query_read("
SELECT *
FROM ".TABLE_PREFIX."user
JOIN ".TABLE_PREFIX."usergroup AS ugroup
ON ugroup.usergroupid=".TABLE_PREFIX."user.usergroupid
LEFT JOIN ".TABLE_PREFIX."usergroup
ON (FIND_IN_SET(".TABLE_PREFIX."usergroup.usergroupid, ".TABLE_PREFIX."user.membergroupids))
WHERE ugroup.siteteam=1 OR ".TABLE_PREFIX."usergroup.siteteam=1
GROUP BY ".TABLE_PREFIX."user.userid
ORDER BY RAND()
LIMIT $limit
");
while ($team = $vbulletin->db->fetch_array($teamarray)){
if($vbulletin->options['siteteam_type']== 1) {
$avatarurl = fetch_avatar_url($team['userid']);
if (!$avatarurl) {
$teamavatar = 'images/misc/noavatar.gif';
} else {
$teamavatar = $vbulletin->options['bburl'] . '/' . $avatarurl[0];
}
} else {
$teamavatar = '';
$teamuserinfo = verify_id('user', $team['userid'], 1, 1, 47);
$showprofilepic = ($vbulletin->options['profilepicenabled'] AND
$teamuserinfo['profilepic'] AND
($permissions['genericpermissions'] &
$vbulletin->bf_ugp_genericpermissions['canseeprofilepic'] OR
$vbulletin->userinfo['userid'] == $teamuserinfo['userid'])) ? true : false;
if($vbulletin->options['usefileavatar']) {
$teamavatar = $vbulletin->options['profilepicurl'] . '/profilepic' . $teamuserinfo['userid'] . '_' . $teamuserinfo['profilepicrevision'] . '.gif';
} else {
$teamavatar = 'image.php?' . $vbulletin->session->vars['sessionurl'] . 'u=' . $teamuserinfo['userid'] . "&dateline=$teamuserinfo[profilepicdateline]&type=profile";
}

if(empty($teamavatar) || !$showprofilepic) {
$avatarurl = fetch_avatar_url($team['userid']);
if(!$avatarurl) {
$teamavatar = 'images/misc/noavatar.gif';
} else {
$teamavatar = $vbulletin->options['bburl'] . '/' . $avatarurl[0];
}
}
}
$userinfo = verify_id('user', $team['userid'], 1, 1);
$userinfo['lastactivitydate'] = vbdate($vbulletin->options['dateformat'], $userinfo['lastactivity'], true);
$userinfo['lastactivitytime'] = vbdate($vbulletin->options['timeformat'], $userinfo['lastactivity']);
$useronline = fetch_online_status($userinfo, true);
$userinfo['onlinestatuskey'] = $userinfo['onlinestatus'];
$totalcount ++;
eval('$teambits .= "' . fetch_template('siteteam_teambits') . '";');
}
unset($teamarray);

eval('$meetteams .= "' . fetch_template('siteteam_main') . '";');

$footer = '<br />'.$meetteams.$footer;
}

--------------- Added 22 Mar 2008 at 13:27 ---------------

Never Mind Abe1, Found the problem in vbshout.

Last edited by dave9720; 22 Mar 2008 at 13:27. Reason: Auto-Merged DoublePost
Reply With Quote
  #14  
Old 02 Apr 2008, 18:42
ronnie2112 ronnie2112 is offline
 
Join Date: Mar 2008
I am still getting this error:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Im confused as to how to fix it. I tried doing this below but it did not work:

Try changing this in the plugin named "Show Meet our team at forum home page":

$tmp = unserialize($user["phrasegroup_siteteam"]);

To this:

$tmp[] = unserialize($user["phrasegroup_siteteam"]);


I know that the error began and is caused by the plugin called "Site Team Version 1.1.0 for VB version 3.6.8

Where or what do I look for to edit and in which files to fix this error or stop it from being thrown. The Plugin actually functions, I just get the error code seen at the top of the forum page. If I turn off the SiteTeam plugin or make it in-active then the error goes away. It also started giving me that error right after I installed the plugin "SiteTeam v1.1.0" so I am certain that this is where the problem lies correct?

So what exactly do I edit to fix this? Im very confused.

Thank you!

Last edited by ronnie2112; 02 Apr 2008 at 19:10.
Reply With Quote
  #15  
Old 03 Apr 2008, 00:36
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
I am getting this error:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Line 264 in index.php is:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Line 263 to 271 are:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Does anyone have a clue what I can do to resolve this error?
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 21:35.

Layout Options | Width: Wide Color: