Commit bba21dbe authored by Mark Harding's avatar Mark Harding

(fix): do not use strict in_array when dealing with integers

parent d1e4ff4f
No related merge requests found
Pipeline #78708972 waiting for manual action with stages
in 10 minutes and 27 seconds
......@@ -149,11 +149,11 @@ class recommended implements Interfaces\Api
{
$guids = [];
$entities = array_filter($entities, function ($entity) use (&$guids, $exclude) {
if (in_array($entity->guid, $guids, true)) {
if (in_array($entity->guid, $guids, false)) {
return false;
}
if (in_array($entity->guid, $exclude, true)) {
if (in_array($entity->guid, $exclude, false)) {
return false;
}
......
......@@ -64,7 +64,7 @@ class Manager
break;
}
return in_array($this->vote->getActor()->guid, $votes, true);
return in_array($this->vote->getActor()->guid, $votes, false);
}
/**
......
......@@ -66,7 +66,7 @@ class Activity implements EmailBatchInterface
foreach ($iterator as $user) {
$filtered = array_filter($trendingPosts, function ($activity) use ($user, $subscribers_map) {
return in_array($activity->owner_guid, $subscribers_map[$user->guid], true);
return in_array($activity->owner_guid, $subscribers_map[$user->guid], false);
});
if ($filtered && count($filtered) >= 1) {
$campaign = new WithActivity();
......
......@@ -170,7 +170,7 @@ class Manager
$hydratedEntities = $this->entitiesBuilder->get(['guids' => $hydrateGuids]);
foreach ($hydratedEntities as $entity) {
if ($opts['pinned_guids'] && in_array($entity->getGuid(), $opts['pinned_guids'], true)) {
if ($opts['pinned_guids'] && in_array($entity->getGuid(), $opts['pinned_guids'], false)) {
$entity->pinned = true;
}
if ($opts['as_activities']) {
......
......@@ -226,7 +226,7 @@ class Repository
],
];
if (in_array(6, $nsfw, true)) { // 6 is legacy 'mature'
if (in_array(6, $nsfw, false)) { // 6 is legacy 'mature'
$body['query']['function_score']['query']['bool']['must_not'][] = [
'term' => [
'mature' => true,
......
......@@ -96,7 +96,7 @@ class Invitations
$result = [];
foreach ($users as $user) {
$result[$user] = in_array($user, $invited_guids, true);
$result[$user] = in_array($user, $invited_guids, false);
}
return $result;
......
......@@ -579,7 +579,7 @@ class Membership
$result = [];
foreach ($users as $user) {
$result[$user] = in_array($user, $banned_guids, true);
$result[$user] = in_array($user, $banned_guids, false);
}
return $result;
......
......@@ -62,8 +62,8 @@ class Question
$export['answer'] = $this->getAnswer();
$export['category_uuid'] = $this->getCategoryUuid();
$export['category'] = $this->getCategory() ? $this->getCategory()->export() : null;
$export['thumb_up'] = in_array(Session::getLoggedInUserGuid(), $this->getThumbsUp(), true);
$export['thumb_down'] = in_array(Session::getLoggedInUserGuid(), $this->getThumbsDown(), true);
$export['thumb_up'] = in_array(Session::getLoggedInUserGuid(), $this->getThumbsUp(), false);
$export['thumb_down'] = in_array(Session::getLoggedInUserGuid(), $this->getThumbsDown(), false);
$export['position'] = $this->getPosition();
return $export;
......
......@@ -67,7 +67,7 @@ class Manager
$array = $this->question->$getter();
if (!in_array($this->user->getGuid(), $array, true)) {
if (!in_array($this->user->getGuid(), $array, false)) {
$array[] = (string) $this->user->getGuid();
$this->question->$setter($array);
}
......
......@@ -52,8 +52,10 @@ class Conversations
if ($guids && is_array($guids) && count($guids) >= 12) {
$collection = \Cassandra\Type::collection(\Cassandra\Type::text())
->create(... $guids);
$prepared->query("SELECT * from entities_by_time WHERE key= ? AND column1 IN ? LIMIT ?",
[ "object:gathering:conversations:{$this->user->guid}", $collection, 1000 ]);
$prepared->query(
"SELECT * from entities_by_time WHERE key= ? AND column1 IN ? LIMIT ?",
[ "object:gathering:conversations:{$this->user->guid}", $collection, 1000 ]
);
$usingCache = true;
}
}
......@@ -148,7 +150,7 @@ class Conversations
foreach ($conversations as $key => $conversation) {
foreach ($conversation->getParticipants() as $participant) {
if (in_array($participant, $online, true)) {
if (in_array($participant, $online, false)) {
$conversations[$key] = $conversation->setOnline(true);
}
}
......
......@@ -92,7 +92,7 @@ class Manager
// Remove the summonses of jurors who have already voted
$summonses = array_filter($summonses, function (Summons $summons) use ($completedJurorGuids) {
return !in_array($summons->getJurorGuid(), $completedJurorGuids, true);
return !in_array($summons->getJurorGuid(), $completedJurorGuids, false);
});
// Check how many are missing
......
......@@ -82,7 +82,7 @@ class Manager
if ($report->getReasonCode() == 2
&& $report->getEntity()->getNsfw()
&& in_array($report->getSubReasonCode(), $report->getEntity()->getNsfw(), true)
&& in_array($report->getSubReasonCode(), $report->getEntity()->getNsfw(), false)
) {
return true; // If the post is NSFW and tagged, do not allow report
}
......
......@@ -270,7 +270,7 @@ class AutoReporter
{
$reasons = array_filter($reasons, function ($reason) use ($NSFWtags) {
if ($reason->getReasonCode() == REASON::REASON_NSFW
&& in_array($reason->getSubreasonCode(), $NSFWtags, true)) {
&& in_array($reason->getSubreasonCode(), $NSFWtags, false)) {
return false;
}
......
......@@ -96,7 +96,7 @@ class Indexes
$guids = $entity->{"thumbs:{$direction}:user_guids"} ?: [];
return in_array($actor->guid, $guids, true);
return in_array($actor->guid, $guids, false);
}
/**
......
......@@ -560,7 +560,7 @@ class Group extends NormalizedEntity
$user_guid = is_object($user) ? $user->guid : $user;
return $this->isCreator($user) || in_array($user_guid, $this->getOwnerGuids(), true);
return $this->isCreator($user) || in_array($user_guid, $this->getOwnerGuids(), false);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment