Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

Commit 6bd0624

Browse files
committed
🐛 id-indexing (not content cache) did not consider drafts when performing full index
drafts where added to index less obviously later when any hook was triggered or and search to that id caused a crawl. now it should not crawl for individual ids that often but initial indexing is a bit slower.
1 parent ee60864 commit 6bd0624

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ echo $page->tinyurl(); // https://devkit.bnomei.com/x/8j5g64hh
320320
| expire | `0` | expire in minutes for all caches created |
321321
| read | `true` | read from cache |
322322
| write | `true` | write to cache |
323+
| drafts | `true` | index drafts |
323324
| fileModifiedCheck | `false` | expects file to not be altered outside of kirby |
324325
| index.generator | callback | the uuid genertor |
325326
| tinyurl.url | callback | returning `site()->url()`. Use htaccess on that domain to redirect `RewriteRule (.*) http://www.bnomei.com/x/$1 [R=301]` |

classes/BoostIndex.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public function index(bool $force = false, ?Page $target = null): int
7575

7676
$this->index = [];
7777
$count = 0;
78-
// NOT: index() does not include drafts
7978
foreach (kirby()->collection('boostidpages') as $page) {
8079
if ($this->add($page)) {
8180
$count++;
@@ -124,7 +123,6 @@ public function findByBoostId(string $boostid, bool $throwException = true): ?Pa
124123
if ($crawl) {
125124
return $crawl;
126125
} elseif ($throwException) {
127-
$this->write();
128126
throw new \Exception("No page found for BoostID: " . $boostid);
129127
}
130128
}

collections/boostidpages.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// NOTE: this does not have a cached since cached content is assumed
55
// NOTE: this collection does not include drafts
66
// PERFORMANCE ISSUE: https://github.com/getkirby/kirby/issues/3746
7-
return $site->index()->filter(function ($page) {
7+
$drafts = option('bnomei.boost.drafts');
8+
return $site->index($drafts)->filter(function ($page) {
89
return $page->hasBoost() === true;
910
});
1011
};

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bnomei/kirby3-boost",
33
"type": "kirby-plugin",
4-
"version": "1.6.6",
4+
"version": "1.7.0",
55
"description": "Boost the speed of Kirby by having content files of pages cached, with automatic unique ID, fast lookup and Tiny-URL.",
66
"license": "MIT",
77
"authors": [

index.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function boost(string $id): ?\Kirby\Cms\Page
3030
/*
3131
function siteIndexFilterByBoostID(string $id): ?\Kirby\Cms\Page
3232
{
33-
return site()->index()->filter(function ($page) use ($id) {
33+
$drafts = option('bnomei.boost.drafts');
34+
return site()->index($drafts)->filter(function ($page) use ($id) {
3435
return $page->boostIDField()->value() === $id;
3536
})->first();
3637
}
@@ -45,6 +46,7 @@ function siteIndexFilterByBoostID(string $id): ?\Kirby\Cms\Page
4546
'fileModifiedCheck' => false, // expects file to not be altered outside of kirby
4647
'read' => true, // read from cache
4748
'write' => true, // write to cache
49+
'drafts' => true, // index drafts as well
4850
'index' => [
4951
'generator' => function (?string $seed = null) {
5052
// override with custom callback if needed
@@ -183,10 +185,12 @@ function siteIndexFilterByBoostID(string $id): ?\Kirby\Cms\Page
183185
],
184186
'siteMethods' => [
185187
'boost' => function () {
186-
return site()->index()->boost();
188+
$drafts = option('bnomei.boost.drafts');
189+
return site()->index($drafts)->boost();
187190
},
188191
'boostmark' => function () {
189-
return site()->index()->boostmark();
192+
$drafts = option('bnomei.boost.drafts');
193+
return site()->index($drafts)->boostmark();
190194
},
191195
],
192196
'fieldMethods' => [

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php return array(
22
'root' => array(
3-
'pretty_version' => '1.6.6',
4-
'version' => '1.6.6.0',
3+
'pretty_version' => '1.7.0',
4+
'version' => '1.7.0.0',
55
'type' => 'kirby-plugin',
66
'install_path' => __DIR__ . '/../../',
77
'aliases' => array(),
@@ -20,8 +20,8 @@
2020
'dev_requirement' => false,
2121
),
2222
'bnomei/kirby3-boost' => array(
23-
'pretty_version' => '1.6.6',
24-
'version' => '1.6.6.0',
23+
'pretty_version' => '1.7.0',
24+
'version' => '1.7.0.0',
2525
'type' => 'kirby-plugin',
2626
'install_path' => __DIR__ . '/../../',
2727
'aliases' => array(),

0 commit comments

Comments
 (0)