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

Updating a product always returns woocommerce_product_image_upload_error #56

Closed
cdiguy opened this issue Nov 5, 2019 · 4 comments
Closed

Comments

@cdiguy
Copy link

cdiguy commented Nov 5, 2019

I have a custom plugin that creates/updates product pages from information retrieved from an external customer database. The plugin uses the WooCommerce REST API PUT request to update existing product page data. When I updated WooCommerce from ver 3.4.4 to ver 3.7.0 I began to see the following error for all product page updates:

Code: 400
Headers: Array
(
[Date] => Thu, 31 Oct 2019 17:34:55 GMT
[Server] => Apache/2.2.15 (CentOS)
[X-Powered-By] => PHP/7.2.1
[Set-Cookie] => PHPSESSID=7uo0ufol9pnejka6ru0pvm7sov; path=/
[Expires] => Wed, 11 Jan 1984 05:00:00 GMT
[Cache-Control] => no-transform, no-cache, must-revalidate, max-age=0
[Pragma] => no-cache
[X-Robots-Tag] => noindex
[Link] => http://beta.cdielectronics.com/wp-json/; rel="https://api.w.org/"
[X-Content-Type-Options] => nosniff
[Access-Control-Expose-Headers] => X-WP-Total, X-WP-TotalPages
[Access-Control-Allow-Headers] => Authorization, Content-Type
[Allow] => GET, POST, PUT, PATCH, DELETE
[Content-Length] => 159
[Connection] => close
[Content-Type] => application/json; charset=UTF-8
)
Body: {"code":"woocommerce_product_image_upload_error","message":"Invalid image: Sorry, this file type is not permitted for security reasons.","data":{"status":400}}

Our debug output for one of the product updates:

[31-Oct-2019 17:34:55 UTC] [admin-ajax.php][192.168.1.183][][DEBUG] upsert_wc_product called for sku 113-4041
[31-Oct-2019 17:34:55 UTC] [admin-ajax.php][192.168.1.183][][DEBUG] wc_existing_product_id: 19624
[31-Oct-2019 17:34:55 UTC] [admin-ajax.php][192.168.1.183][][DEBUG] get_post_thumbnail_id: no media attached to product ID = 19624
[31-Oct-2019 17:34:55 UTC] [admin-ajax.php][192.168.1.183][][DEBUG] Updating existing product: Data: Array
(
[sku] => 113-4041
[name] => Power Pack 4 Cyl.
[slug] => 113-4041
[type] => simple
[description] => 1988-2001 (120,125,130,135 & 140HP) Loop Charged Engines w/ Quick Start & S.L.O.W., 6700 RPM Limit

Replaces:

113-4041, 18-5772, 583489, 584040, 584041, 9-25017
[upsell_ids] => Array
(
[0] => 19427
)

[images] => Array
    (
        [0] => Array
            (
                [src] => http://beta.cdielectronics.com/wp-admin/admin-ajax.php?action=cdi_spget&spurl=https://sharepoint.cdielectronics.com/Controlled%20Documents/Product%20Images/113-4041.jpg
                [position] => 0
            )

    )

[categories] => Array
    (
        [0] => Array
            (
                [id] => 262
            )

    )

)

[31-Oct-2019 17:34:56 UTC] [admin-ajax.php][192.168.1.183][] Error: Invalid image: Sorry, this file type is not permitted for security reasons. [woocommerce_product_image_upload_error]

There are over 900 product pages we are attempting to update. This error is returned for every product page image file. I have verified that the image files exist.

Up through WooCommerce version 3.5.1 I do not get this error. I see the error for versions 3.6.5, 3.7.0, 3.7.1. I have not tested versions between 3.5.1 and 3.6.5 to see in which version the error starts appearing. I am assuming the error exists in all versions since at least 3.6.5.

@issue-label-bot issue-label-bot bot added the bug Issue that can be reproduced. label Nov 5, 2019
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.85. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@guilherme-oliveria
Copy link

guilherme-oliveria commented Nov 25, 2019

that was a slut they did with the link of the images, because now contain "?" in the image link url does not work and this error.
https://www.reddit.com/r/Wordpress/comments/ajg9oa/woocommerce_354_and_wordpress_503_rest_api_image/ (url 1)

woocommerce/woocommerce#24484 my)

@guilherme-oliveria
Copy link

that was a slut they did with the link of the images, because now contain "?" in the image link url does not work and this error.
[https://www.reddit.com/r/Wordpress/comments/ajg9oa/woocommerce_354_and_wordpress_503_rest_api_image/](url 1)

[https://github.com/woocommerce/woocommerce/issues/24484](url my)

@juliaamosova juliaamosova removed the bug Issue that can be reproduced. label Dec 17, 2019
@juliaamosova
Copy link

@cdiguy please take a look at the reason why we made a change in regards to the type of URL allowed in woocommerce/woocommerce#24484. Thanks to @guilherme-oliveria for pointing it out.

I am closing this issue since this is not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants