From feb09a21ce3fdada1ab3d7fe2aa0d944fd197702 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 16 Sep 2024 15:28:44 +1200 Subject: [PATCH] ENH Only query primary DB --- composer.json | 2 +- src/Model/HybridSessionDataObject.php | 2 ++ src/Store/DatabaseStore.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3a32041..7a8d0c2 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^8.1", - "silverstripe/framework": "^5" + "silverstripe/framework": "^5.4" }, "require-dev": { "phpunit/phpunit": "^9.6", diff --git a/src/Model/HybridSessionDataObject.php b/src/Model/HybridSessionDataObject.php index cdae2f3..5b35464 100644 --- a/src/Model/HybridSessionDataObject.php +++ b/src/Model/HybridSessionDataObject.php @@ -20,4 +20,6 @@ class HybridSessionDataObject extends DataObject ]; private static $table_name = 'HybridSessionDataObject'; + + private static bool $must_use_primary_db = true; } diff --git a/src/Store/DatabaseStore.php b/src/Store/DatabaseStore.php index 37aec55..61e54d8 100644 --- a/src/Store/DatabaseStore.php +++ b/src/Store/DatabaseStore.php @@ -68,7 +68,7 @@ public function read(string $session_id): string|false $this->getNow() ); - $result = DB::query($query); + $result = DB::withPrimary(fn() => DB::query($query)); if ($result && $result->numRecords()) { $data = $result->record();