From 510251353ab3ced0d45d21e0d70a340e11071660 Mon Sep 17 00:00:00 2001 From: bnomei Date: Wed, 3 Jul 2024 10:39:03 +0200 Subject: [PATCH] :sparkles: lazyloading of client and default to not read from cache --- README.md | 77 ++++++++++++- classes/Mongodb.php | 36 +++--- composer.json | 2 +- composer.lock | 204 +++++++++++++++++----------------- index.php | 6 +- vendor/composer/installed.php | 8 +- 6 files changed, 204 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index e3e7fc7..e3a291f 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,77 @@ $pages = khulan([ ]); ``` +### Example: Filtering and Resolving Relations + +With Kirby's content cache as a NoSQL database you can do some advanced filtering. If you would do the same with Kirby's +filtering on collection you would end up loading a lot pages and that is not as efficient. We can load the information +we need directly from the cache without the need to load the full page object. + +Let's assume we have two models: `film` and `actor`. The `film` model has a field `actors` which is a pages field with +linked `actor` pages. We want to list all films with their actors. + +#### Load 1000 films and their actors, total of 6429 pages accessed in 250ms + +```php +$films = page('films')->children(); +foreach ($films as $film) { + echo $film->title(); + $actors = []; + foreach ($film->actors()->toPages() as $actor) { + $actors[] = $actor->title(); + } + echo implode(', ', $actors); +} +?> +``` + +#### Query the cache instead to get the same information in under 100ms + +```php +/** @var \MongoDB\Driver\Cursor $films */ +$films = khulan()->aggregate([ + [ + // only get pages with template 'film' + '$match' => ['template' => 'film'], + ], + [ + // lookup actors by their mongodb objectId + // this will create an array of objects + '$lookup' => [ + 'from' => 'kirby', + 'localField' => 'actors{}', + 'foreignField' => '_id', + 'as' => 'actor_details', + ], + ], + [ + // only get the fields we need + // to make the query even faster + '$project' => [ + 'title' => 1, + 'id' => 1, + 'actor_details.title' => 1, + ], + ], +]); + +/** @var \MongoDB\BSON\Document $film */ +foreach ($films as $film) { ?> +
+ title) ?> + +
+ [!NOTE] +> +> This example is from [my Sakila DB kit](https://github.com/bnomei/kirby-sakila-kit/tree/with-mongodb-plugin). + ## MongoDB Client You can access the underlying MongoDB client directly. @@ -206,9 +277,9 @@ return [ | port | `27017` | | | username | `null` | | | password | `null` | | -| database | `kirby` | | -| khulan.read | `true` | read from cache | -| khulan.write | `true` | write to cache | +| database | `kirby` | you can give it any name you want and MongoDB will create it for you | +| khulan.read | `false` | read from cache is disabled by default as loading from file might be faster | +| khulan.write | `true` | write to cache for all models that use the ModelWithKhulan trait | | khulan.patch-files-class | `true` | monkey-patch the \Kirby\CMS\Files class to use Khulan for caching it content | ## Disclaimer diff --git a/classes/Mongodb.php b/classes/Mongodb.php index f4c2d22..45db6f5 100644 --- a/classes/Mongodb.php +++ b/classes/Mongodb.php @@ -16,7 +16,7 @@ final class Mongodb extends Cache { - protected Client $_client; + protected ?Client $_client = null; /** * Sets all parameters which are needed to connect to MongoDB. @@ -44,20 +44,7 @@ public function __construct(array $options = []) parent::__construct($this->options); - if (! empty($this->options['username']) && ! empty($this->options['password'])) { - $auth = $this->options['username'].':'.$this->options['password'].'@'; - } else { - $auth = ''; - } - - $this->_client = new Client( - 'mongodb://'.$auth.$this->options['host'].':'.$this->options['port'] - ); - $this->_client->selectDatabase($this->options['database']); - - if ($this->option('debug')) { - $this->flush(); - } + // client init is done lazily see ->client() } /** @@ -201,12 +188,29 @@ public function cache(): self public function client(): Client { + if (! $this->_client) { + if (! empty($this->options['username']) && ! empty($this->options['password'])) { + $auth = $this->options['username'].':'.$this->options['password'].'@'; + } else { + $auth = ''; + } + + $this->_client = new Client( + 'mongodb://'.$auth.$this->options['host'].':'.$this->options['port'] + ); + $this->_client->selectDatabase($this->options['database']); + + if ($this->option('debug')) { + $this->flush(); + } + } + return $this->_client; } public function collection(string $collection): Collection { - return $this->_client->selectCollection($this->options['database'], $collection); + return $this->client()->selectCollection($this->options['database'], $collection); } public function cacheCollection(): Collection diff --git a/composer.json b/composer.json index 223c6b0..9b60c21 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "bnomei/kirby-mongodb", "type": "kirby-plugin", - "version": "1.0.2", + "version": "1.1.0", "description": "Khulan is a cache driver and content cache with NoSQL interface for Kirby using MongoDB", "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index ee8a768..685bbee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "56ec8c3c2e9b523f922fbd41ef84444d", + "content-hash": "905563bebeeb62aaeed911feac8ef41a", "packages": [ { "name": "getkirby/composer-installer", @@ -1611,16 +1611,16 @@ }, { "name": "illuminate/bus", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/bus.git", - "reference": "4ab0439597a6c8c2f749173e272e9d33282bff97" + "reference": "9a8649eb57a6621eed87ecc18af7eb84aa180992" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/bus/zipball/4ab0439597a6c8c2f749173e272e9d33282bff97", - "reference": "4ab0439597a6c8c2f749173e272e9d33282bff97", + "url": "https://api.github.com/repos/illuminate/bus/zipball/9a8649eb57a6621eed87ecc18af7eb84aa180992", + "reference": "9a8649eb57a6621eed87ecc18af7eb84aa180992", "shasum": "" }, "require": { @@ -1660,20 +1660,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-05-27T11:26:35+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/collections", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "6923dc8c83b8c065c3b89cb4c2a4b10a4288ce79" + "reference": "358fd6dcce6927ee9d7cf520fa619f4597020d52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/6923dc8c83b8c065c3b89cb4c2a4b10a4288ce79", - "reference": "6923dc8c83b8c065c3b89cb4c2a4b10a4288ce79", + "url": "https://api.github.com/repos/illuminate/collections/zipball/358fd6dcce6927ee9d7cf520fa619f4597020d52", + "reference": "358fd6dcce6927ee9d7cf520fa619f4597020d52", "shasum": "" }, "require": { @@ -1715,20 +1715,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-21T15:52:51+00:00" + "time": "2024-06-28T20:14:10+00:00" }, { "name": "illuminate/conditionable", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", - "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb" + "reference": "362dd761b9920367bca1427a902158225e9e3a23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/conditionable/zipball/8a558fec063b6a63da1c3af1d219c0f998edffeb", - "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/362dd761b9920367bca1427a902158225e9e3a23", + "reference": "362dd761b9920367bca1427a902158225e9e3a23", "shasum": "" }, "require": { @@ -1761,20 +1761,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-04-04T17:36:49+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/console", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", - "reference": "a82fb59ac16fd4efcfd521a05babbd2a5f10422d" + "reference": "eb0c8ca9e2cff09701ee759587d350742e790634" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/console/zipball/a82fb59ac16fd4efcfd521a05babbd2a5f10422d", - "reference": "a82fb59ac16fd4efcfd521a05babbd2a5f10422d", + "url": "https://api.github.com/repos/illuminate/console/zipball/eb0c8ca9e2cff09701ee759587d350742e790634", + "reference": "eb0c8ca9e2cff09701ee759587d350742e790634", "shasum": "" }, "require": { @@ -1827,20 +1827,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-27T07:57:32+00:00" + "time": "2024-06-28T20:18:40+00:00" }, { "name": "illuminate/container", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7" + "reference": "280405e0b577504b97feae0e7c7f5399816ccff1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", - "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", + "url": "https://api.github.com/repos/illuminate/container/zipball/280405e0b577504b97feae0e7c7f5399816ccff1", + "reference": "280405e0b577504b97feae0e7c7f5399816ccff1", "shasum": "" }, "require": { @@ -1878,20 +1878,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-04-04T17:36:49+00:00" + "time": "2024-07-02T15:41:17+00:00" }, { "name": "illuminate/contracts", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "86c1331d0b06c59ca21723d8bfc9faaa19430b46" + "reference": "eb8ccfbc5905c5631712d157cccdd7bc9db692e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/86c1331d0b06c59ca21723d8bfc9faaa19430b46", - "reference": "86c1331d0b06c59ca21723d8bfc9faaa19430b46", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/eb8ccfbc5905c5631712d157cccdd7bc9db692e0", + "reference": "eb8ccfbc5905c5631712d157cccdd7bc9db692e0", "shasum": "" }, "require": { @@ -1926,20 +1926,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-05-21T17:42:34+00:00" + "time": "2024-07-01T21:58:24+00:00" }, { "name": "illuminate/database", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "d2bd095eab3d7a1e869b5824bcada7492e447ec7" + "reference": "6576f6fcc871a6ad173b6e246e8d2c63cd7cfe1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/d2bd095eab3d7a1e869b5824bcada7492e447ec7", - "reference": "d2bd095eab3d7a1e869b5824bcada7492e447ec7", + "url": "https://api.github.com/repos/illuminate/database/zipball/6576f6fcc871a6ad173b6e246e8d2c63cd7cfe1a", + "reference": "6576f6fcc871a6ad173b6e246e8d2c63cd7cfe1a", "shasum": "" }, "require": { @@ -1994,20 +1994,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-24T20:24:42+00:00" + "time": "2024-07-02T15:56:54+00:00" }, { "name": "illuminate/events", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", - "reference": "18cf9c17f4656778355e5e49bb193b3cf585a668" + "reference": "2ca94accf7e30e478a1cb2b0501c5be4478cb717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/events/zipball/18cf9c17f4656778355e5e49bb193b3cf585a668", - "reference": "18cf9c17f4656778355e5e49bb193b3cf585a668", + "url": "https://api.github.com/repos/illuminate/events/zipball/2ca94accf7e30e478a1cb2b0501c5be4478cb717", + "reference": "2ca94accf7e30e478a1cb2b0501c5be4478cb717", "shasum": "" }, "require": { @@ -2049,20 +2049,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-04-04T17:36:49+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/filesystem", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", - "reference": "3a09c14df1085de6e81cecb8b5df2031c8872ca2" + "reference": "43b8d2af61dd6ca882e192fa4ca803d2294d4507" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/3a09c14df1085de6e81cecb8b5df2031c8872ca2", - "reference": "3a09c14df1085de6e81cecb8b5df2031c8872ca2", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/43b8d2af61dd6ca882e192fa4ca803d2294d4507", + "reference": "43b8d2af61dd6ca882e192fa4ca803d2294d4507", "shasum": "" }, "require": { @@ -2116,20 +2116,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-05-30T15:47:53+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/http", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", - "reference": "69aa1453484043b02f1766afe433395bff4a75a6" + "reference": "bbeda8564171e44c202688f5cacb6eb67ea6ec3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/http/zipball/69aa1453484043b02f1766afe433395bff4a75a6", - "reference": "69aa1453484043b02f1766afe433395bff4a75a6", + "url": "https://api.github.com/repos/illuminate/http/zipball/bbeda8564171e44c202688f5cacb6eb67ea6ec3b", + "reference": "bbeda8564171e44c202688f5cacb6eb67ea6ec3b", "shasum": "" }, "require": { @@ -2177,20 +2177,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-19T14:26:13+00:00" + "time": "2024-07-01T20:51:35+00:00" }, { "name": "illuminate/macroable", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", - "reference": "5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa" + "reference": "e1cb9e51b9ed5d3c9bc1ab431d0a52fe42a990ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/macroable/zipball/5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa", - "reference": "5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/e1cb9e51b9ed5d3c9bc1ab431d0a52fe42a990ed", + "reference": "e1cb9e51b9ed5d3c9bc1ab431d0a52fe42a990ed", "shasum": "" }, "require": { @@ -2223,20 +2223,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-05-16T21:43:47+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/pipeline", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/pipeline.git", - "reference": "f9fc10f5af04035339f4e8ecbc6bcfaa1e7d74a6" + "reference": "ca9266eecf659f7e60c06758969b2ae3918ea3da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/pipeline/zipball/f9fc10f5af04035339f4e8ecbc6bcfaa1e7d74a6", - "reference": "f9fc10f5af04035339f4e8ecbc6bcfaa1e7d74a6", + "url": "https://api.github.com/repos/illuminate/pipeline/zipball/ca9266eecf659f7e60c06758969b2ae3918ea3da", + "reference": "ca9266eecf659f7e60c06758969b2ae3918ea3da", "shasum": "" }, "require": { @@ -2271,20 +2271,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-04-04T17:36:49+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/session", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", - "reference": "9ff6f25fe01f8597e7d62edd42262a7396f05b69" + "reference": "b831db344028e665052a4de88fd5590bfa1707c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/session/zipball/9ff6f25fe01f8597e7d62edd42262a7396f05b69", - "reference": "9ff6f25fe01f8597e7d62edd42262a7396f05b69", + "url": "https://api.github.com/repos/illuminate/session/zipball/b831db344028e665052a4de88fd5590bfa1707c3", + "reference": "b831db344028e665052a4de88fd5590bfa1707c3", "shasum": "" }, "require": { @@ -2328,20 +2328,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-07T14:38:26+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "illuminate/support", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "ee18738fad2592734c3db7542bb8c0c4bf5afd89" + "reference": "a8f299ed76d52fc048decada3571628e65fa5c41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/ee18738fad2592734c3db7542bb8c0c4bf5afd89", - "reference": "ee18738fad2592734c3db7542bb8c0c4bf5afd89", + "url": "https://api.github.com/repos/illuminate/support/zipball/a8f299ed76d52fc048decada3571628e65fa5c41", + "reference": "a8f299ed76d52fc048decada3571628e65fa5c41", "shasum": "" }, "require": { @@ -2402,20 +2402,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-27T08:41:09+00:00" + "time": "2024-07-01T21:58:57+00:00" }, { "name": "illuminate/view", - "version": "v11.13.0", + "version": "v11.14.0", "source": { "type": "git", "url": "https://github.com/illuminate/view.git", - "reference": "3e66fa68c8ef4081ba12243c1eb3a02fded58958" + "reference": "daca4922fdb590144657171a06be7babcc0c910e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/view/zipball/3e66fa68c8ef4081ba12243c1eb3a02fded58958", - "reference": "3e66fa68c8ef4081ba12243c1eb3a02fded58958", + "url": "https://api.github.com/repos/illuminate/view/zipball/daca4922fdb590144657171a06be7babcc0c910e", + "reference": "daca4922fdb590144657171a06be7babcc0c910e", "shasum": "" }, "require": { @@ -2456,7 +2456,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-06-20T14:43:11+00:00" + "time": "2024-06-28T20:10:30+00:00" }, { "name": "jean85/pretty-package-versions", @@ -3174,16 +3174,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "v5.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", "shasum": "" }, "require": { @@ -3194,7 +3194,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -3226,9 +3226,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-07-01T20:03:41+00:00" }, { "name": "nunomaduro/collision", @@ -3666,26 +3666,26 @@ }, { "name": "pestphp/pest-plugin-type-coverage", - "version": "v2.8.3", + "version": "v2.8.4", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-type-coverage.git", - "reference": "bb232225c3dd6468dffdab271b3d67377afed369" + "reference": "ce599efae7c2493e300960cb9c697a9bdd15c44e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-type-coverage/zipball/bb232225c3dd6468dffdab271b3d67377afed369", - "reference": "bb232225c3dd6468dffdab271b3d67377afed369", + "url": "https://api.github.com/repos/pestphp/pest-plugin-type-coverage/zipball/ce599efae7c2493e300960cb9c697a9bdd15c44e", + "reference": "ce599efae7c2493e300960cb9c697a9bdd15c44e", "shasum": "" }, "require": { "pestphp/pest-plugin": "^2.1.1", "php": "^8.1", - "phpstan/phpstan": "^1.11.3", + "phpstan/phpstan": "^1.11.6", "tomasvotruba/type-coverage": "^0.2.8" }, "require-dev": { - "pestphp/pest": "^2.34.7", + "pestphp/pest": "^2.34.8", "pestphp/pest-dev-tools": "^2.16.0" }, "type": "library", @@ -3719,7 +3719,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest-plugin-type-coverage/issues", - "source": "https://github.com/pestphp/pest-plugin-type-coverage/tree/v2.8.3" + "source": "https://github.com/pestphp/pest-plugin-type-coverage/tree/v2.8.4" }, "funding": [ { @@ -3735,7 +3735,7 @@ "type": "patreon" } ], - "time": "2024-06-03T19:38:34+00:00" + "time": "2024-07-01T17:18:50+00:00" }, { "name": "phar-io/manifest", @@ -4248,16 +4248,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.5", + "version": "1.11.6", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" + "reference": "6ac78f1165346c83b4a753f7e4186d969c6ad0ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", - "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6ac78f1165346c83b4a753f7e4186d969c6ad0ee", + "reference": "6ac78f1165346c83b4a753f7e4186d969c6ad0ee", "shasum": "" }, "require": { @@ -4302,20 +4302,20 @@ "type": "github" } ], - "time": "2024-06-17T15:10:54+00:00" + "time": "2024-07-01T15:33:06+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.14", + "version": "10.1.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b" + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", - "reference": "e3f51450ebffe8e0efdf7346ae966a656f7d5e5b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", "shasum": "" }, "require": { @@ -4372,7 +4372,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.14" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.15" }, "funding": [ { @@ -4380,7 +4380,7 @@ "type": "github" } ], - "time": "2024-03-12T15:33:41+00:00" + "time": "2024-06-29T08:25:15+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/index.php b/index.php index 449384f..625972c 100644 --- a/index.php +++ b/index.php @@ -69,7 +69,7 @@ function khulan(string|array|null $search = null): mixed // khulan 'khulan' => [ // cache for models - 'read' => true, + 'read' => false, // mongodb is most likely slower than file system for the pages 'write' => true, 'patch-files-class' => true, // monkey patch files class ], @@ -79,8 +79,8 @@ function khulan(string|array|null $search = null): mixed ], 'hooks' => [ 'system.loadPlugins:after' => function () { - if (option('bnomei.mongodb.khulan.read') && - option('bnomei.mongodb.khulan.write') && + if ((option('bnomei.mongodb.khulan.read') || + option('bnomei.mongodb.khulan.write') ) && khulan()->countDocuments() === 0) { Khulan::index(); } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 48325b8..957fbc4 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,8 +1,8 @@ array( 'name' => 'bnomei/kirby-mongodb', - 'pretty_version' => '1.0.2', - 'version' => '1.0.2.0', + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', 'reference' => null, 'type' => 'kirby-plugin', 'install_path' => __DIR__ . '/../../', @@ -11,8 +11,8 @@ ), 'versions' => array( 'bnomei/kirby-mongodb' => array( - 'pretty_version' => '1.0.2', - 'version' => '1.0.2.0', + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', 'reference' => null, 'type' => 'kirby-plugin', 'install_path' => __DIR__ . '/../../',