PHP Warning: Invalid argument blocks ProductCategories.php on line 182
-
I am seeing php error in log:
PHP Warning: Invalid argument supplied for foreach() in /var/web/site/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/BlockTypes/ProductCategories.php on line 182This appears to be line 182: foreach ( $tree as $category ) {
and these are 183-186:
if ( ! empty( $categories_by_parent[ ‘cat-‘ . $category->term_id ] ) ) {
$category->children = $this->fill_category_children( $categories_by_parent[ ‘cat-‘ . $category->term_id ], $categories_by_parent );
}
}This is the whole section:
/** * Build hierarchical tree of categories. * * @param array $categories List of terms. * @return array */ protected function build_category_tree( $categories ) { $categories_by_parent = []; foreach ( $categories as $category ) { if ( ! isset( $categories_by_parent[ 'cat-' . $category->parent ] ) ) { $categories_by_parent[ 'cat-' . $category->parent ] = []; } $categories_by_parent[ 'cat-' . $category->parent ][] = $category; } $tree = $categories_by_parent['cat-0']; unset( $categories_by_parent['cat-0'] ); foreach ( $tree as $category ) { if ( ! empty( $categories_by_parent[ 'cat-' . $category->term_id ] ) ) { $category->children = $this->fill_category_children( $categories_by_parent[ 'cat-' . $category->term_id ], $categories_by_parent ); } } return $tree; }
I couldn’t find any mention of this in the forum. Would appreciate any tips for fixing. I’m not able to follow the code enough to understand what is wrong with this that is causing the warning. But the site appears to be functioning properly so perhaps this is something that I can ignore? I’m not using blocks.
The page I need help with: [log in to see the link]
-
Hi @burnstuff
The code seems fine! To help us diagnose it better, could you please share a copy of your site’s System Status?
You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.?
Once you’ve done that, paste it here in your response.
All the best,
Hi @burnstuff,
This topic has been inactive for a while, so I’m marking it as “resolved”.
We’ll be here if you need additional assistance.
Sorry, I’ve been away. Thank you for your reply and offer to assist. Not sure if this is related, but I also started seeing this error as well:\
[23-Mar-2022 12:38:58 UTC] PHP Warning: Creating default object from empty value in /var/web/site/public_html/wp-content/plugins/woocommerce/includes/admin/helper/class-wc-helper-updater.php on line 81Here’s my system status:
### WordPress Environment ### WordPress address (URL): https://chnevents.org Site address (URL): https://chnevents.org WC Version: 6.3.1 REST API Version: ? 6.3.1 WC Blocks Version: ? 6.9.0 Action Scheduler Version: ? 3.4.0 WC Admin Version: ? 3.2.1 Log Directory Writable: ? WP Version: 5.9.2 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ? Language: en_US External object cache: ? ### Server Environment ### Server Info: nginx/1.20.1 PHP Version: 7.4.28 PHP Post Max Size: 128 MB PHP Time Limit: 300 PHP Max Input Vars: 3000 cURL Version: 7.58.0 OpenSSL/1.1.1 SUHOSIN Installed: – MySQL Version: 5.5.5-10.3.34-MariaDB-1:10.3.34+maria~bionic Max Upload Size: 128 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 6.3.1 WC Database Prefix: whnpu_ Total Database Size: 63.03MB Database Data Size: 46.86MB Database Index Size: 16.17MB whnpu_woocommerce_sessions: Data: 4.09MB + Index: 0.21MB + Engine MyISAM whnpu_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_woocommerce_order_items: Data: 0.04MB + Index: 0.02MB + Engine MyISAM whnpu_woocommerce_order_itemmeta: Data: 0.24MB + Index: 0.19MB + Engine MyISAM whnpu_woocommerce_tax_rates: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_woocommerce_payment_tokens: Data: 0.01MB + Index: 0.01MB + Engine MyISAM whnpu_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.02MB + Engine MyISAM whnpu_woocommerce_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_actionscheduler_actions: Data: 1.29MB + Index: 0.62MB + Engine MyISAM whnpu_actionscheduler_claims: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_actionscheduler_groups: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_actionscheduler_logs: Data: 0.90MB + Index: 0.63MB + Engine MyISAM whnpu_aiowps_events: Data: 0.27MB + Index: 0.04MB + Engine MyISAM whnpu_aiowps_failed_logins: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_aiowps_global_meta: Data: 2.95MB + Index: 0.00MB + Engine MyISAM whnpu_aiowps_login_activity: Data: 0.01MB + Index: 0.00MB + Engine MyISAM whnpu_aiowps_login_lockdown: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_aiowps_permanent_block: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_auction_bids: Data: 0.11MB + Index: 0.24MB + Engine MyISAM whnpu_commentmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_comments: Data: 0.18MB + Index: 0.09MB + Engine MyISAM whnpu_csshero: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_defender_audit_log: Data: 2.52MB + Index: 2.44MB + Engine InnoDB whnpu_defender_email_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB whnpu_defender_lockout: Data: 0.56MB + Index: 0.85MB + Engine MyISAM whnpu_defender_lockout_log: Data: 0.39MB + Index: 0.08MB + Engine MyISAM whnpu_defender_scan: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_defender_scan_item: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_et_social_stats: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_frmt_form_entry: Data: 0.00MB + Index: 0.02MB + Engine MyISAM whnpu_frmt_form_entry_meta: Data: 0.16MB + Index: 0.07MB + Engine MyISAM whnpu_frmt_form_views: Data: 0.03MB + Index: 0.06MB + Engine MyISAM whnpu_gf_addon_feed: Data: 0.01MB + Index: 0.00MB + Engine MyISAM whnpu_gf_addon_payment_callback: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_gf_addon_payment_transaction: Data: 0.02MB + Index: 0.02MB + Engine MyISAM whnpu_gf_draft_submissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_gf_entry: Data: 0.13MB + Index: 0.02MB + Engine MyISAM whnpu_gf_entry_meta: Data: 0.68MB + Index: 0.46MB + Engine MyISAM whnpu_gf_entry_notes: Data: 0.10MB + Index: 0.03MB + Engine MyISAM whnpu_gf_form: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_gf_form_meta: Data: 0.42MB + Index: 0.00MB + Engine MyISAM whnpu_gf_form_revisions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_gf_form_view: Data: 0.09MB + Index: 0.05MB + Engine MyISAM whnpu_give_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_give_comments: Data: 0.05MB + Index: 0.00MB + Engine InnoDB whnpu_give_donationmeta: Data: 0.08MB + Index: 0.03MB + Engine InnoDB whnpu_give_donormeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_give_donors: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_give_formmeta: Data: 0.09MB + Index: 0.08MB + Engine InnoDB whnpu_give_funds: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_give_fund_form_relationship: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_give_log: Data: 1.52MB + Index: 0.20MB + Engine InnoDB whnpu_give_migrations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_give_revenue: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_give_sequential_ordering: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_give_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB whnpu_give_subscriptionmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_give_subscriptions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB whnpu_gpui_sequence: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_ip_geo_block_cache: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_ip_geo_block_logs: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_ip_geo_block_stat: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_links: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_login_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_options: Data: 6.09MB + Index: 0.13MB + Engine MyISAM whnpu_pantheon_sessions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_pmxe_exports: Data: 0.11MB + Index: 0.00MB + Engine InnoDB whnpu_pmxe_google_cats: Data: 0.39MB + Index: 0.00MB + Engine InnoDB whnpu_pmxe_posts: Data: 0.08MB + Index: 0.00MB + Engine InnoDB whnpu_pmxe_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_hash: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_images: Data: 0.06MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_imports: Data: 0.06MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_posts: Data: 0.09MB + Index: 0.00MB + Engine InnoDB whnpu_pmxi_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_postmeta: Data: 8.72MB + Index: 2.00MB + Engine MyISAM whnpu_posts: Data: 6.45MB + Index: 3.29MB + Engine MyISAM whnpu_rg_form: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_form_meta: Data: 0.35MB + Index: 0.00MB + Engine MyISAM whnpu_rg_form_view: Data: 0.03MB + Index: 0.02MB + Engine MyISAM whnpu_rg_incomplete_submissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_lead: Data: 0.06MB + Index: 0.01MB + Engine MyISAM whnpu_rg_lead_detail: Data: 0.22MB + Index: 0.33MB + Engine MyISAM whnpu_rg_lead_detail_long: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_lead_meta: Data: 0.16MB + Index: 0.05MB + Engine MyISAM whnpu_rg_lead_notes: Data: 0.04MB + Index: 0.02MB + Engine MyISAM whnpu_rg_stripe: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_stripe_events: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_stripe_transaction: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_rg_zapier: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_signups: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_smush_dir_images: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_termmeta: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_terms: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_term_relationships: Data: 0.06MB + Index: 0.14MB + Engine MyISAM whnpu_term_taxonomy: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_usermeta: Data: 1.01MB + Index: 0.61MB + Engine MyISAM whnpu_users: Data: 0.06MB + Index: 0.06MB + Engine MyISAM whnpu_wc_admin_notes: Data: 0.03MB + Index: 0.00MB + Engine MyISAM whnpu_wc_admin_note_actions: Data: 0.01MB + Index: 0.01MB + Engine MyISAM whnpu_wc_category_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_wc_customer_lookup: Data: 0.04MB + Index: 0.04MB + Engine MyISAM whnpu_wc_download_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_wc_order_coupon_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_wc_order_product_lookup: Data: 0.04MB + Index: 0.04MB + Engine MyISAM whnpu_wc_order_stats: Data: 0.02MB + Index: 0.02MB + Engine MyISAM whnpu_wc_order_tax_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_wc_product_meta_lookup: Data: 0.05MB + Index: 0.08MB + Engine MyISAM whnpu_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB whnpu_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_wc_tax_rate_classes: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_wc_webhooks: Data: 0.00MB + Index: 0.00MB + Engine MyISAM whnpu_wfpklist_template_data: Data: 0.02MB + Index: 0.00MB + Engine InnoDB whnpu_wsal_metadata: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_wsal_occurrences: Data: 0.02MB + Index: 0.03MB + Engine InnoDB whnpu_yoast_indexable: Data: 4.99MB + Index: 2.23MB + Engine MyISAM whnpu_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.07MB + Engine MyISAM whnpu_yoast_migrations: Data: 0.00MB + Index: 0.01MB + Engine MyISAM whnpu_yoast_primary_term: Data: 0.01MB + Index: 0.02MB + Engine MyISAM whnpu_yoast_seo_links: Data: 0.12MB + Index: 0.03MB + Engine MyISAM whnpu_yoast_seo_meta: Data: 0.01MB + Index: 0.02MB + Engine MyISAM ### Post Type Counts ### attachment: 898 custom_css: 2 et_body_layout: 5 et_header_layout: 1 et_pb_layout: 26 et_template: 13 et_theme_builder: 1 forminator_forms: 2 give_forms: 1 give_payment: 10 give_pdf_template: 1 nav_menu_item: 32 oembed_cache: 25356 page: 32 post: 1 product: 498 revision: 233 shop_order: 270 shop_order_refund: 2 tablepress_table: 1 user_request: 1 wdf_scan: 1 wdf_scan_item: 6 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (42) ### User Switching in Admin Bar: by wpexpertsio – 1.4 Bulk remove posts from category: by MasterNs – 3.2.1 Classic Editor: by WordPress Contributors – 1.6.2 Elegant Themes Updater: by Elegant Themes – 1.1 Flexible Checkout Fields: by WP Desk – 3.2.2 Forminator Pro: by WPMU DEV – 1.15.12 Give - Email Reports: by GiveWP – 1.1.4 Give - Fee Recovery: by GiveWP – 1.9.7 Give - Form Field Manager: by GiveWP – 2.0.3 Give - Funds and Designations: by GiveWP – 1.1.0 Give - Google Analytics Donation Tracking: by GiveWP – 1.2.5 Give - Manual Donations: by GiveWP – 1.6.0 Give - PDF Receipts: by GiveWP – 2.3.13 Give - Per Form Gateways: by GiveWP – 1.0.2 Receipt Attachments for GiveWP: by GiveWP – 1.1.3 Give - Recurring Donations: by GiveWP – 1.15.0 Give - Stripe Gateway: by GiveWP – 2.4.1 Give - Tributes: by GiveWP – 1.5.9 Give - Donation Plugin: by GiveWP – 2.19.5 IgniteWoo Updater: by IgniteWoo.com – 3.0.3 Members: by MemberPress – 3.1.7 Monarch Plugin: by Elegant Themes – 1.4.14 Nav Menu Roles: by Kathy Darling – 2.1.0 Order Tip for WooCommerce: by Adrian Emil Tudorache – 1.2.2 Per-Form Confirmation Pages for GiveWP: by GiveWP – 1.1.1 WooCommerce PDF Invoices, Packing Slips, Delivery Notes and Shipping Labels: by WebToffee – 2.9.0 Redirect After Login: by marcelotorres – 0.1.9 Return to shop button custom code: by John Foster - AuctionZoom – 1.0 Send E-mails with Mandrill: by Miller Media ( Matt Miller ) – 1.2.13 Snapshot Pro: by WPMU DEV – 4.7.1 Title Remover: by WPGurus – 1.2.1 User Switching: by John Blackbourn & contributors – 1.5.8 Woocommerce autocomplete checkout address: by Acespritech Solutions Pvt. Ltd. – 1.1.0 Checkout Field Editor for WooCommerce: by ThemeHigh – 1.5.3 WooCommerce Auctions Pro: by IgniteWoo.com – 3.7.11 WooCommerce Stripe Gateway: by WooCommerce – 6.3.0 WP All Import - WooCommerce Add-On: by Soflyy – 1.5.1 WooCommerce: by Automattic – 6.3.1 Yoast SEO: by Team Yoast – 18.4.1 WP All Import: by Soflyy – 3.6.6 WP BrowserUpdate: by Marco Steinbrecher – 4.3.6 WPMU DEV Dashboard: by WPMU DEV – 4.11.10 ### Inactive Plugins (11) ### CAPTCHA 4WP: by WP White Security – 7.0.6.1 Change Password Protected Message: by pipdig – 2.2.0 Defender Pro: by WPMU DEV – 2.8.0 Give - Donation Modules for Divi: by GiveWP – 1.0.3 Gravity Forms: by Gravity Forms – 2.4.22 Health Check & Troubleshooting: by The www.remarpro.com community – 1.4.5 Hummingbird Pro: by WPMU DEV – 3.3.2 Smush Pro: by WPMU DEV – 3.9.8 UpdraftPlus - Backup/Restore: by UpdraftPlus.Com DavidAnderson – 1.22.11 WP All Export: by Soflyy – 1.3.4 WP All Export - User Export Add-On: by Soflyy – 1.0.0 ### Dropin Plugins (1) ### object-cache.php: WPMU DEV Hummingbird Object Cache ### Must Use Plugins (3) ### disable_plugins_on_forminator_pages.php: by – Health Check Troubleshooting Mode: by – 1.7.2 WPMU DEV Hosting: by WPMU DEV – 0.1 ### Settings ### API Enabled: – Force SSL: – Currency: CAD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) ignitewoo_auction (ignitewoo_auction) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – ### WC Pages ### Shop base: #7862 - /shop/ Cart: #7863 - /cart/ Checkout: #7864 - /checkout/ My account: #7865 - /my-account/ Terms and conditions: #8257 - /how-to-bid/ ### Theme ### Name: Divi Child Theme Version: (update to version 0 is available) Author URL: Child Theme: ? Parent Theme Name: Divi Parent Theme Version: 4.15.1 Parent Theme Author URL: https://www.elegantthemes.com WooCommerce Support: ? ### Templates ### Overrides: divi-child-theme/woocommerce/emails/customer-completed-order.php ### Action Scheduler ### Complete: 5,257 Oldest: 2022-02-25 16:10:04 -0800 Newest: 2022-03-26 10:41:05 -0700 Pending: 2 Oldest: 2022-03-26 10:41:20 -0700 Newest: 2022-03-26 10:42:06 -0700 Canceled: 15 Oldest: 2022-03-17 16:32:32 -0700 Newest: 2022-03-25 21:03:28 -0700 ### Status report information ### Generated at: 2022-03-26 10:41:26 -07:00
Hello,
Thanks for sending this information. Is possible there is a conflict with the theme or any plugin?
You can switch your theme to Storefront temporarily, disable all plugins except for WooCommerce, and check the issue again.
After that make sure to enable plugins one by one until you find the origin/cause of the issue, to learn more please check How to do a conflict test.
Let us know if this makes a difference.
- The topic ‘PHP Warning: Invalid argument blocks ProductCategories.php on line 182’ is closed to new replies.