Make WordPress Core

Opened 20 months ago

Last modified 13 months ago

#56479 new defect (bug)

Missing capability shows blank page in WP-Admin

Reported by: vincenz17's profile vincenz17 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0.2
Component: Posts, Post Types Keywords:
Focuses: ui, administration Cc:

Description

Hello,

I have created a custom post type with the following code.

<?php
function customPostTypeIBF()
{
        $labels = array
        (
                'name'                  => _x('Fortbildungen', 'Post Type General Name', 'ibf'),
                'singular_name'         => _x('Fortbildung', 'Post Type Singular Name', 'ibf'),
                'menu_name'             => __('IBF', 'ibf'),
                'name_admin_bar'        => __('IBF-Fortbildung', 'ibf'),
                'archives'              => __('IBF-Archiv', 'ibf'),
                'all_items'             => __('Alle Fortbildungen', 'ibf'),
                'add_new_item'          => __('Neue Fortbildung', 'ibf'),
                'add_new'               => __('Neue Fortbildung', 'ibf'),
                'new_item'              => __('Neue Fortbildung', 'ibf'),
                'edit_item'             => __('Fortbildung bearbeiten', 'ibf'),
                'update_item'           => __('Fortbildung speichern', 'ibf'),
                'view_item'             => __('Fortbildung anzeigen', 'ibf'),
                'view_items'            => __('Fortbildungen anzeigen', 'ibf'),
                'search_items'          => __('Fortbildung suchen', 'ibf'),
        );

        $args = array
        (
                'label'                 => __('IBF', 'ibf'),
                'description'           => __('Fortbildungen verwalten', 'ibf'),
                'labels'                => $labels,
                'supports'              => array('title', 'editor', 'author', 'thumbnail', 'revisions', 'custom-fields'),
                'show_in_rest'          => true,
                'hierarchical'          => false,
                'public'                => true,
                'show_in_menu'          => true,
                'menu_position'         => 5,
                'menu_icon'             => 'dashicons-welcome-learn-more',
                'has_archive'           => true,
                'rewrite'               => array('slug' => 'ibf'),
                'capability_type'       => 'post',
                'capabilities'          => array
                (
                        'edit_post'             => 'edit_ibf',
                        'edit_posts'            => 'edit_ibfs',
                        'edit_others_posts'     => 'edit_others_ibf',
                        'publish_posts'         => 'publish_ibf',
                        'read_post'             => 'read_ibf',
                        'read_private_posts'    => 'read_private_ibf',
                        'delete_post'           => 'delete_ibf',
                        'create_posts'          => 'create_ibfs', 
                ),
        );

        register_post_type('ibf', $args);
}
add_action('init', 'customPostTypeIBF', 0);

Then I adjusted the wp_user_roles field in the database so that the permissions are also set appropriately based on the role.

Now when I don't have the create_ibf permission I get the following message in the admin panel:

https://i.ibb.co/2dPcrWh/error-ok.png

Thats right and it works!

Now the problem: When I don't have the edit_ibf (without S at the end) permission I just get a white page (blank page) in the admin panel. Now error message or so. Only a white page. The source code shows the page but in the browser I cant see anything.
If I use the developer tools I get the following error message:

https://i.ibb.co/gjjyhkZ/error-white.png

If I follow the link in the error message I can see that:

https://i.ibb.co/3dFQ8Sh/wp-rest-error.png

So I think here is a error message missing.

And now another funny thing: When I havent the permission edit_ibf and disable the block editor with the parameter:

<?php
'show_in_rest' => false,

the page is loading:

https://i.ibb.co/dGJPdj3/ibf-ohne-blockeditor.png

I think something is wrong here. Maybe someone can take a look and fix this. At least the error message that you don't have enough rights would make sense, since you're looking for the error for a long time.

Thanks in advance!

My Live-Server: Ubuntu 20.04.3 with PHP 8.0.22 and MariaDB 10.5
My Test-Server (used here for reporting): Windows 11 with XAMPP and PHP 8.0.19 and a fresh install from 18:00 Uhr

Change History (1)

#1 @vincenz17
16 months ago

Hello,

is someone working in this system?!
Sorry, but I report no bugs anymore because all my tickets will be ignored. No answer, no comment, no status about anything…
That’s not fun. 😒

Note: See TracTickets for help on using tickets.