• Resolved scatory2

    (@scatory2)


    After updating site to php and WP 8 I get this warning on my local

    Warning: Attempt to read property "cat_ID" on null and it’s coming from functions.php

    here is the block of code:

    add_action('pre_get_posts', 'pre_get_posts_mod1' ); 
    	function pre_get_posts_mod1( $wp_query ) { 
     
    	$excluded =  get_resource_cat_ids();  
     	//exclude podcast category by ID 
    	array_push($excluded, '9', '1691'); 
    	  
    	$page_object = get_queried_object(); 
    	$cat_ID = $page_object->cat_ID; 
    	//do we exclude anything from main loop? 
    	if (!in_array( $cat_ID , $excluded )) {
    	//exclude categories
    	set_query_var('category__not_in', $excluded);  
    		}	  
    	
     }

    Stack trace from debug log

    
    [10-Jun-2022 13:18:20 UTC] PHP Stack trace:
    [10-Jun-2022 13:18:20 UTC] PHP   1. {main}() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-admin/admin-ajax.php:0
    [10-Jun-2022 13:18:20 UTC] PHP   2. require_once() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-admin/admin-ajax.php:22
    [10-Jun-2022 13:18:20 UTC] PHP   3. require_once() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-load.php:50
    [10-Jun-2022 13:18:20 UTC] PHP   4. require_once() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-config.php:92
    [10-Jun-2022 13:18:20 UTC] PHP   5. do_action() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-settings.php:620
    [10-Jun-2022 13:18:20 UTC] PHP   6. WP_Hook->do_action() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/plugin.php:476
    [10-Jun-2022 13:18:20 UTC] PHP   7. WP_Hook->apply_filters() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-hook.php:331
    [10-Jun-2022 13:18:20 UTC] PHP   8. wpDiscuzForm->initPersonalDataExporter() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-hook.php:307
    [10-Jun-2022 13:18:20 UTC] PHP   9. wpdFormAttr\Tools\PersonalDataExporter::getInstance() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-content/plugins/wpdiscuz/forms/wpDiscuzForm.php:60
    [10-Jun-2022 13:18:20 UTC] PHP  10. wpdFormAttr\Tools\PersonalDataExporter->__construct() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Tools/PersonalDataExporter.php:112
    [10-Jun-2022 13:18:20 UTC] PHP  11. wpdFormAttr\Tools\PersonalDataExporter->initFormsFields() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Tools/PersonalDataExporter.php:16
    [10-Jun-2022 13:18:20 UTC] PHP  12. get_posts() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Tools/PersonalDataExporter.php:21
    [10-Jun-2022 13:18:20 UTC] PHP  13. WP_Query->query() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/post.php:2410
    [10-Jun-2022 13:18:20 UTC] PHP  14. WP_Query->get_posts() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-query.php:3586
    [10-Jun-2022 13:18:20 UTC] PHP  15. do_action_ref_array() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-query.php:1805
    [10-Jun-2022 13:18:20 UTC] PHP  16. WP_Hook->do_action() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/plugin.php:524
    [10-Jun-2022 13:18:20 UTC] PHP  17. WP_Hook->apply_filters() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-hook.php:331
    [10-Jun-2022 13:18:20 UTC] PHP  18. pre_get_posts_mod1() /Users/jasonsprague/Local Sites/marketsmart-site/app/public/wp-includes/class-wp-hook.php:307
    [10-Jun-2022 13:18:20 UTC] PHP Warning:  Attempt to read prop
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    Hello scatory2,

    The issue comes from the custom code you’re using and doesn’t have any relation to the wpDiscuz plugin. You should correct the code so that the error won’t appear again.

    Thread Starter scatory2

    (@scatory2)

    @gvectorssupport the error was triggered by an AJAX request that the wpDiscuz plugin should process.

    Plugin Support gVectors Support

    (@gvectorssupport)

    You should replace these lines:

    $page_object = get_queried_object();
    	$cat_ID = $page_object->cat_ID;

    with the following one:

    $page_object = get_queried_object();
    $cat_ID = 0;
    if($page_object){
    	$cat_ID = $page_object->cat_ID;

    After the last update of this plugin, I can’t edit a post that says “There has been a critical error on this website. Please check your site admin email inbox for instructions.”
    PHP version: 8.1.0
    Please help me fast

    Error Details
    =============
    An error of type E_ERROR was caused in line 173 of the file /home/a54321/domains/mysite.com/public_html/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Form.php. Error message: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /home/a54321/domains/mysite.com/public_html/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Form.php:173
    Stack trace:
    #0 /home/a54321/domains/mysite.com/public_html/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Form.php(173): array_key_exists()
    #1 /home/a54321/domains/mysite.com/public_html/wp-content/plugins/wpdiscuz/forms/wpdFormAttr/Form.php(367): wpdFormAttr\Form->getEnableRateOnPost()
    #2 /home/a54321/domains/mysite.com/public_html/wp-includes/class-wp-hook.php(307): wpdFormAttr\Form->displayRatingMeta()
    #3 /home/a54321/domains/mysite.com/public_html/wp-includes/plugin.php(191): WP_Hook->apply_filters()
    #4 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1811): apply_filters()
    #5 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(560): WP_REST_Posts_Controller->prepare_item_for_response()
    #6 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api/class-wp-rest-server.php(1143): WP_REST_Posts_Controller->get_item()
    #7 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api/class-wp-rest-server.php(990): WP_REST_Server->respond_to_request()
    #8 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api.php(519): WP_REST_Server->dispatch()
    #9 /home/a54321/domains/mysite.com/public_html/wp-includes/rest-api.php(2868): rest_do_request()
    #10 [internal function]: rest_preload_api_request()
    #11 /home/a54321/domains/mysite.com/public_html/wp-includes/block-editor.php(601): array_reduce()
    #12 /home/a54321/domains/mysite.com/public_html/wp-admin/edit-form-blocks.php(75): block_editor_rest_api_preload()
    #13 /home/a54321/domains/mysite.com/public_html/wp-admin/post.php(187): require('/home/u63040410...')
    #14 {main}
      thrown
    Plugin Support gVectors Support

    (@gvectorssupport)

    Hi @softfully,

    This issue will be fixed very soon. Please wait for the next update.

    Plugin Support gVectors Support

    (@gvectorssupport)

    @softfully,

    Please update the wpDiscuz to the latest version (v. 7.3.19) and check again. The issue should be solved.

    Thank you. Now works fine.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error stemming from this plugin’ is closed to new replies.