Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Forced variation not available in experiment #237

Merged
merged 6 commits into from
Dec 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Optimizely/Event/Builder/EventBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,9 @@ public function createImpressionEvent($config, $experimentId, $variationKey, $fl
{
$eventParams = $this->getCommonParams($config, $userId, $attributes);
$experiment = $config->getExperimentFromId($experimentId);
$variation = $config->getFlagVariationByKey($flagKey, $variationKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment above this line that mapped flagKey can be directly used in variation so no experimentKey exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a check here, this is only valid for feature test not for ab. so flag_key must be non-empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we need check empty both 'flagKey' (line 256) and 'experimentId' (line 260).
Also consider switching line 260 and 256 since 256 is common cases while 256 is for FD only and slow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a unit test covering this bug?


if (empty($experimentId)) {
$variation = $config->getFlagVariationByKey($flagKey, $variationKey);
} else {
if (!$variation) {
$variation = $config->getVariationFromKeyByExperimentId($experimentId, $variationKey);
}

Expand Down