Attempt to read property “ID” on null in class.ziprecipes.php on line 1569
-
Hi there,
After switching to PHP8 you might encounter the following warning:
PHP Warning: Attempt to read property "ID" on null in .../zip-recipes/class.ziprecipes.php on line 1569
Here is a quick fix to check whether $post has set prior to access its properties.
--- class.ziprecipes.org.php 2022-10-11 09:50:30.928611488 +0200 +++ class.ziprecipes.php 2022-10-11 09:55:14.265627257 +0200 @@ -1566,7 +1566,7 @@ $recipe_json_ld = array(); // get recipe id - limitation: only 1 recipe is supported - if (Util::has_shortcode($post->ID, $post)){ + if (isset($post) && Util::has_shortcode($post->ID, $post)){ // Find recipe $recipe = new Recipe(false, $post->ID); $recipe_json_ld = $recipe->jsonld();
Cheers!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Attempt to read property “ID” on null in class.ziprecipes.php on line 1569’ is closed to new replies.