Upgrade to 3.8.2
This commit is contained in:
@@ -383,7 +383,7 @@ class App
|
||||
*/
|
||||
public function collections()
|
||||
{
|
||||
return $this->collections = $this->collections ?? new Collections();
|
||||
return $this->collections ??= new Collections();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,7 +564,7 @@ class App
|
||||
*/
|
||||
public function defaultLanguage()
|
||||
{
|
||||
return $this->defaultLanguage = $this->defaultLanguage ?? $this->languages()->default();
|
||||
return $this->defaultLanguage ??= $this->languages()->default();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -928,11 +928,15 @@ class App
|
||||
return $this->defaultLanguage();
|
||||
}
|
||||
|
||||
// if requesting a non-default language,
|
||||
// find it but don't cache it
|
||||
if ($code !== null) {
|
||||
return $this->languages()->find($code);
|
||||
}
|
||||
|
||||
return $this->language = $this->language ?? $this->defaultLanguage();
|
||||
// otherwise return language set by `AppTranslation::setCurrentLanguage`
|
||||
// or default language
|
||||
return $this->language ??= $this->defaultLanguage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1025,7 +1029,7 @@ class App
|
||||
*/
|
||||
public function nonce(): string
|
||||
{
|
||||
return $this->nonce = $this->nonce ?? base64_encode(random_bytes(20));
|
||||
return $this->nonce ??= base64_encode(random_bytes(20));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1345,7 +1349,7 @@ class App
|
||||
*/
|
||||
public function response()
|
||||
{
|
||||
return $this->response = $this->response ?? new Responder();
|
||||
return $this->response ??= new Responder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1355,7 +1359,7 @@ class App
|
||||
*/
|
||||
public function roles()
|
||||
{
|
||||
return $this->roles = $this->roles ?? Roles::load($this->root('roles'));
|
||||
return $this->roles ??= Roles::load($this->root('roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1578,7 +1582,7 @@ class App
|
||||
*/
|
||||
public function site()
|
||||
{
|
||||
return $this->site = $this->site ?? new Site([
|
||||
return $this->site ??= new Site([
|
||||
'errorPageId' => $this->options['error'] ?? 'error',
|
||||
'homePageId' => $this->options['home'] ?? 'home',
|
||||
'kirby' => $this,
|
||||
@@ -1647,7 +1651,7 @@ class App
|
||||
*/
|
||||
public function system()
|
||||
{
|
||||
return $this->system = $this->system ?? new System($this);
|
||||
return $this->system ??= new System($this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1771,7 +1775,7 @@ class App
|
||||
public static function version(): string|null
|
||||
{
|
||||
try {
|
||||
return static::$version = static::$version ?? Data::read(dirname(__DIR__, 2) . '/composer.json')['version'] ?? null;
|
||||
return static::$version ??= Data::read(dirname(__DIR__, 2) . '/composer.json')['version'] ?? null;
|
||||
} catch (Throwable) {
|
||||
throw new LogicException('The Kirby version cannot be detected. The composer.json is probably missing or not readable.');
|
||||
}
|
||||
@@ -1794,6 +1798,6 @@ class App
|
||||
*/
|
||||
public function visitor()
|
||||
{
|
||||
return $this->visitor = $this->visitor ?? new Visitor();
|
||||
return $this->visitor ??= new Visitor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,10 +140,7 @@ trait AppPlugins
|
||||
protected function extendAreas(array $areas): array
|
||||
{
|
||||
foreach ($areas as $id => $area) {
|
||||
if (isset($this->extensions['areas'][$id]) === false) {
|
||||
$this->extensions['areas'][$id] = [];
|
||||
}
|
||||
|
||||
$this->extensions['areas'][$id] ??= [];
|
||||
$this->extensions['areas'][$id][] = $area;
|
||||
}
|
||||
|
||||
@@ -388,9 +385,7 @@ trait AppPlugins
|
||||
protected function extendHooks(array $hooks): array
|
||||
{
|
||||
foreach ($hooks as $name => $callbacks) {
|
||||
if (isset($this->extensions['hooks'][$name]) === false) {
|
||||
$this->extensions['hooks'][$name] = [];
|
||||
}
|
||||
$this->extensions['hooks'][$name] ??= [];
|
||||
|
||||
if (is_array($callbacks) === false) {
|
||||
$callbacks = [$callbacks];
|
||||
|
||||
@@ -31,7 +31,7 @@ trait AppUsers
|
||||
*/
|
||||
public function auth()
|
||||
{
|
||||
return $this->auth = $this->auth ?? new Auth($this);
|
||||
return $this->auth ??= new Auth($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,9 +63,7 @@ class Collections
|
||||
public function get(string $name, array $data = [])
|
||||
{
|
||||
// if not yet loaded
|
||||
if (isset($this->collections[$name]) === false) {
|
||||
$this->collections[$name] = $this->load($name);
|
||||
}
|
||||
$this->collections[$name] ??= $this->load($name);
|
||||
|
||||
// if not yet cached
|
||||
if (
|
||||
|
||||
@@ -164,13 +164,11 @@ class Content
|
||||
|
||||
$key = strtolower($key);
|
||||
|
||||
if (isset($this->fields[$key])) {
|
||||
return $this->fields[$key];
|
||||
}
|
||||
|
||||
$value = $this->data()[$key] ?? null;
|
||||
|
||||
return $this->fields[$key] = new Field($this->parent, $key, $value);
|
||||
return $this->fields[$key] ??= new Field(
|
||||
$this->parent,
|
||||
$key,
|
||||
$this->data()[$key] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,26 +84,17 @@ class ContentTranslation
|
||||
*/
|
||||
public function content(): array
|
||||
{
|
||||
$parent = $this->parent();
|
||||
|
||||
if ($this->content === null) {
|
||||
$this->content = $parent->readContent($this->code());
|
||||
}
|
||||
|
||||
$content = $this->content;
|
||||
$parent = $this->parent();
|
||||
$content = $this->content ??= $parent->readContent($this->code());
|
||||
|
||||
// merge with the default content
|
||||
if (
|
||||
$this->isDefault() === false &&
|
||||
$defaultLanguage = $parent->kirby()->defaultLanguage()
|
||||
) {
|
||||
$default = [];
|
||||
|
||||
if ($defaultTranslation = $parent->translation($defaultLanguage->code())) {
|
||||
$default = $defaultTranslation->content();
|
||||
if ($default = $parent->translation($defaultLanguage->code())?->content()) {
|
||||
$content = array_merge($default, $content);
|
||||
}
|
||||
|
||||
$content = array_merge($default, $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
@@ -49,14 +49,10 @@ class Email
|
||||
$this->props = array_merge($preset, $props);
|
||||
|
||||
// add transport settings
|
||||
if (isset($this->props['transport']) === false) {
|
||||
$this->props['transport'] = $this->options['transport'] ?? [];
|
||||
}
|
||||
$this->props['transport'] ??= $this->options['transport'] ?? [];
|
||||
|
||||
// add predefined beforeSend option
|
||||
if (isset($this->props['beforeSend']) === false) {
|
||||
$this->props['beforeSend'] = $this->options['beforeSend'] ?? null;
|
||||
}
|
||||
$this->props['beforeSend'] ??= $this->options['beforeSend'] ?? null;
|
||||
|
||||
// transform model objects to values
|
||||
$this->transformUserSingle('from', 'fromName');
|
||||
@@ -235,12 +231,7 @@ class Email
|
||||
$this->props[$addressProp] = $address;
|
||||
|
||||
// only use the name from the user if no custom name was set
|
||||
if (
|
||||
isset($this->props[$nameProp]) === false ||
|
||||
$this->props[$nameProp] === null
|
||||
) {
|
||||
$this->props[$nameProp] = $name;
|
||||
}
|
||||
$this->props[$nameProp] ??= $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -295,11 +295,7 @@ class File extends ModelWithContent
|
||||
|
||||
$template = $this->template();
|
||||
|
||||
if (isset($readable[$template]) === true) {
|
||||
return $readable[$template];
|
||||
}
|
||||
|
||||
return $readable[$template] = $this->permissions()->can('read');
|
||||
return $readable[$template] ??= $this->permissions()->can('read');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -777,11 +777,7 @@ class Page extends ModelWithContent
|
||||
|
||||
$template = $this->intendedTemplate()->name();
|
||||
|
||||
if (isset($readable[$template]) === true) {
|
||||
return $readable[$template];
|
||||
}
|
||||
|
||||
return $readable[$template] = $this->permissions()->can('read');
|
||||
return $readable[$template] ??= $this->permissions()->can('read');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,55 @@ use Kirby\Uuid\Uuids;
|
||||
*/
|
||||
trait PageActions
|
||||
{
|
||||
/**
|
||||
* Adapts necessary modifications which page uuid, page slug and files uuid
|
||||
* of copy objects for single or multilang environments
|
||||
*/
|
||||
protected function adaptCopy(Page $copy, bool $files = false): Page
|
||||
{
|
||||
if ($this->kirby()->multilang() === true) {
|
||||
foreach ($this->kirby()->languages() as $language) {
|
||||
// overwrite with new UUID for the page and files
|
||||
// for default language (remove old, add new)
|
||||
if (
|
||||
Uuids::enabled() === true &&
|
||||
$language->isDefault() === true
|
||||
) {
|
||||
$copy = $copy->save(['uuid' => Uuid::generate()], $language->code());
|
||||
|
||||
if ($files !== false) {
|
||||
foreach ($copy->files() as $file) {
|
||||
$file->save(['uuid' => Uuid::generate()], $language->code());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove all translated slugs
|
||||
if (
|
||||
$language->isDefault() === false &&
|
||||
$copy->translation($language)->exists() === true
|
||||
) {
|
||||
$copy = $copy->save(['slug' => null], $language->code());
|
||||
}
|
||||
}
|
||||
|
||||
return $copy;
|
||||
}
|
||||
|
||||
// overwrite with new UUID for the page and files (remove old, add new)
|
||||
if (Uuids::enabled() === true) {
|
||||
$copy = $copy->save(['uuid' => Uuid::generate()]);
|
||||
|
||||
if ($files !== false) {
|
||||
foreach ($copy->files() as $file) {
|
||||
$file->save(['uuid' => Uuid::generate()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the sorting number.
|
||||
* The sorting number must already be correct
|
||||
@@ -434,19 +483,8 @@ trait PageActions
|
||||
|
||||
$copy = $parentModel->clone()->findPageOrDraft($slug);
|
||||
|
||||
// remove all translated slugs
|
||||
if ($this->kirby()->multilang() === true) {
|
||||
foreach ($this->kirby()->languages() as $language) {
|
||||
if ($language->isDefault() === false && $copy->translation($language)->exists() === true) {
|
||||
$copy = $copy->save(['slug' => null], $language->code());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// overwrite with new UUID (remove old, add new)
|
||||
if (Uuids::enabled() === true) {
|
||||
$copy = $copy->save(['uuid' => Uuid::generate()]);
|
||||
}
|
||||
// normalize copy object
|
||||
$copy = $this->adaptCopy($copy, $files);
|
||||
|
||||
// add copy to siblings
|
||||
static::updateParentCollections($copy, 'append', $parentModel);
|
||||
@@ -776,9 +814,9 @@ trait PageActions
|
||||
foreach ($sorted as $key => $id) {
|
||||
if ($id === $this->id()) {
|
||||
continue;
|
||||
} elseif ($sibling = $siblings->get($id)) {
|
||||
$sibling->changeNum($key + 1);
|
||||
}
|
||||
|
||||
$siblings->get($id)?->changeNum($key + 1);
|
||||
}
|
||||
|
||||
$parent = $this->parentModel();
|
||||
|
||||
@@ -79,11 +79,7 @@ class PageBlueprint extends Blueprint
|
||||
'sort' => 'default',
|
||||
];
|
||||
|
||||
if (isset($aliases[$num]) === true) {
|
||||
return $aliases[$num];
|
||||
}
|
||||
|
||||
return $num;
|
||||
return $aliases[$num] ?? $num;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,9 +140,7 @@ class PageBlueprint extends Blueprint
|
||||
}
|
||||
|
||||
// also make sure to have the text field set
|
||||
if (isset($status[$key]['text']) === false) {
|
||||
$status[$key]['text'] = null;
|
||||
}
|
||||
$status[$key]['text'] ??= null;
|
||||
|
||||
// translate text and label if necessary
|
||||
$status[$key]['label'] = $this->i18n($status[$key]['label'], $status[$key]['label']);
|
||||
|
||||
Reference in New Issue
Block a user