diff --git a/classes/experiment_manager.php b/classes/experiment_manager.php index 3d080d0..a3b28b5 100644 --- a/classes/experiment_manager.php +++ b/classes/experiment_manager.php @@ -270,9 +270,7 @@ public function get_experiments() { * Get active requests * @return mixed */ - public function get_active_request() { - $experiments = self::get_experiments(); - + public function get_active_request($experiments) { // Filter array for only enabled session experiments. return array_filter($experiments, function ($experiment) { if ($experiment['enabled'] == 1 && $experiment['scope'] == 'request') { @@ -287,8 +285,10 @@ public function get_active_request() { * Get the active session * @return mixed */ - public function get_active_session() { - $experiments = self::get_experiments(); + public function get_active_session($experiments = null) { + if (is_null($experiments)) { + $experiments = self::get_experiments(); + } // Filter array for only enabled session experiments. return array_filter($experiments, function ($experiment) { diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php index 1d53418..37d6519 100644 --- a/classes/hook_callbacks.php +++ b/classes/hook_callbacks.php @@ -98,7 +98,7 @@ public static function after_config(\core\hook\after_config $hook) { // First, Build a list of all commands that need to be executed. // Start with request scope. - $requestexperiments = $manager->get_active_request(); + $requestexperiments = $manager->get_active_request($experiments); if (!empty($requestexperiments)) { foreach ($requestexperiments as $record) { @@ -143,7 +143,7 @@ public static function after_config(\core\hook\after_config $hook) { } // Now session scope. - $sessionexperiments = $manager->get_active_session(); + $sessionexperiments = $manager->get_active_session($experiments); if (!empty($sessionexperiments)) { foreach ($sessionexperiments as $record) { // Check if a session var has been set for this experiment, only care if has been set.