• Resolved madmax4ever

    (@madmax4ever)


    Hello,

    Turning on debug logs, I found that there was a problem with https://plugins.trac.wordpress.org/browser/hide-categories-on-shop-page/trunk/wc-hide-categories-on-shop-page.php#L147.
    As a matter of fact, $terms can contain a mix of WP_Term objects and numerci term_ids… So when it’s a numeric ID, it doesn’t have a ‘slug’ sub-object, so $term->slug is null.

    So I had to change:

    foreach ( $terms as $key => $term ) {
    	if ( ! in_array( $term->slug, $data ) ) {
    		$new_terms[] = $term;
    	}
    }

    into:

    foreach ( $terms as $key => $term ) {
    	// Use get_term to get a WP_Term object from wether WP_Term object or term_id
    	$termobj = get_term($term);
    	if ( ! in_array( $termobj->slug, $data ) ) {
    		$new_terms[] = $term;
    	}
    }

    Maybe you’ll be interested to include that in your next version.

    Hope it helps.

    And thank you for your usefull plugin!

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WMEric

    (@wmeric)

    I dont know why I dont get notifications to these.

    But thank you for the tip. I will add it and push an update.

    Thanks

    Eric

    Hello,

    we found the same issue in our debug.log.

    [17-Nov-2022 13:24:45 UTC] PHP Warning: Attempt to read property "slug" on int in /var/www/wp-content/plugins/hide-categories-on-shop-page/wc-hide-categories-on-shop-page.php on line 147

    Do you plan to fix it? It’s 5 months ago and we can’t find any updates.

    Thank you!

    Plugin Author WMEric

    (@wmeric)

    Released an updated file that fixes this. v1.1.2

    Thanks

    Thank you. We’ve updated the plugin and now the warning has just changed from “null” to “int” 🙁

    [25-Nov-2022 05:49:39 UTC] PHP Warning:  Attempt to read property "slug" on int in /var/www/wp-content/plugins/hide-categories-on-shop-page/wc-hide-categories-on-shop-page.php on line 150
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error in log about null slug’ is closed to new replies.