[wp-trac] [WordPress Trac] #47773: wp_trash_post() ignores errors from wp_update_post()
WordPress Trac
noreply at wordpress.org
Sat Jul 27 07:50:47 UTC 2019
#47773: wp_trash_post() ignores errors from wp_update_post()
-------------------------------+-----------------------------
Reporter: siliconforks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version: 5.2.2
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------------+-----------------------------
Comment (by manzoorwani.jk):
@abhijitrakas You could simply pass the second argument as `false` to
`wp_update_post` to make it not return `WP_Error` and then check only for
the false value, like this
{{{#!php
<?php
$post_updated = wp_update_post(
array(
'ID' => $post_id,
'post_status' => 'trash',
),
false
);
// Check if post was not updated.
if ( ! $post_updated ) {
return false;
}
}}}
Also, there is `wp_trash_post_comments` which could also fail.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47773#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list