-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into WS-447-confirm-leave
- Loading branch information
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
diff --git a/core/modules/file/file.module b/core/modules/file/file.module | ||
index 6fcfa8c789..e80041cd22 100644 | ||
--- a/core/modules/file/file.module | ||
+++ b/core/modules/file/file.module | ||
@@ -532,8 +532,9 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st | ||
$upload_location = $element['#upload_location'] ?? FALSE; | ||
$upload_name = implode('_', $element['#parents']); | ||
$upload_validators = $element['#upload_validators'] ?? []; | ||
+ $file_type = $element['#file_type'] ?? FALSE; | ||
|
||
- $result = file_save_upload($upload_name, $upload_validators, $upload_location, $delta, $fileExists); | ||
+ $result = file_save_upload($upload_name, $upload_validators, $upload_location, $delta, $fileExists, $file_type); | ||
|
||
// Get new errors that are generated while trying to save the upload. This | ||
// will also clear them from the messenger service. | ||
@@ -614,7 +615,7 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st | ||
* | ||
* @see _file_save_upload_from_form() | ||
*/ | ||
-function file_save_upload($form_field_name, $validators = [], $destination = FALSE, $delta = NULL, FileExists|int $fileExists = FileExists::Rename) { | ||
+function file_save_upload($form_field_name, $validators = [], $destination = FALSE, $delta = NULL, FileExists|int $fileExists = FileExists::Rename, $file_type = FALSE) { | ||
if (!$fileExists instanceof FileExists) { | ||
// @phpstan-ignore-next-line | ||
$fileExists = FileExists::fromLegacyInt($fileExists, __METHOD__); | ||
@@ -657,7 +658,7 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL | ||
foreach ($uploaded_files as $i => $uploaded_file) { | ||
try { | ||
$form_uploaded_file = new FormUploadedFile($uploaded_file); | ||
- $result = $file_upload_handler->handleFileUpload($form_uploaded_file, $validators, $destination, $fileExists, FALSE); | ||
+ $result = $file_upload_handler->handleFileUpload($form_uploaded_file, $validators, $destination, $fileExists, FALSE, $file_type); | ||
if ($result->hasViolations()) { | ||
$errors = []; | ||
foreach ($result->getViolations() as $violation) { | ||
diff --git a/core/modules/file/src/Upload/FileUploadHandler.php b/core/modules/file/src/Upload/FileUploadHandler.php | ||
index 9f3661871f..cc011f399a 100644 | ||
--- a/core/modules/file/src/Upload/FileUploadHandler.php | ||
+++ b/core/modules/file/src/Upload/FileUploadHandler.php | ||
@@ -174,7 +174,7 @@ public function __construct( | ||
* @throws \ValueError | ||
* Thrown if $fileExists is a legacy int and not a valid value. | ||
*/ | ||
- public function handleFileUpload(UploadedFileInterface $uploadedFile, array $validators = [], string $destination = 'temporary://', /*FileExists*/$fileExists = FileExists::Replace, bool $throw = TRUE): FileUploadResult { | ||
+ public function handleFileUpload(UploadedFileInterface $uploadedFile, array $validators = [], string $destination = 'temporary://', /*FileExists*/$fileExists = FileExists::Replace, bool $throw = TRUE, $file_type = FALSE): FileUploadResult { | ||
if (!$fileExists instanceof FileExists) { | ||
// @phpstan-ignore-next-line | ||
$fileExists = FileExists::fromLegacyInt($fileExists, __METHOD__); | ||
@@ -267,11 +267,16 @@ public function handleFileUpload(UploadedFileInterface $uploadedFile, array $val | ||
); | ||
} | ||
|
||
- $file = File::create([ | ||
+ $file_values = [ | ||
'uid' => $this->currentUser->id(), | ||
'status' => 0, | ||
'uri' => $uploadedFile->getRealPath(), | ||
- ]); | ||
+ ]; | ||
+ if ($file_type) { | ||
+ $file_values['type'] = $file_type; | ||
+ } | ||
+ | ||
+ $file = File::create($file_values); | ||
|
||
// This will be replaced later with a filename based on the destination. | ||
$file->setFilename($filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
diff --git a/core/modules/action/action.module b/core/modules/action/action.module | ||
index 0e4229debc..f3ac61db22 100644 | ||
--- a/core/modules/action/action.module | ||
+++ b/core/modules/action/action.module | ||
@@ -61,12 +61,16 @@ function action_migration_plugins_alter(array &$migrations) { | ||
foreach ($migrations as $migration_id => $migration) { | ||
// Add Actions plugins in actions module. | ||
/** @var \Drupal\migrate\Plugin\migrate\source\SqlBase $source_plugin */ | ||
- $source_plugin = \Drupal::service('plugin.manager.migration') | ||
- ->createStubMigration($migration) | ||
- ->getSourcePlugin(); | ||
- if (is_a($source_plugin, Action::class) && isset($migration['process']['plugin'])) { | ||
- $migrations[$migration_id]['process']['plugin'][0]['map']['comment_unpublish_by_keyword_action'] = 'comment_unpublish_by_keyword_action'; | ||
- $migrations[$migration_id]['process']['plugin'][0]['map']['node_unpublish_by_keyword_action'] = 'node_unpublish_by_keyword_action'; | ||
+ try { | ||
+ $source_plugin = \Drupal::service('plugin.manager.migration') | ||
+ ->createStubMigration($migration) | ||
+ ->getSourcePlugin(); | ||
+ if (is_a($source_plugin, Action::class) && isset($migration['process']['plugin'])) { | ||
+ $migrations[$migration_id]['process']['plugin'][0]['map']['comment_unpublish_by_keyword_action'] = 'comment_unpublish_by_keyword_action'; | ||
+ $migrations[$migration_id]['process']['plugin'][0]['map']['node_unpublish_by_keyword_action'] = 'node_unpublish_by_keyword_action'; | ||
+ } | ||
+ } catch (Exception $e) { | ||
+ // Do nothing. This hack added to allow the XML upload to work. | ||
} | ||
} | ||
} |