Skip to content

Invalid parameter given. A valid $fileId[tmp_name] is expected #25835

Open
@OleksiyOleksiyovych

Description

@OleksiyOleksiyovych

Preconditions (*)

  1. Magento 2.3.3

Steps to reproduce (*)

  1. Login into the admin panel
  2. Go to Stores - Settings - Configuration.
  3. Open tab Catalog - Catalog. Fieldset "Product Image Placeholders".
  4. Select the placeholder image for field "Base"
  5. Click to button "Save"
    You can try another setting with type "file"

Expected result (*)

Screen Shot 2019-11-29 at 10 14 52 AM
Error message: Invalid parameter given. A valid $fileId[tmp_name] is expected.

Actual result (*)

  1. File uploaded and the configuration saved without errors

Issue reason

The reason for this issue is additional validation - function validateFileId
In this function we have check is uploaded file located in "correnct" tmp dicartory.
sys_get_temp_dir() get folder /tmp
$_FILES["file"]["tmp_name"] located in folder /chroot/home/tmp/xxxxxxx
Nexcess support said: "This actually makes sense, because /tmp is a symbolic link to /chroot/home/tmp on our servers."

Possible fixes

  1. [Correct way] Configure upload_tmp_dir to an allowed folder:
  • "var/tmp" (or another based on sys_get_temp_dir() value)
  • "<magento_root>/pub/media"
  • "<magento_root>/var"
  • "<magento_root>/var/tmp"
  • "<magento_root>/pub/media/upload"

But it can be not so easy (impossible). For example, we have issue on Nexcess server. Server support responce:

sys_get_temp_dir: /tmp
$_FILES["file"]["tmp_name"]: /chroot/home/tmp/phpPEOxFn
This actually makes sense, because /tmp is a symbolic link to /chroot/home/tmp on our servers.

  1. [Hotfix] Add preference for class Magento/Framework/File/Uploader.php and remove validateFileId logic. You can not add a preference for this file.

  2. [Hotfix v2] Add custom patch. How to apply here. Patch here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Admin UIComponent: FilesystemIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedPriority: P3May be fixed according to the position in the backlog.Progress: PR in progressReported on 2.3.3Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions