Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.2.5 (Apr 22, 2021)
- Added delimiter in SharedMemory Cache.

6.2.4 (Mar 20, 2020)
- Added missing methods in ClientInterface.

6.2.3 (Nov 1, 2019)
- Added flag `IPAddressesEnabled` into options to enable/disable sending MachineName and MachineIP when data is posted in headers.

Expand Down
2 changes: 1 addition & 1 deletion Detailed-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ $splitClient = $splitFactory->client();
Within tests folder you can find different test suites in order to run the Split SDK tests. The most important test suite is: **integration** that wrap the others test suites.

### Integration test suite
Before to run this test suite, please be sure to have a Redis instance runing:
Before to run this test suite, please be sure to have a Redis instance running:
- In order to have a local Redis instance you can install [Docker Container Tool](https://www.docker.com) and pull the oficial Redis container running the command ```docker pull redis```.

And set the correct values on the **phpunit.xml** that you should have copied from **phpunit.xml.dist** file.
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Component/Common/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function stop($throw = false)
}

/**
* Method to add the catched error
* Method to add the caught error
* @param $errno
* @param string $errstr
* @param string $errfile
Expand Down
8 changes: 6 additions & 2 deletions src/SplitIO/Component/Memory/SharedMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function write($key, $value, $expiration = 60, $mode = 0644, $size

$expiration = time() + $expiration;

$data = json_encode(array('expiration' => $expiration, 'value' => serialize($value)));
$data = json_encode(array('expiration' => $expiration, 'value' => serialize($value))) . "\0";

@$shm_id = shmop_open($key, "c", $mode, $size);

Expand Down Expand Up @@ -87,7 +87,11 @@ public static function read($key, $mode = 0644, $size = 100)
throw new ReadSharedMemoryException("The shared memory block could not be read");
}

$data = json_decode($cached_string, true);
$null_pos = strpos($cached_string, "\0");
$data = json_decode(
substr($cached_string, 0, $null_pos),
true
);

if ((isset($data['expiration']) && time() > $data['expiration']) || !isset($data['expiration'])) {
shmop_delete($shm_id);
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Sdk/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private function registerData($impressions, $attributes, $metricName, $latency =
}
} catch (\Exception $e) {
SplitApp::logger()->critical(
': An exception occured when trying to store impressions.'
': An exception occurred when trying to store impressions.'
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Sdk/Evaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function evalTreatment($key, $bucketingKey, $split, array $attributes =
}
SplitApp::logger()->info("*Treatment for $key in {$split->getName()} is: ".$result['treatment']);
} catch (\Exception $e) {
SplitApp::logger()->critical('An exception occured when evaluating feature: '. $split->getName());
SplitApp::logger()->critical('An exception occurred when evaluating feature: '. $split->getName());
SplitApp::logger()->critical($e->getMessage());
SplitApp::logger()->critical($e->getTraceAsString());
$result['impression']['label'] = ImpressionLabel::EXCEPTION;
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Version
{
const CURRENT = '6.2.4';
const CURRENT = '6.2.5-rc1';
}
28 changes: 28 additions & 0 deletions tests/Suite/Component/Memory/SharedMemoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace SplitIO\Test\Suite\Component\Memory;

use SplitIO\Component\Memory\SharedMemory;

class SharedMemoryTest extends \PHPUnit_Framework_TestCase
{
public function testSharedMemoryOperations()
{
if (!extension_loaded('shmop')) {
$this->markTestSkipped(
'The shmop extension is not available.'
);
}

$key = 1234;
$value = 'bar';

SharedMemory::write($key, $value);
$given = SharedMemory::read($key);
$this->assertEquals($value, $given);

$updated_value = 'new_value';
SharedMemory::write($key, $updated_value);
$given = SharedMemory::read($key);
$this->assertEquals($updated_value, $given);
}
}