• Resolved Aleksandr

    (@aleksandrx)


    My log is filled with the message: PHP Warning: Attempt to read property “label” on null in /wp-content/plugins/betterdocs/includes/Editors/Elementor/DocsArchive.php on line 47

    The error occurs because:

    1. get_post_type_object('docs') is called on line 45
    2. If the ‘docs’ post type hasn’t been registered yet (timing issue during WordPress initialization), this function returns null
    3. Line 47 tries to access without checking if the object exists first $post_type_object->label
    4. PHP 8.0+ throws a warning when you try to access a property on null

    Maybe it’s worth adding a null check?

    if ( $post_type_object !== null ) {

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Minor bug fix’ is closed to new replies.