Opened 4 years ago
Last modified 4 years ago
#50546 new enhancement
Add better error notices when deleting things fail
Reported by: | dingo_d | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | 2nd-opinion has-patch |
Focuses: | ui, administration | Cc: |
Description
I've stumbled upon this when working with foreign key restraints and post deletion. Working on a project I've added some data to the custom DB table row that has a foreign key association with custom post type post.
So, when I try to delete the post it will fail, as it should 🎉.
But the error I got was: Error in deleting
.
Hmmm, ok. Not a big deal. WordPress is pretty flexible in most cases, so there's bound to be a filter for that.
When searching for it, upon checking the above string I've found 5 matches in 3 files. So if some error happens when deleting a post, you'll get that message in wp_die
. If it happens on attachment delete, the same message.
How are you supposed to know where that error came from, just from the message? You need to check the error log, etc. Which is ok when you're a developer, but what if you're not? A user could get this message on the screen from some plugin and then they'll open up a support question with this message.
Not really helping the debugging process.
I'm not saying the entire stack trace should be visible (that is advanced debugging), but even just adding Error in deleting a post
, or Error in deleting an attachment
would be an improvement IMO.
Having some extra details would be even better, but small steps first.
Attachments (1)
Change History (8)
#1
@
4 years ago
- Component changed from Administration to Posts, Post Types
- Focuses ui administration added
- Keywords has-patch added; needs-patch removed
#2
follow-up:
↓ 3
@
4 years ago
Since we have a post ID, we could add get_post_type
to identify the post type? And fall back to item
as a default?
Or would that be a bit much?
#3
in reply to:
↑ 2
@
4 years ago
Replying to dingo_d:
Since we have a post ID, we could add
get_post_type
to identify the post type? And fall back toitem
as a default?
A general best practice in WordPress is to avoid post type and taxonomy names in generic strings due to i18n concerns and structural differences in languages. For reference, see:
Thanks for the ticket!
Yes, it would be a good idea to disambiguate these strings.
For reference, it's currently a series of related strings:
They use "this item" instead of "post" to account for custom post types, see [12728] / #9674. We should be able to explicitly mention "attachment" though.
50546.diff attempts to bring some consistency:
If we want further clarify what "the item" refers to, these strings should be added to
get_post_type_labels()
.