Skip to content

File-upload field with empty "File types" crashes plupload init — upload button dead #658

Description

@milicavs

Summary

A PPOM file-upload (or cropper) field with no File types value throws an uncaught JS error while plupload initializes on the product page. The uploader is never constructed, so the "Select files" button does nothing.

Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at plupload.min.js?ver=2.1.9:1:6626
    at ppom_setup_file_upload_input (file-upload.js:557)
    at file-upload.js:337

Steps to reproduce

  1. On a product, add a File Upload field via the field modal and leave File types empty.
  2. Save and open the product page on the front end.
  3. Actual: console TypeError on load; the button does nothing. Expected: file picker opens.

Workaround: set File types on the field to any value (e.g. jpg,png,gif,pdf,zip).

Root cause

The uploader reads its config from ppom_input_vars.ppom_inputs, built by Settings::get_js_input_vars(), which passes raw field meta through — the per-type switch defaults daterange/color/bulkquantity but not file/cropper (src/Arrays/Settings.php:551-607). plupload then receives extensions: file_input.file_types (js/file-upload.js:571); when that's undefined it calls .split() on it and throws inside new plupload.Uploader(...), aborting construction. (file_size being empty is harmless — only file_types crashes.)

Proposed fix

Default file_types/file_size for file/cropper in the same switch that already defaults other types — fixes existing saved fields too, no build step:

// src/Arrays/Settings.php — inside switch ( $type )
case 'file':
case 'cropper':
    if ( empty( $fields_meta['file_types'] ) ) {
        $fields_meta['file_types'] = 'jpg,pdf,zip';
    }
    if ( empty( $fields_meta['file_size'] ) ) {
        $fields_meta['file_size'] = '1mb';
    }
    break;

Optional guard in js/file-upload.js:571:

{ title: 'Filetypes', extensions: file_input.file_types || 'jpg,png,gif' },

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions