• Resolved HarshS

    (@harshs)


    Hello –

    I have been observing this issue “Attempt to read property “ID” on null” so frequently that my log file was growing quite rapidly. Hence, I had to fix it myself.

    The issue is in this function of this file: lcp-parameters.php

    // Before fix, problemtic code
      private function lcp_get_current_post_id(){
        global $post;
        return $post->ID;
      }

    Once I fixed this issue, the code is:

      private function lcp_get_current_post_id(){
        global $post;
    
        if( ! $post instanceof WP_Post ) {
            return;
        }
        return $post->ID;
      }

    Please see if you can address this in a better way possible. But the above change resolved my issue that I can confirm.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor zymeth25

    (@zymeth25)

    Hi, you didn’t provide any details on how you are using the plugin – it is impossible to tell if this is a bug or misconfiguration on your side.

    Please provide versions of LCP, PHP, WP, shortcode used and any other details you think relevant.

    Thread Starter HarshS

    (@harshs)

    Sure. Here are the details:

    • LCP: 0.89.2
    • PHP: 8.1.25 @64BitOS
    • WP: 6.4.1

    I used the LCP sidebar widget to display the category-specific posts, not the shortcode. Here is the link where you can see my LCP widget settings: LCP widget settings

    By the way, since I have choose to list post belonging to the current category, so I made sure that the widget only display on either category pages or posts, nowhere.

    • This reply was modified 1 year ago by HarshS.
    Plugin Contributor zymeth25

    (@zymeth25)

    Fixed in 0.89.3. Thanks for reporting.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Attempt to read property “ID” on null in lcp-parameters.php at line 257’ is closed to new replies.