• Resolved James

    (@outrankjames)


    When running the build of the xml feed – we keep getting the following errors over and over agian. Checked for null terms and null slugs, null name, but nothing in the database. Rolling back works.

    Warning: Attempt to read property "name" on bool in /home/nginx/domains/web/public/wp-content/plugins/woo-product-feed-pro/classes/class-get-products.php on line 2349

    PHP Warning:  Attempt to read property "slug" on null in /home/nginx/domains/web/public/wp-includes/taxonomy.php on line 4695

    Warning: Attempt to read property "slug" on null in /home/nginx/domains/web/public/wp-includes/taxonomy.php on line 4695

    PHP Warning:  Attempt to read property "name" on bool in /home/nginx/domains/web/public/wp-content/plugins/woo-product-feed-pro/classes/class-get-products.php on line 2349

    Suspect code here:

    $parent_categories = get_ancestors( $product_cat->term_id, 'product_cat' );
    foreach ( $parent_categories as $category_id ) {
    $parent = get_term_by( 'id', $category_id, 'product_cat' );
    $parent_name = $parent->name; // <-- warning here when $parent === false
    }

    $catlink[] = get_term_link( $value, 'product_cat' ); // <-- can warn when term missing

    Possible fix

    $product_cat = get_term( (int) $value, 'product_cat' );

    if ( $product_cat && ! is_wp_error( $product_cat ) ) {
    // existing code that builds $category_path_* … (leave as-is)

    $parent_categories = get_ancestors( (int) $product_cat->term_id, 'product_cat' );
    if ( is_array( $parent_categories ) && ! empty( $parent_categories ) ) {
    foreach ( $parent_categories as $category_id ) {
    $parent = get_term_by( 'id', (int) $category_id, 'product_cat' );
    if ( $parent && ! is_wp_error( $parent ) ) {
    $parent_name = $parent->name; // safe now
    }
    }
    }

    if ( isset( $product_cat->name ) ) {
    $catname[] = $product_cat->name;
    $term_link = get_term_link( (int) $value, 'product_cat' );
    if ( ! is_wp_error( $term_link ) ) {
    $catlink[] = $term_link;
    }
    }
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘PHP Errors In Latest Version’ is closed to new replies.