Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#39651 new defect (bug)

Find Posts modal does not show post-type labels correctly

Reported by: arkonisus's profile arkonisus Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7.1
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:

Description

The screenshot shows the output of four different posts in the Find Posts Modal. The last two post are correct, at the first and second post the post-type-label (e.g. cpt_example) is missing. The problem is the post-type parameter "public", if it is set to "false" the label will not be shown AND you will get the following PHP-Notice (if DEBUG is true):

Undefined index: cpt_example in ... /wp-admin/includes/ajax-actions.php on line 1803
Trying to get property of non-object in ... /wp-admin/includes/ajax-actions.php on line 1803

At the following code (1745 ff.) you will notice the reason of this issue: $post_types only includes public posts

<?php
/**
 * Ajax handler for querying posts for the Find Posts modal.
 *
 * @see window.findPosts
 *
 * @since 3.1.0
 */
function wp_ajax_find_posts() {
        check_ajax_referer( 'find-posts' );

        $post_types = get_post_types( array( 'public' => true ), 'objects' );
                                             ^^^^^^^^^^^^^^^^

The output of this modal shows all posts (public and unpublic), so i don't think that this "filter" was set for security reasons. In my opinion it must either show all posts correctly with their labels (which would be great) or it must suppress all "unpublic" posts completely.

Attachments (1)

find_posts.png (31.0 KB) - added by arkonisus 7 years ago.

Download all attachments as: .zip

Change History (4)

@arkonisus
7 years ago

#1 @azaozz
7 years ago

  • Component changed from Editor to Administration
  • Focuses administration removed
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#2 @azaozz
7 years ago

Seems it will need to check if the current user can see private posts and exclude them if not.

#3 @SergeyBiryukov
7 years ago

  • Component changed from Administration to Posts, Post Types
Note: See TracTickets for help on using tickets.