Uncaught Error: Call to a member function get_meta() on bool
-
A customer using this plugin received the following error report:
Huidige plugin: PostNL for WooCommerce (versie 5.4.1)
PHP versie 8.0.30Foutdetails
===========
Een fout van het type E_ERROR werd veroorzaakt op regelnummer 738 van het bestand wp-content/plugins/woo-postnl/src/Utils.php. Foutmelding: Uncaught Error: Call to a member function get_meta() on bool in wp-content/plugins/woo-postnl/src/Utils.php:738
Stack trace:
#0 wp-content/plugins/woo-postnl/src/Utils.php(715): PostNLWooCommerce\Utils::check_products_for_letterbox()
#1 wp-content/plugins/woo-postnl/src/Order/OrdersList.php(139): PostNLWooCommerce\Utils::is_eligible_auto_letterbox()
#2 wp-includes/class-wp-hook.php(324): PostNLWooCommerce\Order\OrdersList->add_order_delivery_date_column_content()
#3 wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#4 wp-includes/plugin.php(517): WP_Hook->do_action()
#5 wp-admin/includes/class-wp-posts-list-table.php(1398): do_action()
#6 wp-admin/includes/class-wp-list-table.php(1796): WP_Posts_List_Table->column_default()
#7 wp-admin/includes/class-wp-posts-list-table.php(1432): WP_List_Table->single_row_columns()
#8 wp-admin/includes/class-wp-posts-list-table.php(834): WP_Posts_List_Table->single_row()
#9 wp-admin/includes/class-wp-posts-list-table.php(810): WP_Posts_List_Table->_display_rows()
#10 wp-admin/includes/class-wp-list-table.php(1706): WP_Posts_List_Table->display_rows()
#11 wp-admin/includes/class-wp-list-table.php(1633): WP_List_Table->display_rows_or_placeholder()
#12 wp-admin/edit.php(503): WP_List_Table->display()
#13 {main}
thrownThe implementation on the following lines is not good:
https://plugins.trac.www.ads-software.com/browser/woo-postnl/tags/5.4.1/src/Utils.php#L737foreach ( $products as $item_id => $item ) {
$product = wc_get_product( $item['product_id'] ?? $item->get_product_id() );
$is_letterbox_product = $product->get_meta( Product\Single::LETTERBOX_PARCEL );You have forgotten that
wc_get_product( … )
does not necessarily always return a product, but can also returnnull
orfalse
.Please resolve this quickly, these are signals that the quality of this plugin is really insufficient. By using tools such as PHPStan, such issues can be easily dealt with.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.