-
Notifications
You must be signed in to change notification settings - Fork 30
fix(datafile-parsing): Prevent newer versions datafile #127
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
Conversation
src/Optimizely/Optimizely.php
Outdated
@@ -127,12 +128,13 @@ public function __construct( | |||
|
|||
try { | |||
$this->_config = new ProjectConfig($datafile, $this->_logger, $this->_errorHandler); | |||
} catch (Throwable $exception) { | |||
} catch (InvalidDatafileVersionException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as Python PR, please consolidate these two cases into one.
And pass the exception to the errorHandler
tests/OptimizelyTest.php
Outdated
public function testInitUnSupportedDatafileVersion() | ||
{ | ||
$datafile = json_decode($this->datafile, true); | ||
$datafile['version'] = '5'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this, let's create a small unsupported_datafile
that has one running experiment in it and use that here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after making the recommended change.
src/Optimizely/ProjectConfig.php
Outdated
@@ -196,6 +200,13 @@ public function __construct($datafile, $logger, $errorHandler) | |||
$this->_revision = $config['revision']; | |||
$this->_forcedVariationMap = []; | |||
|
|||
$supportedVersions = array(self::V2, self::V3, self::V4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend setting this up at the top of this method. It is extremely hard to read it here.
build |
No description provided.