PHP Warning
-
Several sites have following in the error log
[13-Mar-2020 09:03:07 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-content/plugins/facebook-for-woocommerce/includes/fbproductfeed.php on line 209
Seems to be a daily event.
-
Hi @iarovuo,
Thanks so much for your question! I’ve not seen this occur in my local testing, though are developers are always looking to squash bugs where possible. To do so, I’ll need a bit more information to see if I can narrow this down for them.
Looking at the code, it seems as though the feed sync is trying to loop over a variable product. For some reason, the $variants_for_group is not valid for the foreach loop. Unfortunately, there isn’t anywhere we can add logging for this easily without adjusting the plugin code.
If you wouldn’t mind, it would be great if you could raise a support request via our support form so that we could contact you directly. If we could then gain temporary FTP access to the site, it would allow us to add some additional logging directly to try and get to the bottom of this.
Would this be possible do you think?
Cheers!
Simon.
Thanks Simon,
I see there is new version available, let me follow up on this and see if the latest version fixed it.
Hey @iarovuo,
Sure thing! I’m not aware of any particular fix added for this, though we are changing and (hopefully!) improving the code all the time as we go on!
If the issue is still present, please do reach out via our support form so that we can do some more direct testing.
Cheers,
Simon.
I am getting same error
facebook-for-woocommerce/includes/fbproductfeed.php on line 209PHP message: PHP Warning: Invalid argument supplied for foreach() in
/facebook-for-woocommerce/includes/fbproductfeed.php on line 220PHP message: PHP Warning: Invalid argument supplied for foreach() in
Hi @skyverge, Simon,
Confirmed. The version 1.10.2 did not solve this.
– I will implement some debugging into the code to see what the variables hold
– Will PM the findings.Hi @skyverge, Simon,
In our case, this is related to PimWick Gift Cards
https://www.pimwick.com/gift-cards/variants_for_group variable is empty/null. Please see debug log below;
[20-Mar-2020 16:06:31 UTC] parent_id: 7922 [20-Mar-2020 16:06:31 UTC] parent_product: WC_Facebook_Product Object ( [id] => 7922 [fb_description] => [woo_product] => WC_Product_PW_Gift_Card Object ( [children:protected] => [visible_children:protected] => [variation_attributes:protected] => [object_type:protected] => product [post_type:protected] => product [cache_group:protected] => products [data:protected] => Array ( [name] => Klas Squared - Gift Card [slug] => klas-squared-gift-card [date_created] => WC_DateTime Object ( [utc_offset:protected] => 0 [date] => 2017-07-10 20:56:51.000000 [timezone_type] => 3 [timezone] => America/Toronto ) [date_modified] => WC_DateTime Object ( [utc_offset:protected] => 0 [date] => 2019-11-14 20:47:34.000000 [timezone_type] => 3 [timezone] => America/Toronto ) [status] => publish [featured] => [catalog_visibility] => visible [description] => [short_description] => [sku] => [price] => 25 [regular_price] => [sale_price] => [date_on_sale_from] => [date_on_sale_to] => [total_sales] => 1 [tax_status] => none [tax_class] => [manage_stock] => [stock_quantity] => [stock_status] => instock [backorders] => no [low_stock_amount] => [sold_individually] => [weight] => [length] => [width] => [height] => [upsell_ids] => Array ( ) [cross_sell_ids] => Array ( ) [parent_id] => 0 [reviews_allowed] => 1 [purchase_note] => [attributes] => Array ( [gift-card-amount] => WC_Product_Attribute Object ( [data:protected] => Array ( [id] => 0 [name] => Gift Card Amount [options] => Array ( [0] => $25 [1] => $50 [2] => $100 [3] => $200 ) [position] => 0 [visible] => 1 [variation] => 1 ) ) ) [default_attributes] => Array ( ) [menu_order] => 0 [post_password] => [virtual] => [downloadable] => [category_ids] => Array ( [0] => 149 [1] => 233 ) [tag_ids] => Array ( ) [shipping_class_id] => 0 [downloads] => Array ( ) [image_id] => 7926 [gallery_image_ids] => Array ( ) [download_limit] => -1 [download_expiry] => -1 [rating_counts] => Array ( ) [average_rating] => 0 [review_count] => 0 ) [supports:protected] => Array ( ) [id:protected] => 7922 [changes:protected] => Array ( ) [object_read:protected] => 1 [extra_data:protected] => Array ( ) [default_data:protected] => Array ( [name] => [slug] => [date_created] => [date_modified] => [status] => [featured] => [catalog_visibility] => visible [description] => [short_description] => [sku] => [price] => [regular_price] => [sale_price] => [date_on_sale_from] => [date_on_sale_to] => [total_sales] => 0 [tax_status] => taxable [tax_class] => [manage_stock] => [stock_quantity] => [stock_status] => instock [backorders] => no [low_stock_amount] => [sold_individually] => [weight] => [length] => [width] => [height] => [upsell_ids] => Array ( ) [cross_sell_ids] => Array ( ) [parent_id] => 0 [reviews_allowed] => 1 [purchase_note] => [attributes] => Array ( ) [default_attributes] => Array ( ) [menu_order] => 0 [post_password] => [virtual] => [downloadable] => [category_ids] => Array ( ) [tag_ids] => Array ( ) [shipping_class_id] => 0 [downloads] => Array ( ) [image_id] => [gallery_image_ids] => Array ( ) [download_limit] => -1 [download_expiry] => -1 [rating_counts] => Array ( ) [average_rating] => 0 [review_count] => 0 ) [data_store:protected] => WC_Data_Store Object ( [instance:WC_Data_Store:private] => WC_Product_Variable_Data_Store_CPT Object ( [prices_array:protected] => Array ( ) [internal_meta_keys:protected] => Array ( [0] => _visibility [1] => _sku [2] => _price [3] => _regular_price [4] => _sale_price [5] => _sale_price_dates_from [6] => _sale_price_dates_to [7] => total_sales [8] => _tax_status [9] => _tax_class [10] => _manage_stock [11] => _stock [12] => _stock_status [13] => _backorders [14] => _low_stock_amount [15] => _sold_individually [16] => _weight [17] => _length [18] => _width [19] => _height [20] => _upsell_ids [21] => _crosssell_ids [22] => _purchase_note [23] => _default_attributes [24] => _product_attributes [25] => _virtual [26] => _downloadable [27] => _download_limit [28] => _download_expiry [29] => _featured [30] => _downloadable_files [31] => _wc_rating_count [32] => _wc_average_rating [33] => _wc_review_count [34] => _variation_description [35] => _thumbnail_id [36] => _file_paths [37] => _product_image_gallery [38] => _product_version [39] => _wp_old_slug [40] => _edit_last [41] => _edit_lock ) [must_exist_meta_keys:protected] => Array ( [0] => _tax_class ) [extra_data_saved:protected] => [updated_props:protected] => Array ( ) [meta_type:protected] => post [object_id_field_for_meta:protected] => ) [stores:WC_Data_Store:private] => Array ( [coupon] => WC_Coupon_Data_Store_CPT [customer] => WC_Customer_Data_Store [customer-download] => WC_Customer_Download_Data_Store [customer-download-log] => WC_Customer_Download_Log_Data_Store [customer-session] => WC_Customer_Data_Store_Session [order] => WC_Order_Data_Store_CPT [order-refund] => WC_Order_Refund_Data_Store_CPT [order-item] => WC_Order_Item_Data_Store [order-item-coupon] => WC_Order_Item_Coupon_Data_Store [order-item-fee] => WC_Order_Item_Fee_Data_Store [order-item-product] => WC_Order_Item_Product_Data_Store [order-item-shipping] => WC_Order_Item_Shipping_Data_Store [order-item-tax] => WC_Order_Item_Tax_Data_Store [payment-token] => WC_Payment_Token_Data_Store [product] => WC_Product_Data_Store_CPT [product-grouped] => WC_Product_Grouped_Data_Store_CPT [product-variable] => WC_Product_Variable_Data_Store_CPT [product-variation] => WC_Product_Variation_Data_Store_CPT [shipping-zone] => WC_Shipping_Zone_Data_Store [webhook] => WC_Webhook_Data_Store [report-revenue-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore [report-orders] => Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore [report-orders-stats] => Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore [report-products] => Automattic\WooCommerce\Admin\API\Reports\Products\DataStore [report-variations] => Automattic\WooCommerce\Admin\API\Reports\Variations\DataStore [report-products-stats] => Automattic\WooCommerce\Admin\API\Reports\Products\Stats\DataStore [report-categories] => Automattic\WooCommerce\Admin\API\Reports\Categories\DataStore [report-taxes] => Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore [report-taxes-stats] => Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore [report-coupons] => Automattic\WooCommerce\Admin\API\Reports\Coupons\DataStore [report-coupons-stats] => Automattic\WooCommerce\Admin\API\Reports\Coupons\Stats\DataStore [report-downloads] => Automattic\WooCommerce\Admin\API\Reports\Downloads\DataStore [report-downloads-stats] => Automattic\WooCommerce\Admin\API\Reports\Downloads\Stats\DataStore [admin-note] => Automattic\WooCommerce\Admin\Notes\DataStore [report-customers] => Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore [report-customers-stats] => Automattic\WooCommerce\Admin\API\Reports\Customers\Stats\DataStore [report-stock-stats] => Automattic\WooCommerce\Admin\API\Reports\Stock\Stats\DataStore [product-pw-gift-card] => WC_Product_Variable_Data_Store_CPT [order-item-pw_gift_card] => WC_Order_Item_PW_Gift_Card_Data_Store [product-tb-placeholder] => ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder_Data_Store_CPT [product-tb-placeholder-variation] => ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder_Data_Store_CPT ) [current_class_name:WC_Data_Store:private] => WC_Product_Variable_Data_Store_CPT [object_type:WC_Data_Store:private] => product-pw-gift-card ) [meta_data:protected] => ) [gallery_urls] => Array ( ) [fb_use_parent_image] => [fb_price] => 0 [main_description] => [sync_short_description] => [fb_visibility] => 1 ) [20-Mar-2020 16:06:31 UTC] variants_for_group: [20-Mar-2020 16:06:31 UTC] [20-Mar-2020 16:06:31 UTC] PHP Warning: Invalid argument supplied for foreach() in /wp-content/plugins/facebook-for-woocommerce/includes/fbproductfeed.php on line 209
Hey @iarovuo,
Thanks so much for sharing that! It seems as though the variants_for_group is returning null based on the Gift Card product. I can’t quite see where this is failing based on the logging, and it looks like the plugin is a paid-for plugin so I’m not able to run further tests locally.
We could certainly harden the code in this area to prevent throwing an error though, so I will raise this to my developers!
If you’d like to gather a bit more debugging, that would also be super helpful. I’d be interested in seeing whereabouts the null is created from within the prepare_variants_for_group function.
Is it hitting one of the error statements, or is it returning an empty array?
Cheers!
- The topic ‘PHP Warning’ is closed to new replies.