Opened 5 months ago
#61716 new defect (bug)
Fatal error: Uncaught ArgumentCountError in get_delete_post_link() when _edit_link is site-editor.php?postType=%s&postId=%s&canvas=edit
Reported by: | bobbingwide | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-screenshots |
Focuses: | Cc: |
Description
Background
I while ago, before WordPress 6.3, I wrote plugin called gbcptedit ( Gutenberg Custom Post Type Edit ) which enables me to see the posts for the CPTs that were introduced by Gutenberg into WordPress. I used this plugin to help debug / problem determination of several problems where the site editor was not working as expected.
I recently noticed a Fatal error while attempting to view template parts.
Analysis of the problem indicates that this is a problem within the get_delete_post_link()
. The function assumes that the format of the
_edit_link
property for the post_object is post.php?post=%d
, so it only passes the post ID to the sprintf
The failing line is
$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
When the _edit_link
is
site-editor.php?postType=%s&postId=%s&canvas=edit
then sprintf expects 3 parameters; the second for the postType attribute and the third for the postId.
The Docblock for the function states
Can be used within the WordPress loop or outside of it, with any post type.
This comment is no longer true.
In my opinion the code needs to be corrected rather than the comment.
Note: I was not using get_delete_post_link directly. It's called during WP_List_Table->display.
Screenshot of the Fatal error on Template Parts ( wp_template_part ) showing the stack trace