Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#50325 closed enhancement (fixed)

Misleading error message when upload of an image fails

Reported by: Presskopp Owned by: SergeyBiryukov
Priority: normal Milestone: 5.5
Component: Media Version:
Severity: normal Keywords: good-first-bug has-patch
Cc: Focuses: administration

Description

If uploading an image fails we get the error

Could not insert post into the database

Yes, every image will have it's post, but the error message should rather say

Your file could not be uploaded for some reason

see
​https://build.trac.wordpress.org/browser/trunk/wp-includes/post.php?marks=3983#L3983

Attachments (3)

50325.diff​ (564 bytes ) - added by Shital Patel 6 years ago.
error message changed
50325.1.diff​ (576 bytes ) - added by Shital Patel 6 years ago.
full path of src folder
50325.2.diff​ (568 bytes ) - added by Shital Patel 6 years ago.
original message added

Download all attachments as: .zip

Change History (8)

#1 @ocean90
6 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone Awaiting Review → Future Release
  • Type defect (bug) → enhancement

The upload didn't fail in this case so your suggestion would be misleading as well. Since this is a rare error message that the end user should see we can simply replace "post" with "item".

@Shital Patel
6 years ago

error message changed

@Shital Patel
6 years ago

full path of src folder

#2 @Shital Patel
6 years ago

  • Focuses administration added
  • Keywords has-patch added; needs-patch removed

#3 @Presskopp
6 years ago

@shital-patel thanks for the patch. Please change the string to:

Could not insert item into the database

@Shital Patel
6 years ago

original message added

#4 @SergeyBiryukov
6 years ago

  • Milestone Future Release → 5.5

Thanks for the patch! Just noting that we have a specific message for each data type:

  • Could not insert link into the database
  • Could not update link in the database
  • Could not insert site into the database.
  • Could not update site in the database.
  • Could not insert post into the database
  • Could not update post in the database
  • Could not insert term into the database.
  • Could not insert term taxonomy into the database.
  • Could not insert term relationship into the database.

So, instead of switching to a generic "item", I think it would be better to introduce two new strings for attachments:

  • Could not insert attachment into the database.
  • Could not update attachment in the database.

This would also be consistent with some special cases for 'attachment' === $post_type in wp_insert_post(), e.g. wp_insert_attachment_data vs wp_insert_post_data hooks and a few others.

#5 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 47922:

Posts, Post Types: Display a more specific error message when an attachment could not be inserted into the database.

Props shital-patel, Presskopp, ocean90.
Fixes #50325.

Note: See TracTickets for help on using tickets.