• 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)
  • Plugin Support Ashikur Rahman

    (@ashikurwp)

    Hi @aleksandrx ,
    Sorry for any inconvenience!

    Your query has been forwarded to the BetterDocs DEV team for further investigation. We’ll let you know once we have an update from the team. Please allow us some time to look into this.

    We appreciate your patience.
    Best regards,

    Plugin Support Sadman Sakib Nadvi

    (@sadmansakibnadvi)

    Hi @aleksandrx,

    Thanks so much for your patience while our team investigated the issue. We’ve implemented a fix for the PHP warning you flagged, and you can find the updated development version here: https://d.pr/f/VF7pBN

    Please give it a try and let us know if everything runs smoothly on your end. We’re standing by for your feedback.

    Warm regards,

    Thread Starter Aleksandr

    (@aleksandrx)

    Hi, thank you, your version is better – shorter and cleaner.

    if ( $post_type_object ) { – It checks for both null and false

    Plugin Support Sadman Sakib Nadvi

    (@sadmansakibnadvi)

    Hi @aleksandrx ,

    You are most welcome. I’m really glad to hear the solution worked for you!

    If you don’t mind me asking, could you please do me a quick favor and spend just 30 seconds to leave us a review? Your feedback helps us improve and serve you even better.

    You can submit your review here:
    https://wordpress.org/support/plugin/betterdocs/reviews/#new-post

    Thank you so much in advance for your support!

    Best regards,

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

You must be logged in to reply to this topic.