• Resolved Alain Aubry

    (@caban13)


    Hi
    I don’t see any problem, but when I enable “debug” I see 3 lines with the following texts:

    • Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 717
    • Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 720
    • Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-breadcrumbs.php on line 399

    FYI, thanks.

    • This topic was modified 5 years, 5 months ago by Alain Aubry.

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • It seems that happens when you open “author pages”. Could you write more details how to reproduce these PHP warnings (plugin/theme conflicts)?
    I’ve created PR 10905 (Uses get_query_var instead get_queried_object…) and you can look for more details there. If you find more details then we could try to re-open this PR.

    Plugin Support Jerlyn

    (@jerparx)

    Hi @caban13,

    Can you please confirm if you are getting the same error even with the latest Yoast SEO 9.1? And does your server meet the plugin requirements here?

    If the issue persists, we suggest doing a conflict check. You can follow the steps here: https://kb.yoast.com/kb/how-to-check-for-plugin-conflicts/

    Thread Starter Alain Aubry

    (@caban13)

    @stodorovic: yes it happens just on author pages…

    @jerparx: with latest Yoast SEO 9.1 is still the same…
    I have PHP version 7.2.12.
    I have MariaDB version 10.1.36.
    I have not yet checked for plugin conflicts… I will, later…

    Thanks

    Plugin Support devnihil

    (@devnihil)

    @caban13 Please let us know what the outcome of the plugin/theme conflict check is.

    Plugin Support amboutwe

    (@amboutwe)

    This thread has been marked as resolved due to lack of activity.

    You’re always welcome to re-open this topic. Please read this post before open a new request.

    Thanks for understanding!

    Thread Starter Alain Aubry

    (@caban13)

    NO, IT IS NOT RESOLVED !!!!!
    You did not even ask me…
    The situation is exactly the same.

    • This reply was modified 5 years, 4 months ago by Alain Aubry.

    I’ve already written that we have “possible solution” – please read PR 10905. We don’t have exact steps how to reproduce it and we can’t apply patch until we know more details. We need your feedback related to plugin which cause it. In this case we could re-open this issue again.

    Please deactivate plugin by plugin (except Yoast SEO) and check author page at each iteration. If PHP notices disappear (after deactivation of specific plugin) then please send which plugin causes PHP notices. I’ll try to reproduce it.

    If it happens when all plugins are deactivated (except Yoast) then it’s most likely theme issue. Please send more details about the theme.

    PS: It seems as dev site and I think that’s easy doable. Please check “plugin conflicts”.

    Thread Starter Alain Aubry

    (@caban13)

    I tried to read PR 10905.
    It is way too complicated, too many voices, I don’t understand that.
    I will follow your steps and I tell you the results here.
    Thanks

    Thread Starter Alain Aubry

    (@caban13)

    After disabling all plugins the error was still present, so I changed theme to “Twenty Seventeen”, then the error went away.

    Then, I returned to my theme, but I disabled my child theme, leaving just the standard theme, the error was gone.

    So, it is my fault, it is something related to my child theme.
    I will have too look in greater detail.

    The problem is not generated by Yoast SEO as the message indicated.
    Thank you very much, this ticket is closed.

    Alain

    Thread Starter Alain Aubry

    (@caban13)

    As I said before this is still NOT RESOLVED.

    My last input declared the fault was in my child theme, is true, but is not clear why.

    My child theme has loads of functions, so I started to disable the ACTIONS one by by one, in order to find the faulty function. I find it. I shared with the theme developer. He sees no problem. Now I going to share this function here:

    
    // Indigo Adjust Main Queries
    add_action( 'pre_get_posts', 'indigo_adjust_queries' );
    function indigo_adjust_queries( $query ) {
    	if ( !is_admin() && is_post_type_archive( 'actividade' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', 'post_modified' );
    		$query->set( 'order', 'DESC' );
    	endif; // actividade
    
    	if ( !is_admin() && is_post_type_archive( 'colaborador' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', array(
    			'relation' => 'AND',
    			array(
    				'orderby' => 'menu_order',
    				'order', 'ASC'
    			),
    			array(
    				'orderby' => 'post_title',
    				'order', 'ASC'
    			)
    		));
    	endif; // colaborador
    
    	if ( !is_admin() && is_post_type_archive( 'evento' ) && $query->is_main_query() ) :
        $today = date('Ymd');
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'post_type', 'evento' );
        $query->set( 'meta_key', 'data_do_evento' );
        $query->set( 'orderby', 'meta_value_num' );
        $query->set( 'order', 'ASC' );
        $query->set( 'meta_query', array(
          array(
            'key' => 'data_do_evento',
            'compare' => '>=',
            'value' => $today,
            'type' => 'numeric'
          )
        ));
    	endif; // evento
    
    	if ( !is_admin() && is_post_type_archive( 'course' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', 'post_modified' );
    		$query->set( 'order', 'DESC' );
    	endif; // course
    
    	$term = single_term_title( '', false );
    	if ( $term ) :
    		if ( !is_admin() && is_tax( 'grupo' ) && $query->is_main_query() ) :
    			$query->set( 'post_per_page', -1 );
    			$query->set( 'post_type', 'colaborador' );
    			$query->set( 'orderby', 'menu_order' );
    			$query->set( 'order', 'ASC' );
    			$query->set( 'tax_query', array(
    				array(
    					'taxonomy' => 'grupo',
    					'field' => 'name',
    					'operator' => 'IN',
    					'terms' => $term
    				)
    			));
    		endif; // colaborador
    
    		if ( !is_admin() && is_tax( 'tipo' ) && $query->is_main_query() ) :
    			$query->set( 'post_per_page', -1 );
    			$query->set( 'post_type', 'actividade' );
    			$query->set( 'orderby', 'post_modified' );
    			$query->set( 'order', 'DESC' );
    			$query->set( 'tax_query', array(
    				array(
    					'taxonomy' => 'tipo',
    					'field' => 'name',
    					'operator' => 'IN',
    					'terms' => $term
    				)
    			));
    		endif; // actividade
    	endif; // terms
    
    } // END indigo_adjust_queries
    

    Here, again, I went disabling sections, one at the time, to find the faulty part. This single line is the one causing the problem:

    $term = single_term_title( '', false );

    I really don’t see any problem with this, my developer either, can you explain it? Or better get a fix for it…

    Thanks
    Alain

    • This reply was modified 5 years, 4 months ago by Alain Aubry.

    @caban13 It’s same as an issue described in PR 10905. Function single_term_title executes get_queried_object() which resets queried object. I see more issues in your code and I’ll try to send an example how you can improve current code (in next few days if I find enough time).

    For now, you should avoid using single_term_title (which returns title instead of slug or term_id, and it can’t be used in this context) and correct way is:

    if ( ! empty( $query->query_vars['term'] ) {
    
    }
    

    More details – https://codex.wordpress.org/WordPress_Query_Vars

    Thread Starter Alain Aubry

    (@caban13)

    Hi

    I tried to replace: $term = single_term_title( '', false );
    with $term = $query->query_vars['term'];
    it gave me HUGE amount of errors everywhere.

    Undefined index: term

    I don’t see any documentation declaring errors or a different usage here: https://developer.wordpress.org/reference/functions/single_term_title/

    Thanks

    There are notes related to action/filters. Anyway you can’t use all functions inside hook pre_get_posts.

    I already sent correct way. Please replace following lines:

    $term = single_term_title( '', false );
    if ( $term ) :
    

    with these lines:

    if ( ! empty( $query->query_vars['term'] ) ) :
    	$term = $query->query_vars['term'];	
    

    I don’t see reason why you change tax_query because I think that already contains correct term. It’s better to use slug as field (now $term contains slug) and you need to replace 'name' with 'slug' later in the code.

    I already wrote that there are more mistakes (I see orderby as an issue) and code readability isn’t good (repeating same conditionals,…). I’ll try to write better example based on your function (it’s possible to split it into couple functions), but I don’t have time at this moment (maybe I find some moment until end of this week).

    Thread Starter Alain Aubry

    (@caban13)

    HI Saša

    Thank you very much for your support… Your solution is working fine, I have not tested online yet, only local, but the error is gone.

    $query->set( 'tax_query',... has to do with using single_term_title... seems to me, that using query_vars['term'] creates a different situation.

    The idea was to find out which ‘grupo’ (group) was been displayed.

    Thanks
    Alain

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘get property of non-object’ is closed to new replies.