News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[GH#3315] Undefined index: permissions in file Security.php

Started by w4rkr4f7, March 02, 2016, 04:50:49 AM

Previous topic - Next topic

w4rkr4f7

Hi .I'm using latest "SMF2.1-release-2.1" from Github and in error log is appearing frequently these errors :


file: Security.php
error: array_intersect(): Argument #2 is not an array
line 918:    if (count(array_intersect($permission, $user_info['permissions'])) != 0)



file: Security.php
error: Undefined index: permissions
line 918:    if (count(array_intersect($permission, $user_info['permissions'])) != 0)



file: Security.php
error: Undefined index: is_admin
line 909:    if ($user_info['is_admin'])


any help will be appreciated

Illori

you should report bugs or issues like this on the github bug tracker/issues so that it is sure our developers notice and can look into them.

Kindred

also, be aware... 2.1 is in beta - which means that there ARE going to be issues....

but definitely, report the issue on Github, if it has not been reported already
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

w4rkr4f7

I don't have a github account ,I just wanted to inform dev team about that errors and I can live with them until will be fixed by nature :)


Suki

Do you have an idea on what pages/actions your users are doing when that error is logged?

Something is calling allowedTo() too early, perhaps even before $user_info is defined, thats why it will be quite handy to know which actions triggers this errors.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

w4rkr4f7

Quote from: Suki on March 03, 2016, 11:33:10 AM
Do you have an idea on what pages/actions your users are doing when that error is logged?

Something is calling allowedTo() too early, perhaps even before $user_info is defined, thats why it will be quite handy to know which actions triggers this errors.

no action ,just home page    /index.php?

w4rkr4f7

I don't know why but after I've moved


function allowedTo($permission, $boards = null)
{
global $user_info, $sourcedir, $modSettings, $context;
// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
if (empty($permission))
return true;

// You're never allowed to do something if your data hasn't been loaded yet!
if (empty($user_info))
return false;

// Administrators are supermen :P.
if ($user_info['is_admin'])
return true;

if (!is_array($permission))
$permission = array($permission);

// Are we checking the _current_ board, or some other boards?
if ($boards === null)
{
if (count(array_intersect($permission, $user_info['permissions'])) != 0)
return true;
// You aren't allowed, by default.
else
return false;
}
elseif (!is_array($boards))
$boards = array($boards);

$request = $smcFunc['db_query']('', '
SELECT MIN(bp.add_deny) AS add_deny
FROM {db_prefix}boards AS b
INNER JOIN {db_prefix}board_permissions AS bp ON (bp.id_profile = b.id_profile)
LEFT JOIN {db_prefix}moderators AS mods ON (mods.id_board = b.id_board AND mods.id_member = {int:current_member})
LEFT JOIN {db_prefix}moderator_groups AS modgs ON (modgs.id_board = b.id_board AND modgs.id_group IN ({array_int:group_list}))
WHERE b.id_board IN ({array_int:board_list})
AND bp.id_group IN ({array_int:group_list}, {int:moderator_group})
AND bp.permission IN ({array_string:permission_list})
AND (mods.id_member IS NOT NULL OR modgs.id_group IS NOT NULL OR bp.id_group != {int:moderator_group})
GROUP BY b.id_board',
array(
'current_member' => $user_info['id'],
'board_list' => $boards,
'group_list' => $user_info['groups'],
'moderator_group' => 3,
'permission_list' => $permission,
)
);

// Make sure they can do it on all of the boards.
if ($smcFunc['db_num_rows']($request) != count($boards))
return false;

$result = true;
while ($row = $smcFunc['db_fetch_assoc']($request))
$result &= !empty($row['add_deny']);
$smcFunc['db_free_result']($request);

// If the query returned 1, they can do it... otherwise, they can't.
return $result;
}



to the end of page that errors are gone

Antes


Advertisement: