Upgrade to 3.4.4

This commit is contained in:
Bastian Allgeier
2020-10-06 10:23:02 +02:00
parent c091f04115
commit 0b80361a79
53 changed files with 976 additions and 83 deletions

View File

@@ -212,6 +212,53 @@ class Api extends BaseApi
]);
}
/**
* Returns the subpages for the given
* parent. The subpages can be filtered
* by status (draft, listed, unlisted, published, all)
*
* @param string|null $parentId
* @param string|null $status
* @return \Kirby\Cms\Pages
*/
public function pages(string $parentId = null, string $status = null)
{
$parent = $parentId === null ? $this->site() : $this->page($parentId);
switch ($status) {
case 'all':
return $parent->childrenAndDrafts();
case 'draft':
case 'drafts':
return $parent->drafts();
case 'listed':
return $parent->children()->listed();
case 'unlisted':
return $parent->children()->unlisted();
case 'published':
default:
return $parent->children();
}
}
/**
* Search for direct subpages of the
* given parent
*
* @param string|null $parent
* @return \Kirby\Cms\Pages
*/
public function searchPages(string $parent = null)
{
$pages = $this->pages($parent, $this->requestQuery('status'));
if ($this->requestMethod() === 'GET') {
return $pages->search($this->requestQuery('q'));
}
return $pages->query($this->requestBody());
}
/**
* Returns the current Session instance
*

View File

@@ -1079,10 +1079,15 @@ class App
// when the page has been found
if ($page) {
try {
return $this
->response()
->body($page->render([], $extension))
->type($extension);
$response = $this->response();
// attach a MIME type based on the representation
// only if no custom MIME type was set
if ($response->type() === null) {
$response->type($extension);
}
return $response->body($page->render([], $extension));
} catch (NotFoundException $e) {
return null;
}

View File

@@ -111,10 +111,14 @@ trait AppErrors
$httpCode = $exception->getHttpCode();
$code = $exception->getCode();
$details = $exception->getDetails();
} else {
} elseif (is_a($exception, '\Throwable') === true) {
$httpCode = 500;
$code = $exception->getCode();
$details = null;
} else {
$httpCode = 500;
$code = 500;
$details = null;
}
if ($this->option('debug') === true) {

View File

@@ -265,6 +265,8 @@ class Auth
// check for blocked ips
if ($this->isBlocked($email) === true) {
$this->kirby->trigger('user.login:failed', compact('email'));
if ($this->kirby->option('debug') === true) {
$message = 'Rate limit exceeded';
} else {
@@ -397,6 +399,8 @@ class Auth
*/
public function track(string $email): bool
{
$this->kirby->trigger('user.login:failed', compact('email'));
$ip = $this->ipHash();
$log = $this->log();
$time = time();

View File

@@ -245,6 +245,9 @@ trait FileActions
F::remove($file->root());
// remove the file from the sibling collection
$file->parent()->files()->remove($file);
return true;
});
}

View File

@@ -86,7 +86,7 @@ class Media
* given filename and then calls the thumb
* component to create a thumbnail accordingly
*
* @param \Kirby\Cms\Model $model
* @param \Kirby\Cms\Model|string $model
* @param string $hash
* @param string $filename
* @return \Kirby\Cms\Response|false
@@ -95,11 +95,14 @@ class Media
{
$kirby = App::instance();
// assets
if (is_string($model) === true) {
// assets
$root = $kirby->root('media') . '/assets/' . $model . '/' . $hash;
// parent files for file model that already included hash
} elseif (is_a($model, '\Kirby\Cms\File')) {
$root = dirname($model->mediaRoot());
// model files
} else {
// model files
$root = $model->mediaRoot() . '/' . $hash;
}

View File

@@ -8,7 +8,6 @@ use Kirby\Exception\NotFoundException;
use Kirby\Http\Uri;
use Kirby\Toolkit\A;
use Kirby\Toolkit\F;
use Kirby\Toolkit\Str;
/**
* The `$page` object is the heart and
@@ -964,11 +963,6 @@ class Page extends ModelWithContent
{
if ($icon = $this->blueprint()->icon()) {
$params['type'] = $icon;
// check for emojis
if (strlen($icon) !== Str::length($icon)) {
$params['emoji'] = true;
}
}
return parent::panelIcon($params);

View File

@@ -27,11 +27,6 @@ class User extends ModelWithContent
use HasSiblings;
use UserActions;
/**
* @var File
*/
protected $avatar;
/**
* @var UserBlueprint
*/
@@ -798,7 +793,7 @@ class User extends ModelWithContent
*/
protected function setName(string $name = null)
{
$this->name = $name !== null ? trim($name) : null;
$this->name = $name !== null ? trim(strip_tags($name)) : null;
return $this;
}

View File

@@ -50,7 +50,7 @@ class UserPermissions extends ModelPermissions
}
// users who are not admins cannot create admins
if ($this->model->isAdmin() === true) {
if ($this->model->isAdmin() === false) {
return false;
}