WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 2 months ago

#50325 closed enhancement (fixed)

Misleading error message when upload of an image fails

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

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 2 months ago.
error message changed
50325.1.diff (576 bytes) - added by Shital Patel 2 months ago.
full path of src folder
50325.2.diff (568 bytes) - added by Shital Patel 2 months ago.
original message added

Download all attachments as: .zip

Change History (8)

#1 @ocean90
2 months ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to 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
2 months ago

error message changed

@Shital Patel
2 months ago

full path of src folder

#2 @Shital Patel
2 months ago

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

#3 @Presskopp
2 months ago

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

Could not insert item into the database

@Shital Patel
2 months ago

original message added

#4 @SergeyBiryukov
2 months ago

  • Milestone changed from Future Release to 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
2 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to 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.