From 2d12a6f05f13808280efe4a3f1c3928fd36c26b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 22 Jan 2019 21:33:41 +0100 Subject: [PATCH] Bugfix put() stored the value for the current tenant even if the specified $uuid was of a different tenant --- src/TenantManager.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/TenantManager.php b/src/TenantManager.php index 0cf50df1..b722f1fc 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -226,16 +226,23 @@ class TenantManager public function put($key, $value = null, string $uuid = null) { $uuid = $uuid ?: $this->tenant['uuid']; + + // If $uuid is the uuid of the current tenant, put + // the value into the $this->tenant array as well. + $target = []; + if (($this->tenant['uuid'] ?? null) === $uuid) { + $target = &$this->tenant; + } if (! is_null($value)) { - return $this->tenant[$key] = $this->storage->put($uuid, $key, $value); + return $target[$key] = $this->storage->put($uuid, $key, $value); } if (! is_array($key)) { throw new \Exception("No value supplied for key $key."); } - return $this->tenant[$key] = $this->storage->putMany($uuid, $key); + return $target[$key] = $this->storage->putMany($uuid, $key); } /**