Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:276 #40393

Closed
3 of 5 tasks
ntborg opened this issue Sep 25, 2023 · 4 comments · Fixed by #40395
Labels
priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton type: bug The issue is a confirmed bug. type: community contribution

Comments

@ntborg
Copy link

ntborg commented Sep 25, 2023

Prerequisites

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:276 Stack trace: #0 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(219): WC_Regenerate_Images::get_full_size_image_dimensions(1363) #1 /var/www/html/wp-includes/class-wp-hook.php(308): WC_Regenerate_Images::maybe_resize_image(Array, 1363, 'woocommerce_sin...', false) #2 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #3 /var/www/html/wp-includes/media.php(992): apply_filters('wp_get_attachme...', Array, 1363, 'woocommerce_sin...', false) #4 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/api/api-helpers.php(3135): wp_get_attachment_image_src(1363, 'woocommerce_sin...') #5 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-image.php(383): acf_get_attachment(Object(WP_Post)) #6 /var/www/html/wp-includes/class-wp-hook.php(308): acf_field_image->format_value(1363, 'options', Array) #7 /var/www/html/wp-includes/plugin.php(256): WP_Hook->apply_filters('1363', Array) #8 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-hook-functions.php(109): apply_filters_ref_array('acf/format_valu...', Array) #9 /var/www/html/wp-includes/class-wp-hook.php(308): acf_apply_hook_variations('1363', 'options', Array) #10 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters('1363', Array) #11 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php(172): apply_filters('acf/format_valu...', '1363', 'options', Array) #12 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/api/api-template.php(51): acf_format_value('1363', 'options', Array) #13 /var/www/html/wp-content/themes/labelvier/template-parts/content-header.php(15): get_field('featured_image...', 'options') #14 /var/www/html/wp-includes/template.php(785): require('/var/www/html/w...') #15 /var/www/html/wp-includes/template.php(718): load_template('/var/www/html/w...', false, Array) #16 /var/www/html/wp-includes/general-template.php(204): locate_template(Array, true, false, Array) #17 /var/www/html/wp-content/themes/labelvier/header.php(28): get_template_part('template-parts/...', 'header') #18 /var/www/html/wp-includes/template.php(783): require_once('/var/www/html/w...') #19 /var/www/html/wp-includes/template.php(718): load_template('/var/www/html/w...', true, Array) #20 /var/www/html/wp-includes/general-template.php(48): locate_template(Array, true, true, Array) #21 /var/www/html/wp-content/themes/labelvier/front-page.php(15): get_header() #22 /var/www/html/wp-includes/template-loader.php(106): include('/var/www/html/w...') #23 /var/www/html/wp-blog-header.php(19): require_once('/var/www/html/w...') #24 /var/www/html/index.php(17): require('/var/www/html/w...') #25 {main} thrown in /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php on line 276

Expected behavior

Not giving a fatal error :)

Actual behavior

Fatal error shutting down frontend and backend.

Steps to reproduce

Works in combination with ACF (pro).

  • I have an ACF field for a default featured image in 'options'
  • In the template referring to this field get_field('default_featured_image', 'options')
  • For my default featured image, when I select an image that does appear in the media library, but is not physically present in the uploadsmap (like on my local dev environment) - this fatal error will occur. It will resolve selecting another image that is present.

WordPress Environment

`

WordPress Environment

WordPress address (URL): http://localhost
Site address (URL): http://localhost
WC Version: 8.1.1
REST API Version: ✔ 8.1.1
WC Blocks Version: ✔ 10.9.3
Action Scheduler Version: ✔ 3.6.2
Log Directory Writable: ✔
WP Version: 6.3.1
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: ✔
WP Cron: –
Language: nl_NL
External object cache: –

Server Environment

Server Info: Apache/2.4.57 (Debian)
PHP Version: 8.1.23
PHP Post Max Size: 24 MB
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.88.1
OpenSSL/3.0.9

SUHOSIN Installed: –
MySQL Version: 10.11.5-MariaDB-1:10.11.5+maria~ubu2204
Max Upload Size: 16 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ❌ Je server heeft de klasse SoapClient niet ingeschakeld - sommige gateway plugins die SOAP gebruiken
werken mogelijk niet zoals verwacht.

DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 7.9.0
WC Database Prefix: wp_
Totale database grootte: 29.92MB
Database gegevens grootte: 23.99MB
Database index grootte: 5.93MB
wp_woocommerce_sessions: Data: 0.06MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_order_items: Data: 0.06MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_order_itemmeta: Data: 0.38MB + Index: 0.31MB + Engine InnoDB
wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_actions: Data: 0.02MB + Index: 0.13MB + Engine InnoDB
wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_facetwp_index: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_gf_addon_feed: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_gf_entry: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_gf_entry_meta: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_gf_entry_notes: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_gf_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_gf_form_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_gf_form_revisions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_gf_form_view: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_gf_rest_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mollie_pending_payment: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_options: Data: 3.08MB + Index: 0.09MB + Engine InnoDB
wp_postmeta: Data: 8.52MB + Index: 3.03MB + Engine InnoDB
wp_posts: Data: 3.52MB + Index: 0.23MB + Engine InnoDB
wp_post_smtp_logmeta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_post_smtp_logs: Data: 6.52MB + Index: 0.00MB + Engine InnoDB
wp_signups: Data: 0.05MB + Index: 0.06MB + Engine InnoDB
wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_usermeta: Data: 0.33MB + Index: 0.19MB + Engine InnoDB
wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wcpdf_credit_note_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcpdf_invoice_number_2021: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcpdf_packing_slip_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wcpdf_proforma_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
wp_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_product_lookup: Data: 0.08MB + Index: 0.06MB + Engine InnoDB
wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_yoast_indexable: Data: 0.11MB + Index: 0.09MB + Engine InnoDB
wp_yoast_indexable_hierarchy: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB

Post Type Counts

acf-field: 38
acf-field-group: 7
attachment: 94
customize_changeset: 5
nav_menu_item: 6
page: 18
post: 116
postman_sent_mail: 250
product: 21
revision: 288
shop_coupon: 3
shop_order: 115

Security

Secure connection (HTTPS): ❌
Je winkel gebruikt geen HTTPS. Leer meer over HTTPS en SSL-certificaten.
Hide errors from visitors: ❌Foutmeldingen zouden niet getoond moeten worden aan bezoekers.

Active Plugins (8)

Gravity Forms: door Gravity Forms – 2.6.3
Advanced Custom Fields PRO: door WP Engine – 6.2.1.1
Classic Widgets: door WordPress Contributors – 0.3
FacetWP: door FacetWP
LLC – 4.2.5

Label Vier Extras: door Label Vier – 1.6.8
Post SMTP: door Post SMTP – 2.6.0
WooCommerce: door Automattic – 8.1.1
Yoast SEO: door Team Yoast – 21.2

Inactive Plugins (11)

Fake Pay For WooCommerce: door Anthony Graddy – 1.1.0
Gravity Forms User Registration Add-On: door Gravity Forms – 5.0
Mollie Payments for WooCommerce: door Mollie – 7.4.0
PDF Invoices & Packing Slips for WooCommerce: door WP Overnight – 3.6.3
Preview E-mails for WooCommerce: door Digamber Pradhan – 2.1.6
Shop as Client for WooCommerce: door PT Woo Plugins (by Webdados) – 2.5
Shop as Client for WooCommerce - PRO add-on: door Webdados – 1.7.2
WooCommerce AAParcel: door AAParcel – 2.6.1
WooCommerce PDF Invoices & Packing Slips Professional: door Ewout Fernhout – 2.7.3
WooCommerce Sequential Order Numbers Pro: door SkyVerge – 1.13.1
WP Mail Log: door WPVibes – 1.1.2

Must Use Plugins (1)

L4 Profiler: door Label Vier – 1.0.0

Settings

API Enabled: –
Force SSL: –
Currency: EUR (€)
Currency Position: left
Thousand Separator: .
Decimal Separator: ,
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
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: –
Enforce Approved Product Download Directories: –
HPOS feature screen enabled: –
HPOS feature enabled: –
Order datastore: WC_Order_Data_Store_CPT
HPOS data sync enabled: –

WC Pages

Winkelbasis: #23 - /winkel/
Winkelwagen: #24 - /winkelmand/
Afrekenen: #25 - /afrekenen/
Mijn account: #26 - /mijn-account/
Algemene voorwaarden: ❌ Pagina niet ingesteld

Theme

Name: LabelVier
Version: 1.6.4
Author URL: https://labelvier.nl/
Child Theme: ❌ – Als je wijzigingen aanbrengt in WooCommerce of in een hoofdthema dat je niet zelf gebouwd hebt
raden we het gebruik van een sub thema aan. Zie: Hoe maak je eensub thema

WooCommerce Support: ✔

Templates

Overrides: labelvier/woocommerce/emails/customer-invoice.php

Admin

Enabled Features: activity-panels
analytics
product-block-editor
coupons
core-profiler
customer-effort-score-tracks
import-products-task
experimental-fashion-sample-products
shipping-smart-defaults
shipping-setting-tour
homescreen
marketing
mobile-app-banner
navigation
onboarding
onboarding-tasks
remote-inbox-notifications
remote-free-extensions
payment-gateway-suggestions
shipping-label-banner
subscriptions
store-alerts
transient-notices
woo-mobile-welcome
wc-pay-promotion
wc-pay-welcome-page

Disabled Features: customize-store
minified-js
new-product-management-experience
product-variation-management
settings
async-product-editor-category-field

Daily Cron: ✔ Next scheduled: 2022-05-13 11:15:04 +00:00
Options: ✔
Notes: 23
Onboarding: completed

Action Scheduler

Afgerond: 4
Oldest: 2023-09-25 12:33:34 +0000
Newest: 2023-09-25 12:47:50 +0000

In afwachting: 2
Oldest: 2023-09-26 12:33:34 +0000
Newest: 2024-01-01 00:00:01 +0000

Status report information

Generated at: 2023-09-25 13:02:05 +00:00

Isolating the problem

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.
@github-actions github-actions bot added status: awaiting triage This is a newly created issue waiting for triage. type: community contribution labels Sep 25, 2023
@ntborg
Copy link
Author

ntborg commented Sep 25, 2023

Fix
class-wc-regenerate-images.php:266
change:

		if ( ! $imagedata ) {
			return array();
		}

to:

		if ( !is_array($imagedata)  ) {
			return array();
		}

@coreymckrill coreymckrill added type: bug The issue is a confirmed bug. team: Proton and removed status: awaiting triage This is a newly created issue waiting for triage. labels Sep 25, 2023
@coreymckrill
Copy link
Collaborator

@ntborg I'm trying to figure out if this is a bug in WooCommerce or in ACF. It sounds like what's happening here is that wp_get_attachment_metadata is returning a string (which is truthy) instead of either an array or false. As far as I can tell, this would only happen if something (ACF for example, or some other plugin) is adding a filter to the wp_get_attachment_metadata hook and changing the value to a string. WooCommerce itself does not add any filters on that hook.

@barryhughes barryhughes added the priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. label Oct 3, 2023
@coreymckrill coreymckrill added the needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. label Oct 10, 2023
Copy link
Contributor

As a part of this repository's maintenance, this issue is being marked as stale due to inactivity. Please feel free to comment on it in case we missed something.

After 7 days with no activity this issue will be automatically be closed.

@github-actions github-actions bot added the status: stale Issues that have no had any activity for some time. label Nov 17, 2023
@rrennick rrennick removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. status: stale Issues that have no had any activity for some time. labels Nov 17, 2023
@rrennick
Copy link
Contributor

@coreymckrill I removed the needs: author feedback because code using filters should not rely on the filter returning the correct data type and to prevent the issue being automatically closed.

coreymckrill added a commit that referenced this issue Feb 15, 2024
#40395)

Ensures that even if `wp_get_attachment_metadata` returns an unexpected value due to a filter, the `get_full_size_image_dimensions` method will handle it correctly and not throw an error.

Fixes #40393

---------

Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton type: bug The issue is a confirmed bug. type: community contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants