diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php index f246cce462..148f60408c 100644 --- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php @@ -49,6 +49,15 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = if ($requested_format = $this->getContentType($request)) { $request->setRequestFormat($requested_format); } + // Adding some logging around the file upload. + if ($files = $request->files->get('files')) { + \Drupal::logger('file')->notice('NegotiationMiddleware::handle request file:'); + \Drupal::logger('file')->notice(json_encode((array) $files['upload'][0])); + } + else { + \Drupal::logger('file')->notice('NegotiationMiddleware::handle request file empty'); + } + return $this->app->handle($request, $type, $catch); } diff --git a/core/modules/media_library/src/Form/FileUploadForm.php b/core/modules/media_library/src/Form/FileUploadForm.php index 64a19d4e24..d3576392f1 100644 --- a/core/modules/media_library/src/Form/FileUploadForm.php +++ b/core/modules/media_library/src/Form/FileUploadForm.php @@ -141,6 +141,7 @@ protected function buildInputElement(array $form, FormStateInterface $form_state } $slots = $state->getAvailableSlots(); + \Drupal::logger('file')->notice('slots: '. $slots); // Add a container to group the input elements for styling purposes. $form['container'] = [ @@ -162,6 +163,7 @@ protected function buildInputElement(array $form, FormStateInterface $form_state '#remaining_slots' => $slots, ]; + $file_upload_help = [ '#theme' => 'file_upload_help', '#upload_validators' => $form['container']['upload']['#upload_validators'], @@ -191,12 +193,22 @@ protected function buildInputElement(array $form, FormStateInterface $form_state */ public function validateUploadElement(array $element, FormStateInterface $form_state) { if ($form_state::hasAnyErrors()) { + \Drupal::logger('file')->notice('Form has errors'); + foreach ($form_state->getErrors() as $name => $message) { + \Drupal::logger('file')->notice($message); + } // When an error occurs during uploading files, remove all files so the // user can re-upload the files. $element['#value'] = []; } $values = $form_state->getValue('upload', []); + if (empty($values['fids'])) { + \Drupal::logger('file')->notice('$values[\'fids\'] empty in validateUploadElement'); + } if (count($values['fids']) > $element['#cardinality'] && $element['#cardinality'] !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { + \Drupal::logger('file')->notice($this->t('A maximum of @count files can be uploaded.', [ + '@count' => $element['#cardinality'], + ])); $form_state->setError($element, $this->t('A maximum of @count files can be uploaded.', [ '@count' => $element['#cardinality'], ]));