From de020a870f3c7afec5a537d3d52993e779168c87 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 22 Aug 2023 04:36:42 +0000 Subject: [PATCH 01/21] copy internalId when running createDocuments --- src/Database/Adapter/MariaDB.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index 23cce605a..60d465a7f 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -561,7 +561,7 @@ public function createDocument(string $collection, Document $document): Document /** * @throws Duplicate */ - public function createDocuments(string $collection, array $documents, int $batchSize = Database::INSERT_BATCH_SIZE): array + public function createDocuments(string $collection, array $documents, int $batchSize = Database::INSERT_BATCH_SIZE, bool $copyInternalId = false): array { if (empty($documents)) { return $documents; @@ -585,6 +585,9 @@ public function createDocuments(string $collection, array $documents, int $batch $attributes['_createdAt'] = $document->getCreatedAt(); $attributes['_updatedAt'] = $document->getUpdatedAt(); $attributes['_permissions'] = \json_encode($document->getPermissions()); + if($copyInternalId) { + $attributes['_id'] = $document->getInternalId(); + } $columns = []; foreach (\array_keys($attributes) as $key => $attribute) { From c2146e133a418b1a14e661023e6c1ab414397186 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 22 Aug 2023 04:38:00 +0000 Subject: [PATCH 02/21] mongo and adapter update --- src/Database/Adapter.php | 3 ++- src/Database/Adapter/Mongo/MongoDBAdapter.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index c9002ddf8..200884583 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -301,10 +301,11 @@ abstract public function createDocument(string $collection, Document $document): * @param string $collection * @param Document[] $documents * @param int $batchSize + * @paran bool $copyInternalId * * @return Document[] */ - abstract public function createDocuments(string $collection, array $documents, int $batchSize): array; + abstract public function createDocuments(string $collection, array $documents, int $batchSize, bool $copyInternalId): array; /** * Update Document diff --git a/src/Database/Adapter/Mongo/MongoDBAdapter.php b/src/Database/Adapter/Mongo/MongoDBAdapter.php index dcca8023b..d15cfa878 100644 --- a/src/Database/Adapter/Mongo/MongoDBAdapter.php +++ b/src/Database/Adapter/Mongo/MongoDBAdapter.php @@ -391,13 +391,15 @@ public function createDocument(string $collection, Document $document): Document return $document; } - public function createDocuments(string $collection, array $documents, int $batchSize): array + public function createDocuments(string $collection, array $documents, int $batchSize, bool $copyInternalId = false): array { $name = $this->getNamespace() . '_' . $this->filter($collection); $records = []; foreach ($documents as $document) { - $document->removeAttribute('$internalId'); + if(!$copyInternalId) { + $document->removeAttribute('$internalId'); + } $records[] = $this->replaceChars('$', '_', (array)$document); } From a03ba116d08dcd7aadd418c4ba7fba0011d6b9ad Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 22 Aug 2023 04:41:34 +0000 Subject: [PATCH 03/21] make default behavior to copy internal ID --- src/Database/Adapter.php | 3 +-- src/Database/Adapter/MariaDB.php | 6 ++---- src/Database/Adapter/Mongo/MongoDBAdapter.php | 6 +----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index 200884583..c9002ddf8 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -301,11 +301,10 @@ abstract public function createDocument(string $collection, Document $document): * @param string $collection * @param Document[] $documents * @param int $batchSize - * @paran bool $copyInternalId * * @return Document[] */ - abstract public function createDocuments(string $collection, array $documents, int $batchSize, bool $copyInternalId): array; + abstract public function createDocuments(string $collection, array $documents, int $batchSize): array; /** * Update Document diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index 60d465a7f..20a59fbcb 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -561,7 +561,7 @@ public function createDocument(string $collection, Document $document): Document /** * @throws Duplicate */ - public function createDocuments(string $collection, array $documents, int $batchSize = Database::INSERT_BATCH_SIZE, bool $copyInternalId = false): array + public function createDocuments(string $collection, array $documents, int $batchSize = Database::INSERT_BATCH_SIZE): array { if (empty($documents)) { return $documents; @@ -585,9 +585,7 @@ public function createDocuments(string $collection, array $documents, int $batch $attributes['_createdAt'] = $document->getCreatedAt(); $attributes['_updatedAt'] = $document->getUpdatedAt(); $attributes['_permissions'] = \json_encode($document->getPermissions()); - if($copyInternalId) { - $attributes['_id'] = $document->getInternalId(); - } + $attributes['_id'] = $document->getInternalId(); $columns = []; foreach (\array_keys($attributes) as $key => $attribute) { diff --git a/src/Database/Adapter/Mongo/MongoDBAdapter.php b/src/Database/Adapter/Mongo/MongoDBAdapter.php index d15cfa878..91d704bbf 100644 --- a/src/Database/Adapter/Mongo/MongoDBAdapter.php +++ b/src/Database/Adapter/Mongo/MongoDBAdapter.php @@ -391,16 +391,12 @@ public function createDocument(string $collection, Document $document): Document return $document; } - public function createDocuments(string $collection, array $documents, int $batchSize, bool $copyInternalId = false): array + public function createDocuments(string $collection, array $documents, int $batchSize): array { $name = $this->getNamespace() . '_' . $this->filter($collection); $records = []; foreach ($documents as $document) { - if(!$copyInternalId) { - $document->removeAttribute('$internalId'); - } - $records[] = $this->replaceChars('$', '_', (array)$document); } From a49d9ecbde5454bc401793ad15adb022ddc50b21 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 22 Aug 2023 04:43:21 +0000 Subject: [PATCH 04/21] fix mongo --- src/Database/Adapter/Mongo/MongoDBAdapter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Database/Adapter/Mongo/MongoDBAdapter.php b/src/Database/Adapter/Mongo/MongoDBAdapter.php index 91d704bbf..1d3b09597 100644 --- a/src/Database/Adapter/Mongo/MongoDBAdapter.php +++ b/src/Database/Adapter/Mongo/MongoDBAdapter.php @@ -397,6 +397,9 @@ public function createDocuments(string $collection, array $documents, int $batch $records = []; foreach ($documents as $document) { + $document->setAttribute('_id', $document->getInternalId()); + $document->removeAttribute('$internalId'); + $records[] = $this->replaceChars('$', '_', (array)$document); } From 41802d48f2f44977162579eb810599d279d811dc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 22 Aug 2023 05:44:34 +0000 Subject: [PATCH 05/21] fix mongo empty internalId --- src/Database/Adapter/Mongo/MongoDBAdapter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Database/Adapter/Mongo/MongoDBAdapter.php b/src/Database/Adapter/Mongo/MongoDBAdapter.php index 1d3b09597..690be6bd8 100644 --- a/src/Database/Adapter/Mongo/MongoDBAdapter.php +++ b/src/Database/Adapter/Mongo/MongoDBAdapter.php @@ -397,7 +397,9 @@ public function createDocuments(string $collection, array $documents, int $batch $records = []; foreach ($documents as $document) { - $document->setAttribute('_id', $document->getInternalId()); + if(!empty($document->getInternalId())) { + $document->setAttribute('_id', $document->getInternalId()); + } $document->removeAttribute('$internalId'); $records[] = $this->replaceChars('$', '_', (array)$document); From f9453faf917ac3829fe0c3f849b2291fa22a7db5 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 27 Aug 2023 07:29:14 +0000 Subject: [PATCH 06/21] disable structure validation in createDocuments for now --- src/Database/Database.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index a41f6b372..30f94a19d 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1407,10 +1407,11 @@ public function createDocuments(string $collection, array $documents, int $batch $document = $this->encode($collection, $document); - $validator = new Structure($collection); - if (!$validator->isValid($document)) { - throw new StructureException($validator->getDescription()); - } + // TODO find a way to skip with special parameter for migrations + // $validator = new Structure($collection); + // if (!$validator->isValid($document)) { + // throw new StructureException($validator->getDescription()); + // } $documents[$key] = $document; } From 54dac448fc4108675863f4d50865186e53542ca4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 27 Aug 2023 07:35:04 +0000 Subject: [PATCH 07/21] mariadb check if internalId is not empty --- src/Database/Adapter/MariaDB.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index 20a59fbcb..ddb72d5a8 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -585,7 +585,9 @@ public function createDocuments(string $collection, array $documents, int $batch $attributes['_createdAt'] = $document->getCreatedAt(); $attributes['_updatedAt'] = $document->getUpdatedAt(); $attributes['_permissions'] = \json_encode($document->getPermissions()); - $attributes['_id'] = $document->getInternalId(); + if(!empty($document->getInternalId())) { + $attributes['_id'] = $document->getInternalId(); + } $columns = []; foreach (\array_keys($attributes) as $key => $attribute) { From c1ed97994b5daf33c3dd02a233b857701037858c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 28 Aug 2023 03:39:47 +0000 Subject: [PATCH 08/21] add database name prefix to cache --- src/Database/Database.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 30f94a19d..13ad7aa2c 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -108,6 +108,8 @@ class Database */ protected Cache $cache; + protected string $name; + /** * @var array */ @@ -236,11 +238,12 @@ class Database * @param Adapter $adapter * @param Cache $cache */ - public function __construct(Adapter $adapter, Cache $cache, array $filters = []) + public function __construct(Adapter $adapter, Cache $cache, array $filters = [], String $name = 'default') { $this->adapter = $adapter; $this->cache = $cache; $this->instanceFilters = $filters; + $this->name = $name; self::addFilter( 'json', @@ -1303,7 +1306,7 @@ public function getDocument(string $collection, string $id): Document $validator = new Authorization(self::PERMISSION_READ); // TODO@kodumbeats Check if returned cache id matches request - if ($cache = $this->cache->load('cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id, self::TTL)) { + if ($cache = $this->cache->load($this->name . '-cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id, self::TTL)) { $document = new Document($cache); if ($collection->getId() !== self::METADATA @@ -1330,7 +1333,7 @@ public function getDocument(string $collection, string $id): Document $document = $this->casting($collection, $document); $document = $this->decode($collection, $document); - $this->cache->save('cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id, $document->getArrayCopy()); // save to cache after fetching from db + $this->cache->save($this->name . '-cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id, $document->getArrayCopy()); // save to cache after fetching from db $this->trigger(self::EVENT_DOCUMENT_READ, $document); return $document; @@ -1467,7 +1470,7 @@ public function updateDocument(string $collection, string $id, Document $documen $document = $this->adapter->updateDocument($collection->getId(), $document); $document = $this->decode($collection, $document); - $this->cache->purge('cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id); + $this->cache->purge($this->name . '-cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id); $this->trigger(self::EVENT_DOCUMENT_UPDATE, $document); return $document; @@ -1517,7 +1520,7 @@ public function updateDocuments(string $collection, array $documents, int $batch foreach ($documents as $key => $document) { $documents[$key] = $this->decode($collection, $document); - $this->cache->purge('cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $document->getId() . ':*'); + $this->cache->purge($this->name . '-cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $document->getId() . ':*'); } $this->trigger(self::EVENT_DOCUMENTS_UPDATE, $documents); @@ -1547,7 +1550,7 @@ public function deleteDocument(string $collection, string $id): bool throw new AuthorizationException($validator->getDescription()); } - $this->cache->purge('cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id); + $this->cache->purge($this->name . '-cache-' . $this->getNamespace() . ':' . $collection->getId() . ':' . $id); $deleted = $this->adapter->deleteDocument($collection->getId(), $id); $this->trigger(self::EVENT_DOCUMENT_DELETE, $document); @@ -1563,7 +1566,7 @@ public function deleteDocument(string $collection, string $id): bool */ public function deleteCachedCollection(string $collection): bool { - return $this->cache->purge('cache-' . $this->getNamespace() . ':' . $collection . ':*'); + return $this->cache->purge($this->name . '-cache-' . $this->getNamespace() . ':' . $collection . ':*'); } /** @@ -1576,7 +1579,7 @@ public function deleteCachedCollection(string $collection): bool */ public function deleteCachedDocument(string $collection, string $id): bool { - return $this->cache->purge('cache-' . $this->getNamespace() . ':' . $collection . ':' . $id); + return $this->cache->purge($this->name . '-cache-' . $this->getNamespace() . ':' . $collection . ':' . $id); } /** From 7ca5ac38f5d3f24a1064ccc1a6b22589385967f2 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Tue, 29 Aug 2023 16:17:24 +0530 Subject: [PATCH 09/21] adds internal id support for create document --- src/Database/Adapter/MariaDB.php | 17 ++++--- src/Database/Adapter/Mongo/MongoDBAdapter.php | 5 +++ src/Database/Adapter/SQLite.php | 11 +++++ src/Database/Validator/Structure.php | 2 +- tests/Database/Base.php | 45 +++++++++++++++++++ 5 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index ddb72d5a8..1ab7e7583 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -496,12 +496,23 @@ public function createDocument(string $collection, Document $document): Document $bindIndex++; } + // Insert manual id if set + if (!empty($document->getInternalId())) { + $bindKey = '_id'; + $columns .= " _id" . ' = :' . $bindKey . ','; + } + $stmt = $this->getPDO() ->prepare("INSERT INTO {$this->getSQLTable($name)} SET {$columns} _uid = :_uid"); $stmt->bindValue(':_uid', $document->getId(), PDO::PARAM_STR); + // Bind manual internal id if set + if (!empty($document->getInternalId())) { + $stmt->bindValue(':_id', $document->getInternalId(), PDO::PARAM_STR); + } + $attributeIndex = 0; foreach ($attributes as $attribute => $value) { if (is_array($value)) { // arrays & objects should be saved as strings @@ -531,11 +542,7 @@ public function createDocument(string $collection, Document $document): Document try { $stmt->execute(); - $statment = $this->getPDO()->prepare("select last_insert_id() as id"); - $statment->execute(); - $last = $statment->fetch(); - $document['$internalId'] = $last['id']; - + $document['$internalId'] = $this->getDocument($collection, $document->getId())->getInternalId(); if (isset($stmtPermissions)) { $stmtPermissions->execute(); } diff --git a/src/Database/Adapter/Mongo/MongoDBAdapter.php b/src/Database/Adapter/Mongo/MongoDBAdapter.php index 690be6bd8..34eac710c 100644 --- a/src/Database/Adapter/Mongo/MongoDBAdapter.php +++ b/src/Database/Adapter/Mongo/MongoDBAdapter.php @@ -386,6 +386,11 @@ public function createDocument(string $collection, Document $document): Document $record = $this->replaceChars('$', '_', $document->getArrayCopy()); + // Insert manual id if set + if (!empty($internalId)) { + $record['_id'] = $internalId; + } + $this->client->insert($name, $record); return $document; diff --git a/src/Database/Adapter/SQLite.php b/src/Database/Adapter/SQLite.php index 41ac61ec4..8307966e2 100644 --- a/src/Database/Adapter/SQLite.php +++ b/src/Database/Adapter/SQLite.php @@ -319,12 +319,23 @@ public function createDocument(string $collection, Document $document): Document $bindIndex++; } + // Insert manual id if set + if (!empty($document->getInternalId())) { + $values[] = '_id'; + $columns[] = "_id"; + } + $stmt = $this->getPDO() ->prepare("INSERT INTO `{$this->getNamespace()}_{$name}` (".implode(', ', $columns).") VALUES (:".implode(', :', $values).");"); $stmt->bindValue(':_uid', $document->getId(), PDO::PARAM_STR); + // Bind manual internal id if set + if (!empty($document->getInternalId())) { + $stmt->bindValue(':_id', $document->getInternalId(), PDO::PARAM_STR); + } + $attributeIndex = 0; foreach ($attributes as $attribute => $value) { if (is_array($value)) { // arrays & objects should be saved as strings diff --git a/src/Database/Validator/Structure.php b/src/Database/Validator/Structure.php index cddcd1a42..f2ae54ada 100644 --- a/src/Database/Validator/Structure.php +++ b/src/Database/Validator/Structure.php @@ -34,7 +34,7 @@ class Structure extends Validator [ '$id' => '$internalId', 'type' => Database::VAR_STRING, - 'size' => 64, + 'size' => 0, 'required' => false, 'signed' => true, 'array' => false, diff --git a/tests/Database/Base.php b/tests/Database/Base.php index 693289c84..45d130bd1 100644 --- a/tests/Database/Base.php +++ b/tests/Database/Base.php @@ -605,6 +605,50 @@ public function testCreateDocument() $this->assertEquals([], $document->getAttribute('empty')); $this->assertEquals('Works', $document->getAttribute('with-dash')); + // Test create document with manual internal id + $manualIdDocument = static::getDatabase()->createDocument('documents', new Document([ + '$internalId' => '56000', + '$permissions' => [ + Permission::read(Role::any()), + Permission::read(Role::user(ID::custom('1'))), + Permission::read(Role::user(ID::custom('2'))), + Permission::create(Role::any()), + Permission::create(Role::user(ID::custom('1x'))), + Permission::create(Role::user(ID::custom('2x'))), + Permission::update(Role::any()), + Permission::update(Role::user(ID::custom('1x'))), + Permission::update(Role::user(ID::custom('2x'))), + Permission::delete(Role::any()), + Permission::delete(Role::user(ID::custom('1x'))), + Permission::delete(Role::user(ID::custom('2x'))), + ], + 'string' => 'text📝', + 'integer' => 5, + 'bigint' => 8589934592, // 2^33 + 'float' => 5.55, + 'boolean' => true, + 'colors' => ['pink', 'green', 'blue'], + 'empty' => [], + 'with-dash' => 'Works', + ])); + + $this->assertEquals('56000', $manualIdDocument->getInternalId()); + $this->assertNotEmpty(true, $manualIdDocument->getId()); + $this->assertIsString($manualIdDocument->getAttribute('string')); + $this->assertEquals('text📝', $manualIdDocument->getAttribute('string')); // Also makes sure an emoji is working + $this->assertIsInt($manualIdDocument->getAttribute('integer')); + $this->assertEquals(5, $manualIdDocument->getAttribute('integer')); + $this->assertIsInt($manualIdDocument->getAttribute('bigint')); + $this->assertEquals(8589934592, $manualIdDocument->getAttribute('bigint')); + $this->assertIsFloat($manualIdDocument->getAttribute('float')); + $this->assertEquals(5.55, $manualIdDocument->getAttribute('float')); + $this->assertIsBool($manualIdDocument->getAttribute('boolean')); + $this->assertEquals(true, $manualIdDocument->getAttribute('boolean')); + $this->assertIsArray($manualIdDocument->getAttribute('colors')); + $this->assertEquals(['pink', 'green', 'blue'], $manualIdDocument->getAttribute('colors')); + $this->assertEquals([], $manualIdDocument->getAttribute('empty')); + $this->assertEquals('Works', $manualIdDocument->getAttribute('with-dash')); + return $document; } @@ -2636,6 +2680,7 @@ public function testExceptionDuplicate(Document $document) public function testExceptionCaseInsensitiveDuplicate(Document $document) { $document->setAttribute('$id', 'caseSensitive'); + $document->setAttribute('$internalId', '200'); static::getDatabase()->createDocument($document->getCollection(), $document); $document->setAttribute('$id', 'CaseSensitive'); From 7f5202fd5293f8fe82c688f59cdd3588c7db2d2b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 30 Aug 2023 15:48:00 +0545 Subject: [PATCH 10/21] fix remove attribute for null values --- src/Database/Document.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Database/Document.php b/src/Database/Document.php index f6c8649b9..880560799 100644 --- a/src/Database/Document.php +++ b/src/Database/Document.php @@ -226,9 +226,12 @@ public function setAttribute(string $key, $value, string $type = self::SET_TYPE_ */ public function removeAttribute(string $key): self { - if (isset($this[$key])) { + // this check is not required, also this + // prevents from removing if the key is set + // as null value explicitly + // if (isset($this[$key])) { unset($this[$key]); - } + // } return $this; } @@ -397,4 +400,4 @@ public function getArrayCopy(array $allow = [], array $disallow = []): array return $output; } -} \ No newline at end of file +} From de4011600a3df601769362eb097d78659b1c2b15 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Sep 2023 08:41:02 +0545 Subject: [PATCH 11/21] add document security --- src/Database/Database.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Database/Database.php b/src/Database/Database.php index 13ad7aa2c..7ef62f6cc 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -208,6 +208,16 @@ class Database 'array' => false, 'filters' => ['json'], ], + [ + '$id' => 'documentSecurity', + 'key' => 'documentSecurity', + 'type' => self::VAR_BOOLEAN, + 'size' => 0, + 'required' => true, + 'signed' => true, + 'array' => false, + 'filters' => [] + ] ], 'indexes' => [], ]; From 69928e0b824d6ac088b68fef12cbbb9b6cce12bf Mon Sep 17 00:00:00 2001 From: prateek banga Date: Thu, 14 Sep 2023 16:26:45 +0530 Subject: [PATCH 12/21] adds code to use createdAt and updatedAt in createDocuments from documents --- src/Database/Database.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 7ef62f6cc..b3d91fc30 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1393,7 +1393,7 @@ public function createDocument(string $collection, Document $document): Document * Create Documents in a batch * * @param string $collection - * @param Document $document + * @param array $documents * * @return Document * @@ -1412,11 +1412,14 @@ public function createDocuments(string $collection, array $documents, int $batch $time = DateTime::now(); foreach ($documents as $key => $document) { + $documentId = $document->getId(); + $createdAt = $document->getCreatedAt(); + $updatedAt = $document->getUpdatedAt(); $document - ->setAttribute('$id', empty($document->getId()) ? ID::unique() : $document->getId()) + ->setAttribute('$id', empty($documentId) ? ID::unique() : $documentId) ->setAttribute('$collection', $collection->getId()) - ->setAttribute('$createdAt', $time) - ->setAttribute('$updatedAt', $time); + ->setAttribute('$createdAt', empty($createdAt) ? $time : $createdAt) + ->setAttribute('$updatedAt', empty($updatedAt) ? $time : $updatedAt); $document = $this->encode($collection, $document); From 66dfebb7d66dc77bebbcb9bcbb5db107b5eed681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 18 Sep 2023 19:37:52 +0000 Subject: [PATCH 13/21] Remove document security --- src/Database/Database.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index b3d91fc30..999e6df7c 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -207,16 +207,6 @@ class Database 'signed' => true, 'array' => false, 'filters' => ['json'], - ], - [ - '$id' => 'documentSecurity', - 'key' => 'documentSecurity', - 'type' => self::VAR_BOOLEAN, - 'size' => 0, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [] ] ], 'indexes' => [], From f947e14d127027c30e1feb8ad43f4613f13334cf Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 18 Sep 2023 23:51:53 +0000 Subject: [PATCH 14/21] chore: revert documentSecurity attribute --- src/Database/Database.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Database/Database.php b/src/Database/Database.php index 999e6df7c..b3d91fc30 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -207,6 +207,16 @@ class Database 'signed' => true, 'array' => false, 'filters' => ['json'], + ], + [ + '$id' => 'documentSecurity', + 'key' => 'documentSecurity', + 'type' => self::VAR_BOOLEAN, + 'size' => 0, + 'required' => true, + 'signed' => true, + 'array' => false, + 'filters' => [] ] ], 'indexes' => [], From 67978147d1309c1f92b1067a752e312719203ec6 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 19 Sep 2023 00:20:06 +0000 Subject: [PATCH 15/21] chore: make document Security optional --- src/Database/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index b3d91fc30..08d0aeb5b 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -213,7 +213,7 @@ class Database 'key' => 'documentSecurity', 'type' => self::VAR_BOOLEAN, 'size' => 0, - 'required' => true, + 'required' => false, 'signed' => true, 'array' => false, 'filters' => [] From 1128f528fa2b9c00ac6d60159edcb31cc494a8cd Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 19 Sep 2023 00:47:58 +0000 Subject: [PATCH 16/21] chore: patch for migrations --- composer.lock | 466 +++++++++++++++++++++++--------------- src/Database/Database.php | 10 +- 2 files changed, 292 insertions(+), 184 deletions(-) diff --git a/composer.lock b/composer.lock index 648ed38c2..3e4b95d1e 100644 --- a/composer.lock +++ b/composer.lock @@ -57,24 +57,26 @@ }, { "name": "utopia-php/framework", - "version": "0.23.2", + "version": "0.31.0", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "847cfd48fa93f25797dea0be5692f5c3735c9b2f" + "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/847cfd48fa93f25797dea0be5692f5c3735c9b2f", - "reference": "847cfd48fa93f25797dea0be5692f5c3735c9b2f", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/207f77378965fca9a9bc3783ea379d3549f86bc0", + "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0", "shasum": "" }, "require": { - "php": ">=8.0.0" + "php": ">=8.0" }, "require-dev": { - "phpunit/phpunit": "^9.5.25", - "vimeo/psalm": "^4.27.0" + "laravel/pint": "^1.2", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.25" }, "type": "library", "autoload": { @@ -94,9 +96,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.23.2" + "source": "https://github.com/utopia-php/framework/tree/0.31.0" }, - "time": "2022-10-25T15:05:52+00:00" + "time": "2023-08-30T16:10:04+00:00" } ], "packages-dev": [ @@ -341,16 +343,16 @@ }, { "name": "composer/semver", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", "shasum": "" }, "require": { @@ -400,9 +402,9 @@ "versioning" ], "support": { - "irc": "irc://irc.freenode.org/composer", + "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" + "source": "https://github.com/composer/semver/tree/3.4.0" }, "funding": [ { @@ -418,7 +420,7 @@ "type": "tidelift" } ], - "time": "2022-04-01T19:23:25+00:00" + "time": "2023-08-31T09:50:34+00:00" }, { "name": "composer/xdebug-handler", @@ -522,17 +524,17 @@ "time": "2019-12-04T15:06:13+00:00" }, { - "name": "doctrine/instantiator", - "version": "1.4.1", + "name": "doctrine/deprecations", + "version": "v1.1.1", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "url": "https://github.com/doctrine/deprecations.git", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { @@ -540,13 +542,60 @@ }, "require-dev": { "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + }, + "time": "2023-06-03T09:27:29+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -573,7 +622,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -589,24 +638,24 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "fakerphp/faker", - "version": "v1.20.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "37f751c67a5372d4e26353bd9384bc03744ec77b" + "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/37f751c67a5372d4e26353bd9384bc03744ec77b", - "reference": "37f751c67a5372d4e26353bd9384bc03744ec77b", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", + "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8.0", "psr/container": "^1.0 || ^2.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" }, @@ -617,7 +666,8 @@ "bamarni/composer-bin-plugin": "^1.4.1", "doctrine/persistence": "^1.3 || ^2.0", "ext-intl": "*", - "symfony/phpunit-bridge": "^4.4 || ^5.2" + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" }, "suggest": { "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", @@ -629,7 +679,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "v1.20-dev" + "dev-main": "v1.21-dev" } }, "autoload": { @@ -654,9 +704,9 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.20.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.0" }, - "time": "2022-07-20T13:12:54+00:00" + "time": "2023-06-12T08:44:38+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -884,16 +934,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -931,7 +981,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -939,7 +989,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "netresearch/jsonmapper", @@ -994,16 +1044,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.1", + "version": "v4.17.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", - "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -1044,9 +1094,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" }, - "time": "2022-09-04T07:30:47+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "openlss/lib-array2xml", @@ -1324,24 +1374,27 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.2", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", - "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.0", "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.13" }, "require-dev": { "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", @@ -1373,29 +1426,76 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" }, - "time": "2022-10-14T12:47:21+00:00" + "time": "2023-08-12T11:01:26+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.24.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1" + }, + "time": "2023-09-18T12:18:02+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.17", + "version": "9.2.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1410,8 +1510,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -1444,7 +1544,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" }, "funding": [ { @@ -1452,7 +1553,7 @@ "type": "github" } ], - "time": "2022-08-30T12:24:04+00:00" + "time": "2023-09-12T14:36:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1697,20 +1798,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.25", + "version": "9.6.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" + "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a122c2ebd469b751d774aa0f613dc0d67697653f", + "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1721,7 +1822,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1739,8 +1840,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -1748,7 +1849,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -1779,7 +1880,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.12" }, "funding": [ { @@ -1795,7 +1897,7 @@ "type": "tidelift" } ], - "time": "2022-09-25T03:44:45+00:00" + "time": "2023-09-12T14:39:31+00:00" }, { "name": "psr/container", @@ -2200,16 +2302,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { @@ -2254,7 +2356,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { @@ -2262,20 +2364,20 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -2317,7 +2419,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -2325,7 +2427,7 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", @@ -2406,16 +2508,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -2458,7 +2560,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -2466,7 +2568,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -2639,16 +2741,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -2687,10 +2789,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -2698,7 +2800,7 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", @@ -2757,16 +2859,16 @@ }, { "name": "sebastian/type", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -2801,7 +2903,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -2809,7 +2911,7 @@ "type": "github" } ], - "time": "2022-09-12T14:47:03+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", @@ -2908,16 +3010,16 @@ }, { "name": "symfony/console", - "version": "v5.4.14", + "version": "v5.4.28", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d" + "reference": "f4f71842f24c2023b91237c72a365306f3c58827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/984ea2c0f45f42dfed01d2f3987b187467c4b16d", - "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d", + "url": "https://api.github.com/repos/symfony/console/zipball/f4f71842f24c2023b91237c72a365306f3c58827", + "reference": "f4f71842f24c2023b91237c72a365306f3c58827", "shasum": "" }, "require": { @@ -2982,12 +3084,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.14" + "source": "https://github.com/symfony/console/tree/v5.4.28" }, "funding": [ { @@ -3003,20 +3105,20 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:01:20+00:00" + "time": "2023-08-07T06:12:30+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.1.1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", - "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { @@ -3025,7 +3127,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -3054,7 +3156,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.1.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -3070,20 +3172,20 @@ "type": "tidelift" } ], - "time": "2022-02-25T11:15:52+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -3098,7 +3200,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3136,7 +3238,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -3152,20 +3254,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "433d05519ce6990bf3530fba6957499d327395c2" + "reference": "875e90aeea2777b6f135677f618529449334a612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2", - "reference": "433d05519ce6990bf3530fba6957499d327395c2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", + "reference": "875e90aeea2777b6f135677f618529449334a612", "shasum": "" }, "require": { @@ -3177,7 +3279,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3217,7 +3319,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" }, "funding": [ { @@ -3233,20 +3335,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "shasum": "" }, "require": { @@ -3258,7 +3360,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3301,7 +3403,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -3317,20 +3419,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -3345,7 +3447,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3384,7 +3486,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -3400,20 +3502,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", "shasum": "" }, "require": { @@ -3422,7 +3524,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3463,7 +3565,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, "funding": [ { @@ -3479,20 +3581,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.26.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -3501,7 +3603,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3546,7 +3648,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -3562,20 +3664,20 @@ "type": "tidelift" } ], - "time": "2022-05-10T07:21:04+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.1.1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "925e713fe8fcacf6bc05e936edd8dd5441a21239" + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/925e713fe8fcacf6bc05e936edd8dd5441a21239", - "reference": "925e713fe8fcacf6bc05e936edd8dd5441a21239", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", "shasum": "" }, "require": { @@ -3585,13 +3687,10 @@ "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -3631,7 +3730,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.1.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" }, "funding": [ { @@ -3647,20 +3746,20 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:18:58+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/string", - "version": "v6.1.6", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864" + "reference": "53d1a83225002635bca3482fcbf963001313fb68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7e7e0ff180d4c5a6636eaad57b65092014b61864", - "reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864", + "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", + "reference": "53d1a83225002635bca3482fcbf963001313fb68", "shasum": "" }, "require": { @@ -3671,12 +3770,13 @@ "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/translation-contracts": "<2.0" + "symfony/translation-contracts": "<2.5" }, "require-dev": { "symfony/error-handler": "^5.4|^6.0", "symfony/http-client": "^5.4|^6.0", - "symfony/translation-contracts": "^2.0|^3.0", + "symfony/intl": "^6.2", + "symfony/translation-contracts": "^2.5|^3.0", "symfony/var-exporter": "^5.4|^6.0" }, "type": "library", @@ -3716,7 +3816,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.1.6" + "source": "https://github.com/symfony/string/tree/v6.3.2" }, "funding": [ { @@ -3732,7 +3832,7 @@ "type": "tidelift" } ], - "time": "2022-10-10T09:34:31+00:00" + "time": "2023-07-05T08:41:27+00:00" }, { "name": "theseer/tokenizer", @@ -4109,5 +4209,5 @@ "ext-redis": "*", "ext-mongodb": "*" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Database/Database.php b/src/Database/Database.php index 08d0aeb5b..fdb9a5eb7 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1302,7 +1302,11 @@ public function deleteIndex(string $collection, string $id): bool public function getDocument(string $collection, string $id): Document { if ($collection === self::METADATA && $id === self::METADATA) { - return new Document($this->collection); + $coll = $this->collection; + if(!str_contains($this->name, 'v14x')) { + unset($coll['attributes'][3]); + } + return new Document($coll); } if (empty($collection)) { @@ -1854,6 +1858,10 @@ public function casting(Document $collection, Document $document): Document continue; } + if ($collection->getId() === self::METADATA && $key === 'documentSecurity' && !str_contains($this->name, 'v14x')) { + continue; + } + if ($array) { $value = (!is_string($value)) ? ($value ?? []) : json_decode($value, true); } else { From 01c1751a92e2cb9340b6631590bf16fa36f955f9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 19 Sep 2023 00:57:04 +0000 Subject: [PATCH 17/21] chore: patch for migrations --- src/Database/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index fdb9a5eb7..e49b21ea0 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1858,7 +1858,7 @@ public function casting(Document $collection, Document $document): Document continue; } - if ($collection->getId() === self::METADATA && $key === 'documentSecurity' && !str_contains($this->name, 'v14x')) { + if ($collection->getId() === self::METADATA && $document->getId() === self::METADATA && $key === 'documentSecurity' && !str_contains($this->name, 'v14x')) { continue; } From e50303960aea7c7223663af076c8708668a69093 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 19 Sep 2023 07:30:54 +0545 Subject: [PATCH 18/21] fix remove attribute --- src/Database/Document.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Database/Document.php b/src/Database/Document.php index 880560799..295643f8f 100644 --- a/src/Database/Document.php +++ b/src/Database/Document.php @@ -226,12 +226,13 @@ public function setAttribute(string $key, $value, string $type = self::SET_TYPE_ */ public function removeAttribute(string $key): self { - // this check is not required, also this + // isset fails when explicitely set to null // prevents from removing if the key is set // as null value explicitly // if (isset($this[$key])) { + if(array_key_exists($key, $this->getArrayCopy())) { unset($this[$key]); - // } + } return $this; } From 8920b94782fe4e34ab52aa9939ca5abb3a8236d6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 19 Sep 2023 07:36:23 +0545 Subject: [PATCH 19/21] modify encode,decode and casting for document security --- src/Database/Database.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index e49b21ea0..3a4ea12e5 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1794,6 +1794,11 @@ public function encode(Document $collection, Document $document): Document } $document->setAttribute($key, $value); + $documentId = $document->getId(); + $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + $document->removeAttribute('documentSecurity'); + } } return $document; @@ -1828,6 +1833,11 @@ public function decode(Document $collection, Document $document): Document } $document->setAttribute($key, ($array) ? $value : $value[0]); + $documentId = $document->getId(); + $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + $document->removeAttribute('documentSecurity'); + } } return $document; @@ -1858,10 +1868,6 @@ public function casting(Document $collection, Document $document): Document continue; } - if ($collection->getId() === self::METADATA && $document->getId() === self::METADATA && $key === 'documentSecurity' && !str_contains($this->name, 'v14x')) { - continue; - } - if ($array) { $value = (!is_string($value)) ? ($value ?? []) : json_decode($value, true); } else { @@ -1891,6 +1897,11 @@ public function casting(Document $collection, Document $document): Document } $document->setAttribute($key, ($array) ? $value : $value[0]); + $documentId = $document->getId(); + $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + $document->removeAttribute('documentSecurity'); + } } return $document; From c614b8564537feb41a29b501d293110744999eeb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 19 Sep 2023 08:53:04 +0545 Subject: [PATCH 20/21] add console check --- src/Database/Database.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 3a4ea12e5..361def3fb 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1303,7 +1303,7 @@ public function getDocument(string $collection, string $id): Document { if ($collection === self::METADATA && $id === self::METADATA) { $coll = $this->collection; - if(!str_contains($this->name, 'v14x')) { + if(!str_contains($this->name, 'v14x') || $this->namespace === '_console') { unset($coll['attributes'][3]); } return new Document($coll); @@ -1796,7 +1796,7 @@ public function encode(Document $collection, Document $document): Document $document->setAttribute($key, $value); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { $document->removeAttribute('documentSecurity'); } } @@ -1835,7 +1835,7 @@ public function decode(Document $collection, Document $document): Document $document->setAttribute($key, ($array) ? $value : $value[0]); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { $document->removeAttribute('documentSecurity'); } } @@ -1899,7 +1899,7 @@ public function casting(Document $collection, Document $document): Document $document->setAttribute($key, ($array) ? $value : $value[0]); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x')) { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { $document->removeAttribute('documentSecurity'); } } From d79bc87c9818be7731e9cd97f31e9b999f1cdcc7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 19 Sep 2023 09:00:29 +0545 Subject: [PATCH 21/21] fix typo --- src/Database/Database.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 361def3fb..078ab2fac 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1303,7 +1303,7 @@ public function getDocument(string $collection, string $id): Document { if ($collection === self::METADATA && $id === self::METADATA) { $coll = $this->collection; - if(!str_contains($this->name, 'v14x') || $this->namespace === '_console') { + if(!str_contains($this->name, 'v14x') || $this->getNamespace() === '_console') { unset($coll['attributes'][3]); } return new Document($coll); @@ -1796,7 +1796,7 @@ public function encode(Document $collection, Document $document): Document $document->setAttribute($key, $value); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->getNamespace() != '_console') { $document->removeAttribute('documentSecurity'); } } @@ -1835,7 +1835,7 @@ public function decode(Document $collection, Document $document): Document $document->setAttribute($key, ($array) ? $value : $value[0]); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->getNamespace() != '_console') { $document->removeAttribute('documentSecurity'); } } @@ -1899,7 +1899,7 @@ public function casting(Document $collection, Document $document): Document $document->setAttribute($key, ($array) ? $value : $value[0]); $documentId = $document->getId(); $keepDocumentSecurity = str_starts_with($documentId, 'database_') && !str_contains($documentId, '_collection_'); - if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->namespace != '_console') { + if ($collection->getId() === self::METADATA && !$keepDocumentSecurity && !str_contains($this->name, 'v14x') && $this->getNamespace() != '_console') { $document->removeAttribute('documentSecurity'); } }