woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
298 stars 110 forks source link

The image upload in product creation form fails if I upload multiple images at the same time #8564

Closed samy closed 8 months ago

samy commented 1 year ago

Describe the bug If I select more than an image when adding images to a simple product, the uploads fails for the images after the first image (the first image uploads but not the others).

A popin says the application is unable to import my images.

The number of occurences of the popin isn't related to the image number (if I upload 3 or 8 images at the same time, I have the popin twice, for example)

iOS application error logs

``` 3/01/05 20:18:39:613 🔵 Tracked product_image_settings_add_images_button_tapped, properties: [AnyHashable("blog_id"): 96982530, AnyHashable("is_wpcom_store"): false] 2023/01/05 20:18:41:574 🔵 Tracked product_image_settings_add_images_source_tapped, properties: [AnyHashable("source"): "device", AnyHashable("blog_id"): 96982530, AnyHashable("is_wpcom_store"): false] 2023/01/05 20:18:44:894 🔵 Tracked product_image_settings_done_button_tapped, properties: [AnyHashable("is_wpcom_store"): false, AnyHashable("has_changed_data"): true, AnyHashable("blog_id"): 96982530] 2023/01/05 20:19:01:385 <> Mapping Error: keyNotFound(CodingKeys(stringValue: "ID", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "media", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"ID\", intValue: nil) (\"ID\").", underlyingError: nil)) 2023/01/05 20:19:01:410 🔵 Tracked product_image_upload_failed, properties: [AnyHashable("is_wpcom_store"): false, AnyHashable("error_description"): "Swift.DecodingError.keyNotFound(CodingKeys(stringValue: \"ID\", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: \"media\", intValue: nil), _JSONKey(stringValue: \"Index 0\", intValue: 0)], debugDescription: \"No value associated with key CodingKeys(stringValue: \\\"ID\\\", intValue: nil) (\\\"ID\\\").\", underlyingError: nil))", AnyHashable("error_domain"): "NSCocoaErrorDomain", AnyHashable("blog_id"): 96982530, AnyHashable("error_code"): "4865"] 2023/01/05 20:19:02:075 <> Mapping Error: keyNotFound(CodingKeys(stringValue: "ID", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "media", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"ID\", intValue: nil) (\"ID\").", underlyingError: nil)) 2023/01/05 20:19:02:099 🔵 Tracked product_image_upload_failed, properties: [AnyHashable("error_domain"): "NSCocoaErrorDomain", AnyHashable("blog_id"): 96982530, AnyHashable("error_code"): "4865", AnyHashable("error_description"): "Swift.DecodingError.keyNotFound(CodingKeys(stringValue: \"ID\", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: \"media\", intValue: nil), _JSONKey(stringValue: \"Index 0\", intValue: 0)], debugDescription: \"No value associated with key CodingKeys(stringValue: \\\"ID\\\", intValue: nil) (\\\"ID\\\").\", underlyingError: nil))", AnyHashable("is_wpcom_store"): false] 2023/01/05 20:19:07:899 🔵 Tracked main_tab_hub_menu_selected, properties: [AnyHashable("is_wpcom_store"): false, AnyHashable("blog_id"): 96982530] 2023/01/05 20:19:08:942 <> Mapping Error: keyNotFound(CodingKeys(stringValue: "ID", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "media", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"ID\", intValue: nil) (\"ID\").", underlyingError: nil)) 2023/01/05 20:19:08:967 🔵 Tracked product_image_upload_failed, properties: [AnyHashable("blog_id"): 96982530, AnyHashable("is_wpcom_store"): false, AnyHashable("error_description"): "Swift.DecodingError.keyNotFound(CodingKeys(stringValue: \"ID\", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: \"media\", intValue: nil), _JSONKey(stringValue: \"Index 0\", intValue: 0)], debugDescription: \"No value associated with key CodingKeys(stringValue: \\\"ID\\\", intValue: nil) (\\\"ID\\\").\", underlyingError: nil))", AnyHashable("error_domain"): "NSCocoaErrorDomain", AnyHashable("error_code"): "4865"] 2023/01/05 20:19:08:997 🔵 Tracked failure_uploading_image_notice_shown, properties: [AnyHashable("blog_id"): 96982530, AnyHashable("is_wpcom_store"): false, AnyHashable("type"): "product"] ```

Additional information A PHP error occurs in relation of the image upload Call to a member function get_id() on bool in /home/samyrabih/lululalucette.com/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php:656

To Reproduce Steps to reproduce the behavior:

  1. Go to WooCommerce iOS application
  2. Click on "+" on the top of the app
  3. Click on "Simple physical product"
  4. Click on title field and set a title
  5. Click on "Add a product image"
  6. Click on "Add images"
  7. Click on "Choose from device" (the iPhone is in French, so it is my own literal translation)
  8. Select images (more than one)
  9. Click on "Add X" (X being the number of selected images)
  10. The upload begins (very long)
  11. After some many seconds, the error popin occurs

Expected behavior Upload images must work for all the selected images

Isolating the problem (mark completed items with an [x]):

Mobile Environment Please include:

WordPress Environment

``` ### WordPress Environment ### WordPress address (URL): https://lululalucette.com Site address (URL): https://lululalucette.com WC Version: 7.2.2 REST API Version: ✔ 7.2.2 WC Blocks Version: ✔ 9.3.0 Action Scheduler Version: ✔ 3.4.0 Log Directory Writable: ✔ WP Version: 6.1.1 WP Multisite: – WP Memory Limit: 512 Mo WP Debug Mode: ✔ WP Cron: ✔ Language: fr_FR External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 7.4.33 PHP Post Max Size: 512 Mo PHP Time Limit: 360 PHP Max Input Vars: 250000 cURL Version: 7.84.0 OpenSSL/1.1.1p SUHOSIN Installed: – MySQL Version: 5.5.5-10.6.11-MariaDB Max Upload Size: 512 Mo Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 7.2.2 WC Database Prefix: wor8139_ Taille totale de la base de données: 74.01MB Taille de la base de données: 65.05MB Taille de l’index: 8.96MB wor8139_woocommerce_sessions: Données : 0.86MB + Index : 0.04MB + Moteur MyISAM wor8139_woocommerce_api_keys: Données : 0.00MB + Index : 0.01MB + Moteur MyISAM wor8139_woocommerce_attribute_taxonomies: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_downloadable_product_permissions: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_order_items: Données : 0.02MB + Index : 0.01MB + Moteur MyISAM wor8139_woocommerce_order_itemmeta: Données : 0.11MB + Index : 0.08MB + Moteur MyISAM wor8139_woocommerce_tax_rates: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_tax_rate_locations: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_shipping_zones: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_shipping_zone_locations: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_shipping_zone_methods: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_payment_tokens: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_payment_tokenmeta: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woocommerce_log: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_actionscheduler_actions: Données : 0.49MB + Index : 0.26MB + Moteur MyISAM wor8139_actionscheduler_claims: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_actionscheduler_groups: Données : 0.00MB + Index : 0.01MB + Moteur MyISAM wor8139_actionscheduler_logs: Données : 0.39MB + Index : 0.26MB + Moteur MyISAM wor8139_apcm_details: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_apcm_statistics: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_commentmeta: Données : 0.07MB + Index : 0.03MB + Moteur MyISAM wor8139_comments: Données : 2.38MB + Index : 0.73MB + Moteur MyISAM wor8139_gmw_forms: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_gmw_locationmeta: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_gmw_locations: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_iwp_backup_status: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_iwp_processed_iterator: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_links: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_lockdowns: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_login_fails: Données : 0.01MB + Index : 0.01MB + Moteur MyISAM wor8139_mappress_maps: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_mappress_posts: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_options: Données : 6.07MB + Index : 0.18MB + Moteur MyISAM wor8139_postmeta: Données : 31.78MB + Index : 2.39MB + Moteur MyISAM wor8139_posts: Données : 9.44MB + Index : 1.53MB + Moteur MyISAM wor8139_sbi_feeds: Données : 0.02MB + Index : 0.02MB + Moteur InnoDB wor8139_sbi_feed_caches: Données : 0.02MB + Index : 0.02MB + Moteur InnoDB wor8139_sbi_instagram_feeds_posts: Données : 0.02MB + Index : 0.03MB + Moteur InnoDB wor8139_sbi_instagram_feed_locator: Données : 0.02MB + Index : 0.03MB + Moteur InnoDB wor8139_sbi_instagram_posts: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_sbi_sources: Données : 0.02MB + Index : 0.03MB + Moteur InnoDB wor8139_termmeta: Données : 0.01MB + Index : 0.01MB + Moteur MyISAM wor8139_terms: Données : 0.01MB + Index : 0.03MB + Moteur MyISAM wor8139_term_relationships: Données : 0.07MB + Index : 0.13MB + Moteur MyISAM wor8139_term_taxonomy: Données : 0.01MB + Index : 0.01MB + Moteur MyISAM wor8139_usermeta: Données : 0.05MB + Index : 0.02MB + Moteur MyISAM wor8139_users: Données : 0.00MB + Index : 0.01MB + Moteur MyISAM wor8139_wc_admin_notes: Données : 0.05MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_admin_note_actions: Données : 0.02MB + Index : 0.01MB + Moteur MyISAM wor8139_wc_category_lookup: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_customer_lookup: Données : 0.01MB + Index : 0.01MB + Moteur MyISAM wor8139_wc_download_log: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_order_coupon_lookup: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_order_product_lookup: Données : 0.01MB + Index : 0.02MB + Moteur MyISAM wor8139_wc_order_stats: Données : 0.01MB + Index : 0.02MB + Moteur MyISAM wor8139_wc_order_tax_lookup: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_product_attributes_lookup: Données : 0.02MB + Index : 0.02MB + Moteur InnoDB wor8139_wc_product_download_directories: Données : 0.02MB + Index : 0.02MB + Moteur InnoDB wor8139_wc_product_meta_lookup: Données : 0.06MB + Index : 0.09MB + Moteur InnoDB wor8139_wc_rate_limits: Données : 0.02MB + Index : 0.02MB + Moteur InnoDB wor8139_wc_reserved_stock: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_wc_tax_rate_classes: Données : 0.00MB + Index : 0.01MB + Moteur MyISAM wor8139_wc_webhooks: Données : 0.00MB + Index : 0.00MB + Moteur MyISAM wor8139_woel_woocommerce_order_emails_log: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_wpml_mails: Données : 0.02MB + Index : 0.00MB + Moteur InnoDB wor8139_yoast_indexable: Données : 12.29MB + Index : 1.91MB + Moteur MyISAM wor8139_yoast_indexable_hierarchy: Données : 0.38MB + Index : 0.86MB + Moteur MyISAM wor8139_yoast_migrations: Données : 0.00MB + Index : 0.01MB + Moteur MyISAM wor8139_yoast_primary_term: Données : 0.01MB + Index : 0.01MB + Moteur MyISAM wor8139_yoast_seo_links: Données : 0.13MB + Index : 0.04MB + Moteur MyISAM wor8139_yoast_seo_meta: Données : 0.03MB + Index : 0.03MB + Moteur MyISAM ### Post Type Counts ### acf-field: 5 acf-field-group: 4 attachment: 17266 custom_css: 3 is_search_form: 1 lieu: 3 nav_menu_item: 20 oembed_cache: 3 page: 9 post: 1223 product: 155 product_variation: 182 revision: 439 shop_coupon: 5 shop_order: 114 shop_order_refund: 2 wp_global_styles: 1 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (22) ### InfiniteWP - Client: par Revmakx – 1.10.1 Ivory Search: par Ivory Search – 5.4.10 Advanced Custom Fields PRO: par WP Engine – 6.0.6 AfterShip Tracking - All-In-One WooCommerce Order Tracking (Free plan available): par AfterShip – 1.15.2 Akismet Anti-Spam: par Automattic – 5.0.2 Custom Post Type UI: par WebDevStudios – 1.13.4 Facebook for WooCommerce: par Facebook – 3.0.7 Favicon par RealFaviconGenerator: par Philippe Bernard – 1.3.27 GA Google Analytics: par Jeff Starr – 20221016 Jetpack: par Automattic – 11.6 Kirki Customizer Framework: par David Vongries – 4.0.24 Gutenberg PDF Viewer Block: par audrasjb – 1.1 PixLikes: par pixelgrade – 1.1.3 Top Bar PRO: par WP Darko – 3.0.1 Chronopost & Mondial relay pour WooCommerce - WCMultiShipping: par Mondial Relay WooCommerce - WCMultiShipping – 2.1.2 Widgets in Menu for WordPress: par saurabhshukla yapapaya – 1.0.0 WooCommerce Blocks: par Automattic – 9.3.0 WooCommerce Stripe Gateway: par WooCommerce – 7.0.1 WooCommerce PayPal Payments: par WooCommerce – 2.0.1 WooCommerce: par Automattic – 7.2.2 Yoast SEO: par L’équipe Yoast – 19.13 WP Sanitize Accented Uploads: par Onni Hakala / Geniem Oy – 1.2 ### Inactive Plugins (4) ### Image Licensing Schema – Structured Data for Google Images: par audrasjb – 1.3 Pinterest Pin It Button For Images: par Canha – 1.1.0 Smash Balloon Instagram Feed: par Smash Balloon – 6.1 Widget CSS Classes: par Jory Hogeveen – 1.5.4.1 ### Must Use Plugins (1) ### InfiniteWP - Client Loader: par Revmakx – 1.0.1 ### Settings ### API Enabled: – Force SSL: – Currency: EUR (€) Currency Position: right 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: – Order datastore: WC_Order_Data_Store_CPT ### WC Pages ### Base de la boutique: #95253 - /boutique/ Panier: #92435 - /panier/ Commander: #92436 - /paiement/ Mon compte: #92437 - /mon-compte/ Conditions générales de vente et d’utilisation: ❌ Page non définie ### Theme ### Name: Lulu la lucette Version: 1.0.0 Author URL: http://example.com Child Theme: ✔ Parent Theme Name: Kale Parent Theme Version: 2.6 Parent Theme Author URL: https://www.lyrathemes.com/ WooCommerce Support: ✔ ### Templates ### Archive Template: Votre thème a un fichier woocommerce.php vous ne serez pas en mesure de substituer le modèle personnalisé woocommerce/archive-product.php étant donné que woocommerce.php a la priorité sur archive-product.php. Ceci vise à prévenir les problèmes d’affichage. Overrides: – ### WooCommerce PayPal Payments ### Onboarded: ✔ Shop country code: FR WooCommerce currency supported: ✔ Advanced Card Processing available in country: ✔ Pay Later messaging available in country: ✔ Webhook status: – Vault enabled: ✔ Logging enabled: – Reference Transactions: – Used PayPal Checkout plugin: ✔ Tracking enabled: – ### Admin ### Enabled Features: activity-panels analytics coupons customer-effort-score-tracks experimental-products-task experimental-import-products-task experimental-fashion-sample-products shipping-smart-defaults shipping-setting-tour homescreen marketing multichannel-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: minified-js new-product-management-experience settings Daily Cron: ✔ Next scheduled: 2023-01-06 00:56:53 +01:00 Options: ✔ Notes: 63 Onboarding: completed ### Action Scheduler ### Terminé: 1 839 Oldest: 2022-12-05 21:35:13 +0100 Newest: 2023-01-05 12:54:53 +0100 En attente: 2 Oldest: 2023-01-06 04:09:40 +0100 Newest: 2023-01-06 08:34:49 +0100 ### Status report information ### Generated at: 2023-01-05 21:07:30 +01:00 ```
samy commented 1 year ago

It seems Jetpack debugguer encountered problems to contact the site because of a agressive mod_security strategy returning HTTP 429 errors if the connection rate was too high.

I fixed this setting and the debugger works now.

But it doesn't fix the problem for WooCommerce iOS app.

jostnes commented 1 year ago

@shiki I think your team is the one working on products (please help ping the right people if not 🙏 ) pinging you so that you're aware of this issue.

Also, I've tried the steps above (about 5 photos - screenshots, and actual photos) and wasn't able to reproduce the issue on my test device, all the photos uploaded without issue.

rachelmcr commented 8 months ago

Thank you for sharing the details about the error. When the app uploads images, it expects the site to respond with details about the successfully uploaded images. The errors in the app logs indicate that the app received an unexpected response (missing the expected data) from your site.

This fits with the PHP error described in the issue, where the function get_id() did not work. Based on where that occurred it looks like your site wasn't able to fetch the ID of the product where the images were being uploaded. This kind of error is usually caused by a plugin or your site's theme modifying related code on your site so it doesn't work as expected. In this case, it's possible that the upload itself works but your site sends a response that looks like a failure to the app, so the app thinks the upload has failed (and if there are multiple images being uploaded, it cancels the upload).

The best way to resolve this for your store is to test for theme or plugin conflicts. If you discover the issue is caused by a conflict with another plugin, we recommend contacting the plugin developer to let them know or we can take a look to see if there's a way the app can work around that conflict. Hope this helps!