From 8ef4497aa0ca9edffe32d2f3f92fa2d8eadc2e1e Mon Sep 17 00:00:00 2001 From: Serge Latyntcev Date: Fri, 12 Jul 2019 09:26:11 +1200 Subject: [PATCH] Revert "Merge pull request #33 from open-sausages/fix/session-binary-safety" This reverts commit 793f933ad1d0dd45ed8e390752f2aaee1c6b44b8, reversing changes made to 785c69771b37636515f6a3b0015d04eab1585ca8. --- .travis.yml | 8 ++-- code/DynamoDbClient.php | 82 ---------------------------------- code/Model/DynamoDbSession.php | 7 ++- code/SessionHandler.php | 36 --------------- composer.json | 3 +- 5 files changed, 8 insertions(+), 128 deletions(-) delete mode 100644 code/DynamoDbClient.php delete mode 100644 code/SessionHandler.php diff --git a/.travis.yml b/.travis.yml index 1a05b1a..dfadab7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,11 @@ env: matrix: fast_finish: true include: - - php: 7.1 - env: DB=MYSQL PHPUNIT_TEST=1 - - php: 7.2 + - php: 5.6 env: DB=MYSQL PHPUNIT_TEST=1 PHPCS_TEST=1 - - php: 7.3 + - php: 7.0 + env: DB=MYSQL PHPUNIT_TEST=1 + - php: 7.1 env: DB=MYSQL PHPUNIT_TEST=1 before_script: diff --git a/code/DynamoDbClient.php b/code/DynamoDbClient.php deleted file mode 100644 index de4a84a..0000000 --- a/code/DynamoDbClient.php +++ /dev/null @@ -1,82 +0,0 @@ -sessionTable = $sessionTable; - parent::__construct(...$args); - } - - /** - * Initialize the client with the session data attribute (within the session table) - * This method must be used to finish the client initialization, otherwise session updates will not be - * intercepted and amended - * - * @param string $dataAttribute attribute of the session table where session data is persisted - */ - public function setSessionTableDataAttribute($dataAttribute) - { - $this->dataAttribute = $dataAttribute; - } - - public function updateItem($attributes, ...$extra) - { - $this->patchSessionUpdate($attributes); - return parent::updateItem($attributes, ...$extra); - } - - /** - * Update the session data type from 'S' to 'B' (from string to binary) - * - * @param mixed &$data Data to be updated in-place - */ - private function patchSessionUpdate(&$data) - { - if (!isset($data['TableName']) || $data['TableName'] !== $this->sessionTable) { - return; - } - - if (!isset($data['AttributeUpdates'][$this->dataAttribute]['Value']['S'])) { - return; - } - - $data['AttributeUpdates'][$this->dataAttribute]['Value']['B'] = $data['AttributeUpdates'][$this->dataAttribute]['Value']['S']; - unset($data['AttributeUpdates'][$this->dataAttribute]['Value']['S']); - } -} diff --git a/code/Model/DynamoDbSession.php b/code/Model/DynamoDbSession.php index fd7e9d1..fde4273 100644 --- a/code/Model/DynamoDbSession.php +++ b/code/Model/DynamoDbSession.php @@ -2,8 +2,8 @@ namespace SilverStripe\DynamoDb\Model; -use SilverStripe\DynamoDb\DynamoDbClient; -use SilverStripe\DynamoDb\SessionHandler; +use Aws\DynamoDb\DynamoDbClient; +use Aws\DynamoDb\SessionHandler; use Aws\DoctrineCacheAdapter; use Doctrine\Common\Cache\ApcuCache; use SilverStripe\Core\Config\Config; @@ -78,8 +78,7 @@ public static function get() public function __construct($options, $table) { - $this->client = new DynamoDbClient($table, array_merge(['version' => '2012-08-10'], $options)); - + $this->client = new DynamoDbClient(array_merge(['version' => '2012-08-10'], $options)); $this->table = $table; $this->handler = SessionHandler::fromClient( $this->client, diff --git a/code/SessionHandler.php b/code/SessionHandler.php deleted file mode 100644 index a40b5ba..0000000 --- a/code/SessionHandler.php +++ /dev/null @@ -1,36 +0,0 @@ -setSessionTableDataAttribute($handler->connection->getDataAttribute()); - - return $handler; - } - - public function __construct(SessionConnectionInterface $connection) - { - $this->connection = $connection; - parent::__construct($connection); - } -} diff --git a/composer.json b/composer.json index fd7721e..1f2702a 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,7 @@ "silverstripe/framework": "^4@dev" }, "require-dev": { - "phpunit/PHPUnit": "^5.7", - "squizlabs/php_codesniffer": "^3.0" + "phpunit/PHPUnit": "^5.7" }, "autoload": { "psr-4": {