Update to Kirby 3.7.5

This commit is contained in:
Nico Hoffmann
2022-08-30 20:43:20 +02:00
parent d89a0a647c
commit 26541380c4
45 changed files with 191 additions and 199 deletions

View File

@@ -75,24 +75,24 @@ class FileCache extends Cache
$keyParts = [];
foreach (preg_split('#([\/\\\\])#', $key, 0, PREG_SPLIT_DELIM_CAPTURE) as $part) {
switch ($part) {
// forward slashes don't need special treatment
case '/':
// forward slashes don't need special treatment
break;
// backslashes get their own marker in the path
// to differentiate the cache key from one with forward slashes
case '\\':
// backslashes get their own marker in the path
// to differentiate the cache key from one with forward slashes
$keyParts[] = '_backslash';
break;
// empty part means two slashes in a row;
// special marker like for backslashes
case '':
// empty part means two slashes in a row;
// special marker like for backslashes
$keyParts[] = '_empty';
break;
// an actual path segment
default:
// an actual path segment:
// check if the segment only contains safe characters;
// underscores are *not* safe to guarantee uniqueness
// as they are used in the special cases

View File

@@ -461,7 +461,6 @@ class App
}
if ($contentType !== 'html') {
// no luck for a specific representation controller?
// let's try the html controller instead
if ($controller = $this->controllerLookup($name)) {

View File

@@ -506,7 +506,6 @@ class Blueprint
}
foreach ($fields as $fieldName => $fieldProps) {
// extend field from string
if (is_string($fieldProps) === true) {
$fieldProps = [
@@ -600,7 +599,6 @@ class Blueprint
protected function normalizeSections(string $tabName, array $sections): array
{
foreach ($sections as $sectionName => $sectionProps) {
// unset / remove section if its property is false
if ($sectionProps === false) {
unset($sections[$sectionName]);
@@ -686,7 +684,6 @@ class Blueprint
}
foreach ($tabs as $tabName => $tabProps) {
// unset / remove tab if its property is false
if ($tabProps === false) {
unset($tabs[$tabName]);

View File

@@ -106,7 +106,6 @@ class Email
protected function template(): void
{
if (isset($this->props['template']) === true) {
// prepare data to be passed to template
$data = $this->props['data'] ?? [];
@@ -123,7 +122,7 @@ class Email
$this->props['body']['text'] = $text->render($data);
}
// fallback to single email text template
// fallback to single email text template
} elseif ($text->exists()) {
$this->props['body'] = $text->render($data);
} else {

View File

@@ -194,7 +194,6 @@ trait FileActions
// run the hook
return $file->commit('create', compact('file', 'upload'), function ($file, $upload) {
// delete all public versions
$file->unpublish();
@@ -230,7 +229,6 @@ trait FileActions
public function delete(): bool
{
return $this->commit('delete', ['file' => $this], function ($file) {
// remove all versions in the media folder
$file->unpublish();
@@ -289,7 +287,6 @@ trait FileActions
];
return $this->commit('replace', $arguments, function ($file, $upload) {
// delete all public versions
$file->unpublish();

View File

@@ -60,7 +60,6 @@ class LanguageRouter
// only keep the scoped language routes
$routes = array_values(array_filter($routes, function ($route) use ($language) {
// no language scope
if (empty($route['language']) === true) {
return false;
@@ -82,7 +81,6 @@ class LanguageRouter
foreach ($routes as $index => $route) {
if ($pageId = ($route['page'] ?? null)) {
if ($page = $kirby->page($pageId)) {
// convert string patterns to arrays
$patterns = A::wrap($route['pattern']);

View File

@@ -23,7 +23,6 @@ class LanguageRoutes
$baseurl = $kirby->url();
foreach ($kirby->languages() as $language) {
// ignore languages with a different base url
if ($language->baseurl() !== $baseurl) {
continue;
@@ -66,7 +65,6 @@ class LanguageRoutes
'method' => 'ALL',
'env' => 'site',
'action' => function (string $path) use ($kirby) {
// check for content representations or files
$extension = F::extension($path);
@@ -115,7 +113,6 @@ class LanguageRoutes
'method' => 'ALL',
'env' => 'site',
'action' => function () use ($kirby) {
// find all languages with the same base url as the current installation
$languages = $kirby->languages()->filter('baseurl', $kirby->url());

View File

@@ -41,7 +41,6 @@ class Media
// try to find a file by model and filename
// this should work for all original files
if ($file = $model->file($filename)) {
// check if the request contained an outdated media hash
if ($file->mediaHash() !== $hash) {
// if at least the token was correct, redirect

View File

@@ -83,7 +83,6 @@ abstract class ModelWithContent extends Model
*/
public function content(string $languageCode = null)
{
// single language support
if ($this->kirby()->multilang() === false) {
if (is_a($this->content, 'Kirby\Cms\Content') === true) {
@@ -95,7 +94,6 @@ abstract class ModelWithContent extends Model
// multi language support
} else {
// only fetch from cache for the default language
if ($languageCode === null && is_a($this->content, 'Kirby\Cms\Content') === true) {
return $this->content;

View File

@@ -478,7 +478,6 @@ trait PageActions
// run the hooks and creation action
$page = $page->commit('create', ['page' => $page, 'input' => $props], function ($page, $props) {
// always create pages in the default language
if ($page->kirby()->multilang() === true) {
$languageCode = $page->kirby()->defaultLanguage()->code();
@@ -594,7 +593,6 @@ trait PageActions
public function delete(bool $force = false): bool
{
return $this->commit('delete', ['page' => $this, 'force' => $force], function ($page, $force) {
// delete all files individually
foreach ($page->files() as $file) {
$file->delete();
@@ -607,7 +605,6 @@ trait PageActions
// actually remove the page from disc
if ($page->exists() === true) {
// delete all public media files
Dir::remove($page->mediaRoot());

View File

@@ -119,7 +119,6 @@ class PageBlueprint extends Blueprint
// clean up and translate each status
foreach ($status as $key => $options) {
// skip invalid status definitions
if (in_array($key, ['draft', 'listed', 'unlisted']) === false || $options === false) {
unset($status[$key]);

View File

@@ -648,7 +648,6 @@ class User extends ModelWithContent
// if there's an authenticated user …
if ($user = $kirby->user()) {
// admin users can select pretty much any role
if ($user->isAdmin() === true) {
// except if the user is the last admin

View File

@@ -380,7 +380,6 @@ class Database
// store the final sql to add it to the trace later
$this->lastQuery = $this->statement->queryString;
} catch (Throwable $e) {
// store the error
$this->affected = 0;
$this->lastError = $e;

View File

@@ -407,7 +407,7 @@ class Query
$mode = A::last($args);
// if there's a where clause mode attribute attached…
if (in_array($mode, ['AND', 'OR']) === true) {
if (in_array($mode, ['AND', 'OR'], true) === true) {
// remove that from the list of arguments
array_pop($args);
}
@@ -431,7 +431,7 @@ class Query
$mode = A::last($args);
// if there's a where clause mode attribute attached…
if (in_array($mode, ['AND', 'OR']) === true) {
if (in_array($mode, ['AND', 'OR'], true) === true) {
// remove that from the list of arguments
array_pop($args);
}
@@ -941,7 +941,7 @@ class Query
$result = '';
// if there's a where clause mode attribute attached…
if (in_array($mode, ['AND', 'OR'])) {
if (in_array($mode, ['AND', 'OR'], true) === true) {
// remove that from the list of arguments
array_pop($args);
} else {
@@ -956,14 +956,12 @@ class Query
// ->where('username like "myuser"');
} elseif (is_string($args[0]) === true) {
// simply add the entire string to the where clause
// escaping or using bindings has to be done before calling this method
$result = $args[0];
// ->where(['username' => 'myuser']);
} elseif (is_array($args[0]) === true) {
// simple array mode (AND operator)
$sql = $this->database->sql()->values($this->table, $args[0], ' AND ', true, true);
@@ -990,7 +988,6 @@ class Query
// ->where('username like :username', ['username' => 'myuser'])
if (is_string($args[0]) === true && is_array($args[1]) === true) {
// prepared where clause
$result = $args[0];
@@ -999,7 +996,6 @@ class Query
// ->where('username like ?', 'myuser')
} elseif (is_string($args[0]) === true && is_string($args[1]) === true) {
// prepared where clause
$result = $args[0];
@@ -1012,7 +1008,6 @@ class Query
// ->where('username', 'like', 'myuser');
if (is_string($args[0]) === true && is_string($args[1]) === true) {
// validate column
$sql = $this->database->sql();
$key = $sql->columnName($this->table, $args[0]);
@@ -1061,7 +1056,6 @@ class Query
}
break;
}
// attach the where clause

View File

@@ -672,7 +672,6 @@ abstract class Sql
// array of columns
if (is_array($columns) === true) {
// validate columns
$result = [];
@@ -704,16 +703,16 @@ abstract class Sql
$parts = preg_split('/(?:`[^`]*`|"[^"]*")(*SKIP)(*F)|\./', $identifier);
switch (count($parts)) {
// non-qualified identifier
case 1:
// non-qualified identifier
return [$table, $this->unquoteIdentifier($parts[0])];
// qualified identifier
case 2:
// qualified identifier
return [$this->unquoteIdentifier($parts[0]), $this->unquoteIdentifier($parts[1])];
// every other number is an error
default:
// every other number is an error
throw new InvalidArgumentException('Invalid identifier ' . $identifier);
}
}

View File

@@ -239,7 +239,6 @@ class Dir
natsort($items);
foreach ($items as $item) {
// ignore all items with a leading dot
if (in_array(substr($item, 0, 1), ['.', '_']) === true) {
continue;
@@ -248,7 +247,6 @@ class Dir
$root = $dir . '/' . $item;
if (is_dir($root) === true) {
// extract the slug and num of the directory
if (preg_match('/^([0-9]+)' . static::$numSeparator . '(.*)$/', $item, $match)) {
$num = (int)$match[1];
@@ -313,7 +311,6 @@ class Dir
*/
protected static function inventoryContent(array $inventory, array $content): array
{
// filter meta files from the content file
if (empty($content) === true) {
$inventory['template'] = 'default';
@@ -321,7 +318,6 @@ class Dir
}
foreach ($content as $contentName) {
// could be a meta file. i.e. cover.jpg
if (isset($inventory['files'][$contentName]) === true) {
continue;

View File

@@ -73,7 +73,6 @@ class Form
$this->values = [];
foreach ($fields as $name => $props) {
// inject stuff from the form constructor (model, etc.)
$props = array_merge($inject, $props);
@@ -104,7 +103,6 @@ class Form
}
if ($strict !== true) {
// use all given values, no matter
// if there's a field or not.
$input = array_merge($values, $input);

View File

@@ -314,7 +314,6 @@ class Panel
// create a micro-router for the Panel
return Router::execute($path, $method = $kirby->request()->method(), $routes, function ($route) use ($areas, $kirby, $method, $path) {
// route needs authentication?
$auth = $route->attributes()['auth'] ?? true;
$areaId = $route->attributes()['area'] ?? null;
@@ -416,7 +415,6 @@ class Panel
$routes = [];
foreach ($dialogs as $key => $dialog) {
// create the full pattern with dialogs prefix
$pattern = 'dialogs/' . trim(($dialog['pattern'] ?? $key), '/');
@@ -492,7 +490,6 @@ class Panel
$routes = [];
foreach ($searches as $name => $params) {
// create the full routing pattern
$pattern = 'search/' . $name;

View File

@@ -420,7 +420,6 @@ class View
// if requested, send $fiber data as JSON
if (Panel::isFiberRequest() === true) {
// filter data, if only or globals headers or
// query parameters are set
$fiber = static::apply($fiber);

View File

@@ -177,7 +177,6 @@ class A
}
foreach ($array2 as $key => $value) {
// append to the merged array, don't overwrite numeric keys
if (is_int($key) === true && $mode === static::MERGE_APPEND) {
$merged[] = $value;

View File

@@ -525,7 +525,6 @@ class Collection extends Iterator implements Countable
*/
public function group($field, bool $i = true)
{
// group by field name
if (is_string($field) === true) {
return $this->group(function ($item) use ($field, $i) {
@@ -541,7 +540,6 @@ class Collection extends Iterator implements Countable
$groups = [];
foreach ($this->data as $key => $item) {
// get the value to group by
$value = $field($item);
@@ -1005,7 +1003,6 @@ class Collection extends Iterator implements Countable
$fields = [];
foreach ($args as $arg) {
// get the index of the latest field array inside the $fields array
$currentField = $fields ? count($fields) - 1 : 0;

View File

@@ -585,17 +585,17 @@ class Html extends Xml
};
switch ($path->toString()) {
// playlists
case 'embed/videoseries':
case 'playlist':
// playlists
if ($isYoutubeId($query->list) === true) {
$src = $host . '/videoseries';
}
break;
// regular video URLs
case 'watch':
// regular video URLs
if ($isYoutubeId($query->v) === true) {
$src = $host . '/' . $query->v;

View File

@@ -81,7 +81,6 @@ class Pagination
*/
return $a;
} elseif (is_array($a) === true) {
/**
* First argument is an option array
*
@@ -89,7 +88,6 @@ class Pagination
*/
$params = $a;
} elseif (is_int($a) === true && $b === null) {
/**
* First argument is the limit
*
@@ -97,7 +95,6 @@ class Pagination
*/
$params['limit'] = $a;
} elseif (is_int($a) === true && is_int($b) === true) {
/**
* First argument is the limit,
* second argument is the page
@@ -107,7 +104,6 @@ class Pagination
$params['limit'] = $a;
$params['page'] = $b;
} elseif (is_int($a) === true && is_array($b) === true) {
/**
* First argument is the limit,
* second argument are options

View File

@@ -122,7 +122,6 @@ trait Properties
// handle empty values
if ($value === null) {
// replace null with a default value, if a default handler exists
if (method_exists($this, 'default' . $name) === true) {
$value = $this->{'default' . $name}();

View File

@@ -846,11 +846,9 @@ class Str
if (is_int($replacement['limit']) === false) {
throw new Exception('Invalid limit "' . $replacement['limit'] . '".');
} elseif ($replacement['limit'] === -1) {
// no limit, we don't need our special replacement routine
$string = str_replace($replacement['search'], $replacement['replace'], $string);
} elseif ($replacement['limit'] > 0) {
// limit given, only replace for $replacement['limit'] times per replacement
$position = -1;