Skip to content

Commit

Permalink
✨ modified() can handle files and site objects as well as extended pa…
Browse files Browse the repository at this point in the history
…ge objects
  • Loading branch information
bnomei committed Dec 14, 2021
1 parent e837d93 commit 1ef86c5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
22 changes: 18 additions & 4 deletions classes/BoostIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,31 @@ public static function tinyurl($id): string

public static function modified($id): ?int
{
if (is_a($id, \Kirby\Cms\Page::class)) {
$modified = null;

if ($id instanceof \Kirby\Cms\Page) {
$id = $id->id();
$modified = BoostCache::singleton()->get(crc32($id) . '-modified');
}
elseif ($id instanceof \Kirby\Cms\File) {
$modified = $id->modified();
$id = $id->id();
}
$modified = BoostCache::singleton()->get(crc32($id) . '-modified');
if ($modified) {
elseif ($id instanceof \Kirby\Cms\Site) {
$modified = filemtime($id->contentFile());
$id = '$';
}

if ($modified) { // could be false
return $modified;
}

if ($page = \bolt($id)) {
$page->boost(); // force cache update
return $page->modified();
$modified = $page->modified();
if ($modified) { // could be false
return $modified;
}
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-boost",
"type": "kirby-plugin",
"version": "1.8.1",
"version": "1.8.2",
"description": "Boost the speed of Kirby by having content files of pages cached, with automatic unique ID, fast lookup and Tiny-URL.",
"license": "MIT",
"authors": [
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class InstalledVersions
private static $installed = array (
'root' =>
array (
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
Expand All @@ -46,8 +46,8 @@ class InstalledVersions
),
'bnomei/kirby3-boost' =>
array (
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array (
'root' =>
array (
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
Expand All @@ -22,8 +22,8 @@
),
'bnomei/kirby3-boost' =>
array (
'pretty_version' => '1.8.1',
'version' => '1.8.1.0',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
Expand Down

0 comments on commit 1ef86c5

Please sign in to comment.