PDA

View Full Version : PHP Warning: Illegal string offset 'usergroupid' in


farsgsm
06-10-2017, 06:35 PM
Dear friends,
I recently upgraded php to ver 5.6
i checked error logs of vbulletin and saw these errors.
would u please let me know how can fix it or replace to correct string?!

[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/user/public_html/includes/functions.php on line 383
[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/user/public_html/includes/functions.php on line 449
[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'userid' in /home/user/public_html/includes/functions.php on line 449
[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'userid' in /home/user/public_html/includes/functions.php on line 440
[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/user/public_html/includes/functions.php on line 449

Dave
06-10-2017, 06:53 PM
What vBulletin version are you using?

You may have to update your vBulletin version to a version that supports PHP 5.6+ in order to get rid of these errors. Unless of course you don't mind making manual modifications to the /includes/functions.php file.

farsgsm
06-12-2017, 11:19 AM
using:
vBulletin® v3.8.11, Copyright ©2000-2017, vBulletin Solutions Inc.

I think this version supportes php 5.6+

Paul M
06-12-2017, 11:48 AM
First of all, those line numbers dont match up with the default functions.php for 3.8.11, which makes me wonder if you have the correct files uploaded.

Secondly, they are due to invalid data being passed to core functions, which indicates you have an issue elsewhere, in a modification maybe.

farsgsm
06-13-2017, 08:59 AM
thanks for your reply
here is what my functions.php have on mentioned lines
maybe can help find problem:

[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/user/public_html/includes/functions.php on line 383

$membergroups[] = $user['usergroupid'];


[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/user/public_html/includes/functions.php on line 449

if ($userinfo['usergroupid'] == $usergroupid OR in_array($usergroupid, $user_memberships["$userinfo[userid]"]))


[10-Jun-2017 20:16:42 UTC] PHP Warning: Illegal string offset 'userid' in /home/user/public_html/includes/functions.php on line 440

if (!is_array($user_memberships["$userinfo[userid]"]) OR !$cache)

Paul M
06-13-2017, 10:36 AM
I already told you what the actual problem is :)

... they are due to invalid data being passed to core functions ...


Which as I also said, indicates you have an issue elsewhere, probably in a modification thats calling the functions.

farsgsm
06-13-2017, 10:45 AM
ok thanks, ill check modifications
and u have same idea on errors below?

[13-Jun-2017 12:43:58 UTC] PHP Deprecated: Function split() is deprecated in /home/user/public_html/global.php(607) : eval()'d code on line 297
[13-Jun-2017 12:43:58 UTC] PHP Deprecated: Function split() is deprecated in /home/user/public_html/global.php(607) : eval()'d code on line 311

[13-Jun-2017 12:47:25 UTC] PHP Deprecated: Assigning the return value of new by reference is deprecated in /home/user/public_html/misc.php(100) : eval()'d code on line 834

MarkFL
06-13-2017, 12:20 PM
ok thanks, ill check modifications
and u have same idea on errors below?

[13-Jun-2017 12:43:58 UTC] PHP Deprecated: Function split() is deprecated in /home/user/public_html/global.php(607) : eval()'d code on line 297
[13-Jun-2017 12:43:58 UTC] PHP Deprecated: Function split() is deprecated in /home/user/public_html/global.php(607) : eval()'d code on line 311

You need to find where the split() function is being used and replace those with the explode() function.

[13-Jun-2017 12:47:25 UTC] PHP Deprecated: Assigning the return value of new by reference is deprecated in /home/user/public_html/misc.php(100) : eval()'d code on line 834

In line 100 of misc.php, you will likely find "=&" being used...replace that with just "=".

farsgsm
06-13-2017, 12:52 PM
You need to find where the split() function is being used and replace those with the explode() function.

In line 100 of misc.php, you will likely find "=&" being used...replace that with just "=".

its what the misc.php line 100 contains:
($hook = vBulletinHook::fetch_hook('misc_start')) ? eval($hook) : false;

here is the only split that i have found on global.php
$val = preg_split('#\n#', $vbulletin->GPC['vbulletin_collapse'], -1, PREG_SPLIT_NO_EMPTY);

please advise how to fix the functions

MarkFL
06-13-2017, 01:04 PM
its what the misc.php line 100 contains:
($hook = vBulletinHook::fetch_hook('misc_start')) ? eval($hook) : false;

Yes, I was mistaken...there is code being evaluated at that hook with the deprecated code in it. Try to find the "=&" operator being used in a plugin hooked at "misc_start".

here is the only split that i have found on global.php
$val = preg_split('#\n#', $vbulletin->GPC['vbulletin_collapse'], -1, PREG_SPLIT_NO_EMPTY);

please advise how to fix the functions

The deprecated functions won't be in the "global.pho" file itself, but rather in code executed at the plugin hook locations specified at those given lines.

To make finding text within your plugins much easier, I highly recommend installing this product:

Search Plugins (https://vborg.vbsupport.ru/showthread.php?t=265976)

oldengine
09-08-2019, 04:51 PM
Admin Control Panel (vBulletin 3.8.11) PHP 7.1

[08-Sep-2019 18:18:50 UTC] PHP Warning: Illegal string offset 'userid' in /home/smoky/public_html/forum/includes/functions.php on line 439
[08-Sep-2019 18:18:50 UTC] PHP Warning: Illegal string offset 'userid' in /home/smoky/public_html/forum/includes/functions.php on line 442
[08-Sep-2019 18:18:50 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/smoky/public_html/forum/includes/functions.php on line 382
[08-Sep-2019 18:18:50 UTC] PHP Warning: Illegal string offset 'usergroupid' in /home/smoky/public_html/forum/includes/functions.php on line 448
[08-Sep-2019 18:18:50 UTC] PHP Warning: Illegal string offset 'userid' in /home/smoky/public_html/forum/includes/functions.php on line 448

These are likely to be in the calendar Plugin Event Attendance - show/enroll
The question is where?


//Check time till event
$time_until_event=$eventinfo['dateline_from']-(TIMENOW+$vbulletion->userinfo['timezoneoffset']*3600);
if ($vbulletin->userinfo['dstonoff'])
{
$time_until_event=$time_until_event-3600;
}
//echo $time_until_event." ";
$show['enroll']=(($time_until_event>0) || ($vbulletin->options['lateenroll'])) ? true : false;


//Enroll/Cancel
if ($_REQUEST['ea'] == "attend" || $_REQUEST['ea'] == "unattend" AND ($time_until_event>0 OR $vbulletin->options['lateenroll']) )
{
if (!$eventinfo['roll'])
{
$roll = array();
}
else
{
$roll = @unserialize($eventinfo['roll']);
}

if ($_REQUEST['ea'] == "attend")
{
if ($vbulletin->userinfo[userid])
{
$roll[$vbulletin->userinfo['userid']] = $vbulletin->userinfo['username'];
}
else
{
print_no_permission();
}
}
else
{
if ($vbulletin->userinfo[userid])
{
unset($roll[$vbulletin->userinfo['userid']]);
}
else
{
print_no_permission();
}
}

$eventinfo['roll'] = serialize($roll);
$db->query_write("UPDATE ".TABLE_PREFIX."event SET roll='".addslashes($eventinfo['roll'])."' WHERE eventid='".$eventinfo['eventid']."'");
$_REQUEST['do'] = "getinfo";
}


//show enrolled people
$rollcount=0;
if ($eventinfo['useroll'])
{
// Roll for this event
unset($rollbits);
$show['userattending'] = false;
if (($roll = @unserialize($eventinfo['roll'])) && is_array($roll))
{
if ($vbulletin->options['roll_sort'])
{
uasort($roll, "strnatcasecmp");
}

if (array_key_exists($vbulletin->userinfo['userid'], $roll))
{
$show['userattending']=true;
}

while ($rollusername = current($roll))
{
$rolluserid = key($roll);
eval('$rollbits .= "' . fetch_template('calendar_rollbit') . '";');
$rollcount++;
next($roll);
}
}
else
{
$eventinfo['roll'] = "";
}

eval ('$eventinfo[roll] = "' . fetch_template('calendar_roll') . '";');
$eventinfo['event'].=$eventinfo['roll'];
// End Roll
}
else
{
$eventinfo['roll'] = "";
}

iA1
09-08-2019, 06:59 PM
Wherever you see userinfo[userid] in the code, add quotation marks for userid, like userinfo['userid']. Do the same for usergroupid