Upgrade to 3.5.5
This commit is contained in:
@@ -254,12 +254,6 @@ class PageRules
|
||||
*/
|
||||
public static function changeTitle(Page $page, string $title): bool
|
||||
{
|
||||
if (Str::length($title) === 0) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.changeTitle.empty',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($page->permissions()->changeTitle() !== true) {
|
||||
throw new PermissionException([
|
||||
'key' => 'page.changeTitle.permission',
|
||||
@@ -269,6 +263,12 @@ class PageRules
|
||||
]);
|
||||
}
|
||||
|
||||
if (Str::length($title) === 0) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.changeTitle.empty',
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -283,9 +283,12 @@ class PageRules
|
||||
*/
|
||||
public static function create(Page $page): bool
|
||||
{
|
||||
if (Str::length($page->slug()) < 1) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.slug.invalid',
|
||||
if ($page->permissions()->create() !== true) {
|
||||
throw new PermissionException([
|
||||
'key' => 'page.create.permission',
|
||||
'data' => [
|
||||
'slug' => $page->slug()
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -300,15 +303,6 @@ class PageRules
|
||||
]);
|
||||
}
|
||||
|
||||
if ($page->permissions()->create() !== true) {
|
||||
throw new PermissionException([
|
||||
'key' => 'page.create.permission',
|
||||
'data' => [
|
||||
'slug' => $page->slug()
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
$siblings = $page->parentModel()->children();
|
||||
$drafts = $page->parentModel()->drafts();
|
||||
$slug = $page->slug();
|
||||
@@ -377,6 +371,8 @@ class PageRules
|
||||
]);
|
||||
}
|
||||
|
||||
self::validateSlugLength($slug);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -403,19 +399,27 @@ class PageRules
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the slug doesn't exceed the maximum length to make
|
||||
* sure that the directory name will be accepted by the filesystem
|
||||
* Ensures that the slug is not empty and doesn't exceed the maximum length
|
||||
* to make sure that the directory name will be accepted by the filesystem
|
||||
*
|
||||
* @param string $slug New slug to check
|
||||
* @return void
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the slug is too long
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the slug is empty or too long
|
||||
*/
|
||||
protected static function validateSlugLength(string $slug): void
|
||||
{
|
||||
$slugLength = Str::length($slug);
|
||||
|
||||
if ($slugLength === 0) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.slug.invalid',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($slugsMaxlength = App::instance()->option('slugs.maxlength', 255)) {
|
||||
$maxlength = (int)$slugsMaxlength;
|
||||
|
||||
if (Str::length($slug) > $maxlength) {
|
||||
if ($slugLength > $maxlength) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.slug.maxlength',
|
||||
'data' => [
|
||||
|
Reference in New Issue
Block a user