Skip to content

Commit

Permalink
Cast to string when used as array key
Browse files Browse the repository at this point in the history
Signed by Shawn Bulen, [email protected]
  • Loading branch information
sbulen committed Nov 11, 2024
1 parent 179e10a commit c4e9fe8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Sources/Actions/Admin/Members.php
Original file line number Diff line number Diff line change
Expand Up @@ -1519,16 +1519,16 @@ protected static function populateDuplicateMembers(array &$members): void
'name' => $row['member_name'],
'email' => $row['email_address'],
'is_banned' => $row['is_activated'] >= User::BANNED,
'ip' => $row['member_ip']->__toString(),
'ip2' => $row['member_ip2']->__toString(),
'ip' => (string) $row['member_ip'],
'ip2' => (string) $row['member_ip2'],
];

if (in_array($row['member_ip']->__toString(), $ips)) {
$duplicate_members[$row['member_ip']->__toString()][] = $member_context;
if (in_array((string) $row['member_ip'], $ips)) {
$duplicate_members[(string) $row['member_ip']][] = $member_context;
}

if ($row['member_ip']->__toString() != $row['member_ip2']->__toString() && in_array($row['member_ip2']->__toString(), $ips)) {
$duplicate_members[$row['member_ip2']->__toString()][] = $member_context;
if ((string) $row['member_ip'] != (string) $row['member_ip2'] && in_array((string) $row['member_ip2'], $ips)) {
$duplicate_members[(string) $row['member_ip2']][] = $member_context;
}
}
Db::$db->free_result($request);
Expand All @@ -1555,32 +1555,32 @@ protected static function populateDuplicateMembers(array &$members): void
$row['poster_ip'] = new IP($row['poster_ip']);

// Don't collect lots of the same.
if (isset($had_ips[$row['poster_ip']->__toString()]) && in_array($row['id_member']->__toString(), $had_ips[$row['poster_ip']->__toString()])) {
if (isset($had_ips[(string) $row['poster_ip']]) && in_array((string) $row['id_member'], $had_ips[(string) $row['poster_ip']])) {
continue;
}

$had_ips[$row['poster_ip']->__toString()][] = $row['id_member'];
$had_ips[(string) $row['poster_ip']][] = $row['id_member'];

$duplicate_members[$row['poster_ip']->__toString()][] = [
$duplicate_members[(string) $row['poster_ip']][] = [
'id' => $row['id_member'],
'name' => $row['member_name'],
'email' => $row['email_address'],
'is_banned' => $row['is_activated'] >= User::BANNED,
'ip' => $row['poster_ip']->__toString(),
'ip2' => $row['poster_ip']->__toString(),
'ip' => (string) $row['poster_ip'],
'ip2' => (string) $row['poster_ip'],
];
}
Db::$db->free_result($request);

// Now we have all the duplicate members, stick them with their respective member in the list.
if (!empty($duplicate_members)) {
foreach ($members as $key => $member) {
if (isset($duplicate_members[$member['member_ip']->__toString()])) {
$members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']->__toString()];
if (isset($duplicate_members[(string) $member['member_ip']])) {
$members[$key]['duplicate_members'] = $duplicate_members[(string) $member['member_ip']];
}

if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']->__toString()])) {
$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']->__toString()]);
if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[(string) $member['member_ip2']])) {
$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[(string) $member['member_ip2']]);
}

// Check we don't have lots of the same member.
Expand Down

0 comments on commit c4e9fe8

Please sign in to comment.