request->getQuery('limit', 'int', 5); $question = $this->checkQuestion($id); if (empty($question->tags)) return []; $tagIds = kg_array_column($question->tags, 'id'); $tagId = kg_array_rand($tagIds); $cache = new TaggedQuestionListCache(); $questions = $cache->get($tagId); if (empty($questions)) return []; foreach ($questions as $key => $question) { if ($question['id'] == $id) { unset($questions[$key]); } } if ($limit < count($questions)) { $questions = array_slice($questions, $limit); } return $questions; } }