Skip to content

Commit a1ff4f6

Browse files
rashidspmikeproeng37
authored andcommitted
fixes every one else rule bug (#98)
1 parent 44b96dd commit a1ff4f6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/Optimizely/DecisionService/DecisionService.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,17 @@ public function getVariationForFeatureRollout(FeatureFlag $featureFlag, $userId,
315315
$experiment = $rolloutRules[sizeof($rolloutRules)-1];
316316

317317
// Evaluate if user meets the audience condition of Everyone Else Rule / Last Rule now
318-
if (Validator::isUserInExperiment($this->_projectConfig, $experiment, $userAttributes)) {
319-
$variation = $this->_bucketer->bucket($this->_projectConfig, $experiment, $bucketing_id, $userId);
320-
if ($variation && $variation->getKey()) {
321-
return new FeatureDecision($experiment, $variation, FeatureDecision::DECISION_SOURCE_ROLLOUT);
322-
}
323-
}
324-
$this->_logger->log(
325-
Logger::DEBUG,
326-
sprintf("User '%s' did not meet the audience conditions to be in rollout rule '%s'.", $userId, $experiment->getKey()));
318+
if (!Validator::isUserInExperiment($this->_projectConfig, $experiment, $userAttributes)) {
319+
$this->_logger->log(
320+
Logger::DEBUG,
321+
sprintf("User '%s' did not meet the audience conditions to be in rollout rule '%s'.", $userId, $experiment->getKey()));
322+
return null;
323+
}
327324

325+
$variation = $this->_bucketer->bucket($this->_projectConfig, $experiment, $bucketing_id, $userId);
326+
if ($variation && $variation->getKey()) {
327+
return new FeatureDecision($experiment, $variation, FeatureDecision::DECISION_SOURCE_ROLLOUT);
328+
}
328329
return null;
329330
}
330331

tests/DecisionServiceTests/DecisionServiceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,9 @@ public function testGetVariationForFeatureRolloutWhenUserIsNeitherBucketedInTheT
10251025
->method('bucket')
10261026
->willReturn(null);
10271027

1028+
$this->loggerMock->expects($this->never())
1029+
->method('log');
1030+
10281031
$this->assertEquals(
10291032
null,
10301033
$this->decisionService->getVariationForFeatureRollout($feature_flag, 'user_1', $user_attributes)

0 commit comments

Comments
 (0)