Fixed uploading media in non-existing object

This commit is contained in:
Matias Griese
2020-06-25 15:58:18 +03:00
parent fd52d124dd
commit b0a1effaf9

View File

@@ -64,7 +64,8 @@ trait MediaUploadTrait
}
// Destination is always needed (but it can be set in defaults).
if (!isset($settings['destination'])) {
$self = $settings['self'] ?? false;
if (!isset($settings['destination']) && $self === false) {
throw new RuntimeException($this->translate('PLUGIN_ADMIN.DESTINATION_NOT_SPECIFIED'), 400);
}
@@ -102,7 +103,7 @@ trait MediaUploadTrait
// Handle conflicting filename if needed.
if ($settings['avoid_overwriting']) {
$destination = $settings['destination'];
if (file_exists("{$destination}/{$filename}")) {
if ($destination && file_exists("{$destination}/{$filename}")) {
$filename = date('YmdHis') . '-' . $filename;
}
}