diff --git a/core/modules/file/src/FileUploader.php b/core/modules/file/src/FileUploader.php index cf344aff15..0d49240518 100644 --- a/core/modules/file/src/FileUploader.php +++ b/core/modules/file/src/FileUploader.php @@ -26,13 +26,13 @@ /** * Reads data from an upload stream and creates a corresponding file entity. * - * This is implemented at the field-level for the following reasons: + * This is implemented at the field level for the following reasons: * - Validation for uploaded files is tied to fields (allowed extensions, max * size, etc..). * - The actual files do not need to be stored in another temporary location, * to be later moved when they are referenced from a file field. - * - Permission to upload a file can be determined by a user's field and - * entity level access. + * - Permission to upload a file can be determined by a user's field- and + * entity-level access. */ class FileUploader implements FileUploaderInterface { @@ -145,7 +145,7 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit $lock_id = $this->generateLockIdFromFileUri($file_uri); if (!$this->lock->acquire($lock_id)) { - throw new HttpException(503, sprintf('File "%s" is already locked for writing'), NULL, ['Retry-After' => 1]); + throw new HttpException(503, sprintf('File "%s" is already locked for writing.'), NULL, ['Retry-After' => 1]); } // Begin building file entity. @@ -169,7 +169,7 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit // FILE_EXISTS_ERROR as the file location has already been determined above // in file_unmanaged_prepare(). if (!file_unmanaged_move($temp_file_path, $file_uri, FILE_EXISTS_ERROR)) { - throw new HttpException(500, 'Temporary file could not be moved to file location'); + throw new HttpException(500, 'Temporary file could not be moved to file location.'); } $file->save(); @@ -192,9 +192,9 @@ public function handleFileUploadForField(FieldDefinitionInterface $field_definit * Thrown when the 'Content-Disposition' request header is invalid. */ public static function validateAndParseContentDispositionHeader(Request $request) { - // Firstly, check the header exists. + // First, check the header exists. if (!$request->headers->has('content-disposition')) { - throw new BadRequestHttpException('"Content-Disposition" header is required. A file name in the format "filename=FILENAME" must be provided'); + throw new BadRequestHttpException('"Content-Disposition" header is required. A file name in the format "filename=FILENAME" must be provided.'); } $content_disposition = $request->headers->get('content-disposition'); @@ -203,12 +203,12 @@ public static function validateAndParseContentDispositionHeader(Request $request // i.e. 'filename=""'. This also matches on a word boundary so other keys // like 'not_a_filename' don't work. if (!preg_match(static::REQUEST_HEADER_FILENAME_REGEX, $content_disposition, $matches)) { - throw new BadRequestHttpException('No filename found in "Content-Disposition" header. A file name in the format "filename=FILENAME" must be provided'); + throw new BadRequestHttpException('No filename found in "Content-Disposition" header. A file name in the format "filename=FILENAME" must be provided.'); } // Check for the "filename*" format. This is currently unsupported. if (!empty($matches['star'])) { - throw new BadRequestHttpException('The extended "filename*" format is currently not supported in the "Content-Disposition" header'); + throw new BadRequestHttpException('The extended "filename*" format is currently not supported in the "Content-Disposition" header.'); } // Don't validate the actual filename here, that will be done by the upload @@ -286,14 +286,14 @@ protected function readStreamDataToFile($stream) { // Close the file streams. fclose($temp_file); $this->logger->error('Input data could not be read'); - throw new HttpException(500, 'Input file data could not be read'); + throw new HttpException(500, 'Input file data could not be read.'); } if (fwrite($temp_file, $read) === FALSE) { // Close the file streams. fclose($temp_file); $this->logger->error('Temporary file data for "%path" could not be written', ['%path' => $temp_file_path]); - throw new HttpException(500, 'Temporary file data could not be written'); + throw new HttpException(500, 'Temporary file data could not be written.'); } } @@ -303,7 +303,7 @@ protected function readStreamDataToFile($stream) { else { // Close the file streams. fclose($temp_file); - $this->logger->error('Temporary file "%path" could not be opened for file upload', ['%path' => $temp_file_path]); + $this->logger->error('Temporary file "%path" could not be opened for file upload.', ['%path' => $temp_file_path]); throw new HttpException(500, 'Temporary file could not be opened'); } diff --git a/core/modules/file/src/FileUploaderInterface.php b/core/modules/file/src/FileUploaderInterface.php index 399fcbabcf..88f4de7ea7 100644 --- a/core/modules/file/src/FileUploaderInterface.php +++ b/core/modules/file/src/FileUploaderInterface.php @@ -8,12 +8,12 @@ /** * Interface to handle binary file data uploads and file entity creation. * - * This is implemented at the field-level for the following reasons: + * This is implemented at the field level for the following reasons: * - Validation for uploaded files is tied to fields (allowed extensions, max * size, etc..). * - The actual files do not need to be stored in another temporary location, * to be later moved when they are referenced from a file field. - * - Permission to upload a file can be determined by a users field level + * - Permission to upload a file can be determined by a user's field-level * create access to the file field. */ interface FileUploaderInterface { @@ -28,8 +28,8 @@ * @param resource $stream * The upload stream. * @param \Drupal\Core\Session\AccountInterface $owner - * The owner of the file. Defaults to the current user. Note, it is the - * responsibility of the caller to enforce access. + * The owner of the file. Note, it is the responsibility of the caller to + * enforce access. * * @return \Drupal\file\FileInterface|\Drupal\Core\Entity\EntityConstraintViolationListInterface * The newly uploaded file entity, or a list of validation constraint