Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aa34e8b
fix version string
eli-darkly Jul 16, 2018
6a08f47
Merge pull request #26 from launchdarkly/3.2.1
eli-darkly Jul 16, 2018
0d4fc33
add new version of allFlags() that captures more metadata
eli-darkly Aug 20, 2018
0f76969
linter
eli-darkly Aug 20, 2018
9023ea6
missing array key guard
eli-darkly Aug 21, 2018
e215364
missing array key guards
eli-darkly Aug 21, 2018
30e9e3c
use the standard method for specifying custom JSON serialization
eli-darkly Aug 21, 2018
775f0a1
indents
eli-darkly Aug 21, 2018
c1ac079
Merge pull request #27 from launchdarkly/eb/ch22308/all-flags-state
eli-darkly Aug 21, 2018
2f80b4c
add ability to filter for client-side flags only
eli-darkly Aug 21, 2018
fd08375
fix test to fill in all required flag fields
eli-darkly Aug 21, 2018
42c1ff2
Merge pull request #28 from launchdarkly/eb/ch12124/client-side-filter
eli-darkly Aug 22, 2018
2e9829c
implement evaluation with explanations
eli-darkly Aug 24, 2018
5d8e2b0
add another evaluation test
eli-darkly Aug 24, 2018
1977097
linter
eli-darkly Aug 24, 2018
54759db
fix test method
eli-darkly Aug 25, 2018
5038b0d
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Aug 25, 2018
87417f1
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Aug 27, 2018
07eb1a7
Merge branch 'explanation' into eb/ch19976/explanations
eli-darkly Aug 29, 2018
39d5105
fix for ch22995 - include prereq value in event even if prereq is off
eli-darkly Aug 29, 2018
8391618
Merge pull request #29 from launchdarkly/eb/ch19976/explanations
eli-darkly Sep 4, 2018
180679f
cache flag data in allFlags
eli-darkly Sep 24, 2018
15720d0
rm unused imports
eli-darkly Sep 24, 2018
dd7f268
Merge pull request #30 from launchdarkly/eb/ch24369/all-flags-caching
eli-darkly Sep 25, 2018
08572c9
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Sep 25, 2018
f7211cb
version 3.4.1
eli-darkly Sep 25, 2018
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the LaunchDarkly PHP SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [3.4.1] - 2018-09-25
### Fixed:
- Improved the performance of `allFlags`/`allFlagsState` by not making redundant individual requests for prerequisite flags, when a flag is being evaluated that has prerequisites. Instead it will reuse the same flag data that it already obtained from LaunchDarkly in the "get all the flags" request.

## [3.4.0] - 2018-09-04
### Added:
- The new `LDClient` method `variationDetail` allows you to evaluate a feature flag (using the same parameters as you would for `variation`) and receive more information about how the value was calculated. This information is returned in an object that contains both the result value and a "reason" object which will tell you, for instance, if the user was individually targeted for the flag or was matched by one of the flag's rules, or if the flag returned the default value due to an error.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.4.1
7 changes: 5 additions & 2 deletions src/LaunchDarkly/LDClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LDClient
{
const DEFAULT_BASE_URI = 'https://app.launchdarkly.com';
const DEFAULT_EVENTS_URI = 'https://events.launchdarkly.com';
const VERSION = '3.4.0';
const VERSION = '3.4.1';

/** @var string */
protected $_sdkKey;
Expand Down Expand Up @@ -350,14 +350,17 @@ public function allFlagsState($user, $options = array())
return new FeatureFlagsState(false);
}

$preloadedRequester = new PreloadedFeatureRequester($this->_featureRequester, $flags);
// This saves us from doing repeated queries for prerequisite flags during evaluation

$state = new FeatureFlagsState(true);
$clientOnly = isset($options['clientSideOnly']) && $options['clientSideOnly'];
$withReasons = isset($options['withReasons']) && $options['withReasons'];
foreach ($flags as $key => $flag) {
if ($clientOnly && !$flag->isClientSide()) {
continue;
}
$result = $flag->evaluate($user, $this->_featureRequester);
$result = $flag->evaluate($user, $preloadedRequester);
$state->addFlag($flag, $result->getDetail(), $withReasons);
}
return $state;
Expand Down
52 changes: 52 additions & 0 deletions src/LaunchDarkly/PreloadedFeatureRequester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace LaunchDarkly;

class PreloadedFeatureRequester implements FeatureRequester
{
/** @var FeatureRequester */
private $_baseRequester;

/** @var array */
private $_knownFeatures;

public function __construct($baseRequester, $knownFeatures)
{
$this->_baseRequester = $baseRequester;
$this->_knownFeatures = $knownFeatures;
}

/**
* Gets feature data from cached values
*
* @param $key string feature key
* @return FeatureFlag|null The decoded FeatureFlag, or null if missing
*/
public function getFeature($key)
{
if (isset($this->_knownFeatures[$key])) {
return $this->_knownFeatures[$key];
}
return null;
}

/**
* Gets segment data from the regular feature requester
*
* @param $key string segment key
* @return Segment|null The decoded Segment, or null if missing
*/
public function getSegment($key)
{
return $this->_baseRequester->getSegment($key);
}

/**
* Gets all features from cached values
*
* @return array()|null The decoded FeatureFlags, or null if missing
*/
public function getAllFeatures()
{
return $this->_knownFeatures;
}
}