Upgrade to 3.6.5

This commit is contained in:
Bastian Allgeier
2022-04-19 14:59:34 +02:00
parent fee3f5253d
commit 5c64df9e2b
30 changed files with 266 additions and 279 deletions

View File

@@ -10,6 +10,7 @@ use Kirby\Exception\NotFoundException;
use Kirby\Filesystem\Dir;
use Kirby\Filesystem\F;
use Kirby\Http\Request;
use Kirby\Http\Response;
use Kirby\Http\Router;
use Kirby\Http\Server;
use Kirby\Http\Uri;
@@ -709,14 +710,25 @@ class App
return $this->io(new NotFoundException());
}
// Response Configuration
// (Modified) global response configuration, e.g. in routes
if (is_a($input, 'Kirby\Cms\Responder') === true) {
// return the passed object unmodified (without injecting headers
// from the global object) to allow a complete response override
// https://github.com/getkirby/kirby/pull/4144#issuecomment-1034766726
return $input->send();
}
// Responses
if (is_a($input, 'Kirby\Http\Response') === true) {
return $input;
$data = $input->toArray();
// inject headers from the global response configuration
// lazily (only if they are not already set);
// the case-insensitive nature of headers will be
// handled by PHP's `header()` function
$data['headers'] = array_merge($response->headers(), $data['headers']);
return new Response($data);
}
// Pages

View File

@@ -353,12 +353,12 @@ class File extends ModelWithContent
/**
* Get the file's last modification time.
*
* @param string|null $format
* @param string|null $handler date or strftime
* @param string|\IntlDateFormatter|null $format
* @param string|null $handler date, intl or strftime
* @param string|null $languageCode
* @return mixed
*/
public function modified(string $format = null, string $handler = null, string $languageCode = null)
public function modified($format = null, string $handler = null, string $languageCode = null)
{
$file = $this->modifiedFile();
$content = $this->modifiedContent($languageCode);

View File

@@ -80,15 +80,30 @@ class FileRules
*/
public static function create(File $file, BaseFile $upload): bool
{
// We want to ensure that we are not creating duplicate files.
// If a file with the same name already exists
if ($file->exists() === true) {
if ($file->sha1() !== $upload->sha1()) {
throw new DuplicateException([
'key' => 'file.duplicate',
'data' => [
'filename' => $file->filename()
]
]);
// $file will be based on the props of the new file,
// to compare templates, we need to get the props of
// the already existing file from meta content file
$existing = $file->parent()->file($file->filename());
// if the new upload is the exact same file
// and uses the same template, we can continue
if (
$file->sha1() === $upload->sha1() &&
$file->template() === $existing->template()
) {
return true;
}
// otherwise throw an error for duplicate file
throw new DuplicateException([
'key' => 'file.duplicate',
'data' => [
'filename' => $file->filename()
]
]);
}
if ($file->permissions()->create() !== true) {