Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnomei committed Feb 3, 2024
2 parents 69390d4 + bc40ecb commit 7e567f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions classes/Bolt.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Bolt
*/
private static $idToPage;

public function __construct(Page $parent = null)
public function __construct(?Page $parent = null)
{
$kirby = kirby();
$this->root = $kirby->root('content');
Expand Down Expand Up @@ -232,7 +232,7 @@ public function findByID(string $id, bool $cache = true, bool $extend = true): ?
return $page;
}

public static function page(string $id, Page $parent = null, bool $cache = true, bool $extend = true): ?Page
public static function page(string $id, ?Page $parent = null, bool $cache = true, bool $extend = true): ?Page
{
return (new self($parent))->findByID($id, $cache, $extend);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/BoostIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function write(): bool
return false;
}

public function index(bool $force = false, Page $target = null): int
public function index(bool $force = false, ?Page $target = null): int
{

$count = $this->index ? count($this->index) : 0;
Expand Down
14 changes: 7 additions & 7 deletions classes/ModelHasBoost.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function setBoostWillBeDeleted(bool $value): void
$this->boostWillBeDeleted = $value;
}

public function isContentBoosted(string $languageCode = null): bool
public function isContentBoosted(?string $languageCode = null): bool
{
return $this->readContentCache($languageCode) !== null;
}

public function contentBoostedKey(string $languageCode = null): string
public function contentBoostedKey(?string $languageCode = null): string
{
$key = hash(BoostCache::hashalgo(), $this->id()); // can not use UUID since content not loaded yet
if (! $languageCode) {
Expand All @@ -42,7 +42,7 @@ public function contentBoostedKey(string $languageCode = null): string
return $key;
}

public function isContentCacheExpiredByModified(string $languageCode = null): bool
public function isContentCacheExpiredByModified(?string $languageCode = null): bool
{
$cache = BoostCache::singleton();
if (! $cache) {
Expand Down Expand Up @@ -70,7 +70,7 @@ public function isContentCacheExpiredByModified(string $languageCode = null): bo
return false;
}

public function readContentCache(string $languageCode = null): ?array
public function readContentCache(?string $languageCode = null): ?array
{
if ($this->checkModifiedTimestampForContentBoost()) {
if ($this->isContentCacheExpiredByModified($languageCode)) {
Expand All @@ -84,7 +84,7 @@ public function readContentCache(string $languageCode = null): ?array
);
}

public function readContent(string $languageCode = null): array
public function readContent(?string $languageCode = null): array
{
// read from boostedCache if exists
$data = option('bnomei.boost.read') === false || option('debug') ? null : $this->readContentCache($languageCode);
Expand All @@ -100,7 +100,7 @@ public function readContent(string $languageCode = null): array
return $data;
}

public function writeContentCache(array $data = null, string $languageCode = null): bool
public function writeContentCache(?array $data = null, ?string $languageCode = null): bool
{
$cache = BoostCache::singleton();
if (! $cache || option('bnomei.boost.write') === false) {
Expand Down Expand Up @@ -129,7 +129,7 @@ public function writeContentCache(array $data = null, string $languageCode = nul
);
}

public function writeContent(array $data, string $languageCode = null): bool
public function writeContent(array $data, ?string $languageCode = null): bool
{
// write to file and cache
return parent::writeContent($data, $languageCode) &&
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
], __DIR__);

if (! function_exists('bolt')) {
function bolt(string $id, Page $parent = null, bool $cache = true, bool $extend = true)
function bolt(string $id, ?Page $parent = null, bool $cache = true, bool $extend = true)
{
$id = str_replace('page://', '', $id);
$cacheKey = 'page/'.Str::substr($id, 0, 2).'/'.Str::substr($id, 2);
Expand Down

0 comments on commit 7e567f4

Please sign in to comment.