Skip to content

Commit

Permalink
ENH Only query primary DB
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 16, 2024
1 parent bba7c4f commit 8401975
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": "^8.1",
"silverstripe/framework": "^5"
"silverstripe/framework": "^5.4"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
Expand Down
2 changes: 2 additions & 0 deletions src/Model/HybridSessionDataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class HybridSessionDataObject extends DataObject
];

private static $table_name = 'HybridSessionDataObject';

private static bool $must_use_primary_db = true;
}
4 changes: 3 additions & 1 deletion src/Store/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function read(string $session_id): string|false
$this->getNow()
);

$result = DB::query($query);
$result = DB::withPrimary(function() use ($query) {
return DB::query($query);
});

if ($result && $result->numRecords()) {
$data = $result->record();
Expand Down

0 comments on commit 8401975

Please sign in to comment.