Skip to content

Media uploader fails on dev/2.0 due to setting invalid "cancelled" field in ca_media_upload_sessions #1938

Description

@mellison-seagov

Hi there, I ran into this while testing something else, and I'm not sure of the best solution, but I hope these findings will help.

This is on branch dev/2.0, latest. I can confirm that this wasn't broken on that branch a few months ago.

Steps to repro

  • Ensure in app.conf that media_uploader_enabled = 1
  • Go to Import -> Media Uploader
  • Upload anything

Error and debugging output

You'll get a red error on the page: "Limit of 0 files per upload exceeded." Ignore it. It has nothing to do with the issue.

Inspect the network response or app/log/log_YYYY-MM-DD.txt and you'll see another error: MediaUploadManageSessionException: Could not create media upload session: '0' is not a valid choice for Status of session.

Turn on debug mode and drop a breakpoint in the first line of app/lib/MediaUploaderManager::newSession. Step into the $s->set call and loop through the fields. You'll find it sets session_key then user_id but fails on cancelled because cancelled is not a valid field of ca_media_upload_sessions.

We lose that error about cancelled but get the '0' is not a valid choice for Status of session error on the $s->insert() call because it had never made it to setting the status field earlier.

Workaround

Comment out the 'cancelled' => 0, line in app/lib/MediaUploaderManager.php to upload successfully. Not sure of the impact of doing that, though. Seems like this is meant to let the user cancel uploads, but I don't think this field has been working for a long time, if ever.

Analysis

The immediate culprit was 7cef928 a few weeks ago. It forced that status field to 0, which then fails model validation.

But that change wouldn't have broken anything if this cancelled field wasn't silently failing. It seems better to fix cancelled in ca_media_upload_sessions or remove it from MediaUploadManager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions