magento2: Zend_Validate_File_Upload - undefined class on 2.4.6

Preconditions and environment

  • Magento OS 2.4.6
  • method \Magento\ImportExport\Model\Source\Upload::uploadSource is using a removed Zend_Validate_File_Upload class
  • restricted_classes.php is missing replacement for Zend_Validate_File_Upload , see: magento-coding-standard/Magento2/Sniffs/Legacy/_files/restricted_classes.php

There is Laminas class which can be used as template for appropriate Magento class: Laminas\Validator\File\Upload

Steps to reproduce

I was digging in the importer code and just found that this class has not been migrated. Uploading an import file larger than configured in php.ini will crash the validator.

Expected result

  • restricted_classes.php should have replacement for Zend_Validate_File_Upload , see: magento-coding-standard/Magento2/Sniffs/Legacy/_files/restricted_classes.php

  • One of the messages is printed: __('Make sure your file isn\'t more than %1M.', $maxImageSize); __('We can\'t provide the upload settings right now.');

Actual result

Validator crashes

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Shall we assume that code is correct if the class does not exist? It should be removed or replaced and marked in legacy tests because someone might’ve been using it in their module.

The message should indicate that file was not uploaded due to its size. Current error message is too vague and does not point to the source of the problem.

Agreed, we should not be referencing classes that don’t exist in codebase. \Zend_File_Transfer_Adapter_Http also doesn’t exist anymore yet is being used as typehint reference in screenshot above.