Replace FileUploadHandler:: handleFileUpload() switch with match when core requires PHP 8

Created on 13 October 2021, about 3 years ago
Updated 12 December 2023, 11 months ago

Problem/Motivation

Coming from #3232248-54: Move _file_save_upload_single to a service and deprecate

Steps to reproduce

+++ b/core/modules/file/src/Upload/FileUploadHandler.php
@@ -0,0 +1,134 @@
+    switch ($uploadedFile->getError()) {
+      case \UPLOAD_ERR_INI_SIZE:
...
+      case \UPLOAD_ERR_FORM_SIZE:
...
+      case \UPLOAD_ERR_PARTIAL:
...
+      case \UPLOAD_ERR_NO_FILE:
...
+      case \UPLOAD_ERR_NO_TMP_DIR:
...
+      case \UPLOAD_ERR_CANT_WRITE:
...
+      case \UPLOAD_ERR_EXTENSION:
...
+    throw new FileException($uploadedFile->getErrorMessage());

Proposed resolution

Use https://www.php.net/manual/en/control-structures.match.php

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Closed: won't fix

Version

10.0

Component
File system 

Last updated about 11 hours ago

Created by

🇫🇷France andypost

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024