Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

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

 

Show Printable Version Email this Page Subscription
Brad Brad is offline 08-29-2006, 10:00 PM

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:

Quote:
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:

PHP Code:
$var 'option1';
$array = array('option2''option3''option4');

$array array_merge($var$array); 
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:

PHP Code:
$var 'option1';
$array = array('option2''option3''option4');

$array array_merge((array)$var$array); 
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.
Reply With Quote
  #12  
Old 03-18-2008, 11:17 AM
Abe1's Avatar
Abe1 Abe1 is offline
 
Join Date: Feb 2004
Location: I LOVE New York!
Posts: 2,886
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
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:
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; 
                }
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.
Reply With Quote
  #13  
Old 03-19-2008, 12:14 AM
dancue dancue is offline
 
Join Date: Feb 2008
Posts: 569
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That worked Abe, Thanks!!
Reply With Quote
  #14  
Old 03-22-2008, 08:26 AM
dave9720 dave9720 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.usergroupi d
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'] . "&amp;dateline=$teamuserinfo[profilepicdateline]&amp;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 [DATE]1206188832[/DATE] at [TIME]1206188832[/TIME] ---------------

Never Mind Abe1, Found the problem in vbshout.
Reply With Quote
  #15  
Old 04-02-2008, 04:42 PM
ronnie2112 ronnie2112 is offline
 
Join Date: Mar 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am still getting this error:

Code:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5
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!
Reply With Quote
  #16  
Old 04-02-2008, 10:36 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am getting this error:
Code:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /index.php(539) : eval()'d code on line 264
Line 264 in index.php is:
Code:
{
Line 263 to 271 are:
Code:
if ($values1[0] != $values2[0])
					{
						return ($values1[0] < $values2[0]) ? -1 : 1;
					}
					else
					{
						// Same day events. Check the event start time to order them properly (compare number of seconds from 00:00)
						return ($values1[1] < $values2[1]) ? -1 : 1;
					}
Does anyone have a clue what I can do to resolve this error?
Reply With Quote
  #17  
Old 04-03-2008, 08:28 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

index.php(539)

Your error is the code evaluated on line 539. That will tell you what Hook Location it is. then you need to go to the Plugin Manager and find a Plugin with this Hook Location. Goto to line 264 of the Plugin and your error should be present. (If you have more then one Plugin at that hook disable them and enable them one by one to find out which of them is causing the error, (n.b. the line number of the eval()'d code may change at this point).
Reply With Quote
  #18  
Old 04-03-2008, 07:33 PM
Alfa1's Avatar
Alfa1 Alfa1 is offline
 
Join Date: Dec 2005
Location: Netherlands
Posts: 3,537
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Many thanks. Your help showed me the plugin that caused this: "Just join us" in Forumhome affected the hook location forumhome_complete.

How do I find line 264 of the plugin?

here is the content of the plugin:
PHP Code:
if($vbulletin->options['justjoin_active'] == 1) {
                    
$userid $vbulletin->userinfo['userid']; 
                    
$languageid $vbulletin->userinfo['languageid'];
                    
$user $vbulletin->db->query_first_slave("
                        SELECT language.phrasegroup_justjoin AS phrasegroup_justjoin
                        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_justjoin"]);
                    
$vbphrase array_merge((array)$vbphrase$tmp);
                
                require_once(
'includes/functions_user.php');
                require_once(
'includes/functions_bigthree.php');

                
$limit $vbulletin->options['justjoin_count'];
                
$joinus $vbulletin->db->query_read(
                  SELECT *
                  FROM "
.TABLE_PREFIX."user
                        WHERE usergroupid=2
                  ORDER BY joindate DESC
                  LIMIT 
$limit
                "
); 
                while (
$team $vbulletin->db->fetch_array($joinus)){
            
$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'], 11);
                      
$userinfo['lastactivitydate'] = vbdate($vbulletin->options['dateformat'], $userinfo['lastactivity'], true);
                    
$userinfo['lastactivitytime'] = vbdate($vbulletin->options['timeformat'], $userinfo['lastactivity']);
                      
$useronline fetch_online_status($userinfotrue);
                    
$userinfo['onlinestatuskey'] = $userinfo['onlinestatus'];
                    
$totalcount ++;
                    eval(
'$justjoinbits .= "' fetch_template('justjoin_joinbits') . '";');
                } 
                unset(
$teamarray);
                eval(
'$justjoin .= "' fetch_template('justjoin_main') . '";');
                    
$footer '<br />'.$justjoin.$footer;
                } 
I assume it is due to this line:
PHP Code:
$vbphrase array_merge($vbphrase$tmp); 
How can I fix this?
Reply With Quote
  #19  
Old 04-15-2008, 03:37 AM
xgc ottomatic xgc ottomatic is offline
 
Join Date: Oct 2006
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Brad the post helped me fix the problem.
My issue was in the
vBShout [Template Cache]
for anyone else that has that plugin

fyi: my error was
array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5
Reply With Quote
  #20  
Old 04-18-2008, 05:30 PM
jeddah_eyes jeddah_eyes is offline
 
Join Date: Aug 2005
Location: ksa
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


what i can do ?
Reply With Quote
  #21  
Old 04-19-2008, 04:53 AM
Rocc Rocc is offline
 
Join Date: Mar 2008
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

I get that on profiles, and when i check line 5 of Functions.php
And its just
"|| # ---------------------------------------------------------------- # ||"
So, what am i supposed to do?

--------------- Added [DATE]1208584604[/DATE] at [TIME]1208584604[/TIME] ---------------

Quote:
Originally Posted by xgc ottomatic View Post
Thanks Brad the post helped me fix the problem.
My issue was in the
vBShout [Template Cache]
for anyone else that has that plugin

fyi: my error was
array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 5
Thanks dude, helped me!
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08650 seconds
  • Memory Usage 2,358KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (4)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete