diff --git a/core/modules/file/src/Plugin/Validation/Constraint/FileValidationConstraintValidator.php b/core/modules/file/src/Plugin/Validation/Constraint/FileValidationConstraintValidator.php index 50e4c3611d..8b26e88ce8 100644 --- a/core/modules/file/src/Plugin/Validation/Constraint/FileValidationConstraintValidator.php +++ b/core/modules/file/src/Plugin/Validation/Constraint/FileValidationConstraintValidator.php @@ -16,16 +16,17 @@ class FileValidationConstraintValidator extends ConstraintValidator { public function validate($value, Constraint $constraint) { // The file might not exist. In that case we will already have an // invalid reference violation. - if (!($file = $value->get('entity')->getTarget())) { + $file_target = $value->get('entity')->getTarget(); + if (!$file_target) { return; } // Get the file to execute validators. - $file = $file->getValue(); + $file = $file_target->getValue(); // Get the validators. $validators = $value->getUploadValidators(); // Checks that a file meets the criteria specified by the validators. - if ($errors = file_validate($file, $validators)) { + if ($errors = file_validate($file_target, $validators)) { foreach ($errors as $error) { $this->context->addViolation($error); }