woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.41k stars 10.76k forks source link

Seemingly Sporadic Renaming of products #22166

Closed dogzy closed 5 years ago

dogzy commented 5 years ago

Describe the bug When passing a product id to WC_Product_variation() which isn't a variable product post id, the post parent post is renamed to the current page the user is on. Although this doesn't happen out of the box with woocommerce I believe there should be a check for the post type of the id which is being passed.

To Reproduce Steps to reproduce the behavior:

  1. pass a non variable product id to WC_Product_variation()

Expected behavior If passing a product id to WC_Product_variation() which isn't a valid variation ID I would expect it to return null.

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

WordPress Environment

``` ` ### WordPress Environment ### Home URL: https://www.genesisteamwear.com Site URL: https://www.genesisteamwear.com WC Version: 3.5.0 Log Directory Writable: ✔ WP Version: 4.9.8 WP Multisite: – WP Memory Limit: 1 GB WP Debug Mode: ✔ WP Cron: – Language: en_US External object cache: ✔ ### Server Environment ### Server Info: nginx PHP Version: 7.2.11 PHP Post Max Size: 64 MB PHP Time Limit: 300 PHP Max Input Vars: 3000 cURL Version: 7.52.1 OpenSSL/1.0.2l SUHOSIN Installed: – MySQL Version: 5.5.43-MariaDB-1~wheezy Max Upload Size: 64 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 3.5.0 WC Database Prefix: wp_ MaxMind GeoIP Database: ✔ Total Database Size: 4057.43MB Database Data Size: 3211.08MB Database Index Size: 846.35MB wp_woocommerce_sessions: Data: 2.02MB + Index: 0.02MB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB wp_woocommerce_order_items: Data: 15.55MB + Index: 4.52MB wp_woocommerce_order_itemmeta: Data: 211.77MB + Index: 206.66MB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.05MB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB wp_aelia_dismissed_messages: Data: 0.02MB + Index: 0.00MB wp_aryo_activity_log: Data: 1.02MB + Index: 0.00MB wp_commentmeta: Data: 10.52MB + Index: 13.02MB wp_comments: Data: 147.69MB + Index: 89.25MB wp_fpd_templates: Data: 0.02MB + Index: 0.00MB wp_fpd_views: Data: 0.02MB + Index: 0.00MB wp_gf_addon_feed: Data: 0.02MB + Index: 0.02MB wp_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB wp_gf_entry: Data: 6.52MB + Index: 1.88MB wp_gf_entry_meta: Data: 10.52MB + Index: 12.58MB wp_gf_entry_notes: Data: 0.02MB + Index: 0.03MB wp_gf_form: Data: 0.02MB + Index: 0.00MB wp_gf_form_meta: Data: 1.17MB + Index: 0.00MB wp_gf_form_view: Data: 2.52MB + Index: 3.03MB wp_icl_content_status: Data: 0.02MB + Index: 0.02MB wp_icl_core_status: Data: 0.02MB + Index: 0.02MB wp_icl_flags: Data: 0.02MB + Index: 0.02MB wp_icl_languages: Data: 0.02MB + Index: 0.03MB wp_icl_languages_translations: Data: 0.19MB + Index: 0.11MB wp_icl_locale_map: Data: 0.02MB + Index: 0.00MB wp_icl_message_status: Data: 0.02MB + Index: 0.03MB wp_icl_mo_files_domains: Data: 0.02MB + Index: 0.02MB wp_icl_node: Data: 0.02MB + Index: 0.00MB wp_icl_reminders: Data: 0.02MB + Index: 0.00MB wp_icl_strings: Data: 40.58MB + Index: 19.09MB wp_icl_string_packages: Data: 0.02MB + Index: 0.00MB wp_icl_string_pages: Data: 25.56MB + Index: 21.56MB wp_icl_string_positions: Data: 0.06MB + Index: 0.02MB wp_icl_string_status: Data: 0.02MB + Index: 0.02MB wp_icl_string_translations: Data: 0.22MB + Index: 0.11MB wp_icl_string_urls: Data: 0.39MB + Index: 0.42MB wp_icl_translate: Data: 10.42MB + Index: 1.52MB wp_icl_translate_job: Data: 0.19MB + Index: 0.14MB wp_icl_translations: Data: 22.56MB + Index: 74.22MB wp_icl_translation_batches: Data: 0.02MB + Index: 0.00MB wp_icl_translation_status: Data: 27.56MB + Index: 2.52MB wp_layerslider: Data: 0.14MB + Index: 0.00MB wp_links: Data: 0.02MB + Index: 0.02MB wp_options: Data: 17.11MB + Index: 2.06MB wp_pmxe_exports: Data: 2.02MB + Index: 0.00MB wp_pmxe_google_cats: Data: 0.39MB + Index: 0.00MB wp_pmxe_posts: Data: 1.52MB + Index: 0.00MB wp_pmxe_templates: Data: 0.02MB + Index: 0.00MB wp_postmeta: Data: 824.94MB + Index: 231.23MB wp_postmeta2: Data: 17.52MB + Index: 9.03MB wp_posts: Data: 70.52MB + Index: 40.38MB wp_redirection_404: Data: 4.02MB + Index: 4.41MB wp_redirection_groups: Data: 0.02MB + Index: 0.03MB wp_redirection_items: Data: 0.02MB + Index: 0.08MB wp_redirection_logs: Data: 0.02MB + Index: 0.08MB wp_rg_form: Data: 0.02MB + Index: 0.00MB wp_rg_form_meta: Data: 1.41MB + Index: 0.00MB wp_rg_form_view: Data: 1.52MB + Index: 3.03MB wp_rg_incomplete_submissions: Data: 0.02MB + Index: 0.02MB wp_rg_lead: Data: 5.52MB + Index: 0.73MB wp_rg_lead_detail: Data: 6.52MB + Index: 13.06MB wp_rg_lead_detail_long: Data: 0.42MB + Index: 0.00MB wp_rg_lead_meta: Data: 0.14MB + Index: 0.25MB wp_rg_lead_notes: Data: 0.02MB + Index: 0.03MB wp_rg_salesforce: Data: 0.02MB + Index: 0.02MB wp_rg_zapier: Data: 0.02MB + Index: 0.02MB wp_signups: Data: 0.02MB + Index: 0.06MB wp_termmeta: Data: 0.11MB + Index: 0.16MB wp_terms: Data: 0.06MB + Index: 0.03MB wp_term_relationships: Data: 2.48MB + Index: 1.42MB wp_term_taxonomy: Data: 0.08MB + Index: 0.06MB wp_usermeta: Data: 1701.69MB + Index: 70.11MB wp_users: Data: 5.52MB + Index: 5.55MB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB wp_wc_points_rewards_user_points: Data: 3.52MB + Index: 6.58MB wp_wc_points_rewards_user_points_log: Data: 5.52MB + Index: 6.55MB wp_wc_warranty_products: Data: 0.02MB + Index: 0.05MB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB wp_woocommerce_shipping_table_rates: Data: 0.02MB + Index: 0.00MB wp_woocommerce_shipping_zone_shipping_methods: Data: 0.02MB + Index: 0.00MB wp_wpgdprc_consents: Data: 0.02MB + Index: 0.00MB wp_wpmm_subscribers: Data: 0.02MB + Index: 0.00MB wp_yoast_seo_links: Data: 0.02MB + Index: 0.02MB wp_yoast_seo_meta: Data: 0.38MB + Index: 0.00MB ### Post Type Counts ### acf: 16 acf-field: 671 acf-field-group: 93 amn_mi-lite: 1 archive-image: 22 artwork: 3693 attachment: 105335 campaign: 21 carts: 191 chart: 2 club: 73 crest: 6 gen_componentlist: 25 global_product_addon: 1 gs_kit: 24165 gs_squad: 14057 gs_team: 18508 ifso_triggers: 1 leisurewear: 126 meganav: 17 nav_menu_item: 105 page: 156 post: 120 product: 1482 product_variation: 11789 revision: 1807 share: 967 shop_coupon: 5294 shop_order: 25300 shop_order_refund: 24 shop_webhook: 2 sponsor: 1 testimonials: 5 ufaq: 66 wcct_countdown: 25 wcct-deal-shortcode: 4 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (44) ### Gravity Forms: by rocketgenius – 2.3.2.2 WPML Multilingual CMS: by OnTheGoSystems – 4.0.6 Advanced Custom Fields Multilingual: by OnTheGoSystems – 0.8 Advanced Access Manager: by Vasyl Martyniuk – 5.4.3.2 Advanced Custom Fields PRO: by Elliot Condon – 5.6.10 WP Offload S3 Lite: by Delicious Brains – 1.4.3 Breadcrumb NavXT: by John Havlik – 6.2.0 Desk.com WordPress Plugin: by Jonny Rudd - Genesis Teamwear – 2.0.0 – Not tested with the active version of WooCommerce Duplicate Post: by Enrico Battocchi – 3.2.2 Google Tag Manager for Wordpress: by Thomas Geiger – 1.9 – Not tested with the active version of WooCommerce Google Analytics by Yoast eCommerce tracking addon: by Team Yoast – 3.0.5 Google Analytics for WordPress by MonsterInsights: by MonsterInsights – 7.2.0 Gravity Forms Salesforce Add-On: by Katz Web Services Inc. – 3.1.2 Gravity Forms Multilingual: by OnTheGoSystems – 1.3.17 Gravity Forms WooCommerce Product Field Add-On: by First 10 Digital – 1.0 – Not tested with the active version of WooCommerce Gravity Forms User Registration Add-On: by rocketgenius – 3.9.2 Gs Kit Builder: by RedVelvetDigital – 1.0.1 Genesis Sports Utilities: by Mark Wilkinson – 1.0 First 10 PDF Builder: by First 10 Digital – 1.0.2 Product Catalog Feed Pro by PixelYourSite: by PixelYourSite – 3.3.7 – Not tested with the active version of WooCommerce NC Size Chart for Woocommerce: by Nabaraj Chapagain – 1.0.6 – Not tested with the active version of WooCommerce Q and A FAQ and Knowledge Base for WordPress: by Raygun – 1.0.6.2 Redirection: by John Godley – 3.5 Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.0.2 SendGrid: by SendGrid – 1.11.8 Smart WooCommerce Search: by YummyWP – 1.5.3 – Not tested with the active version of WooCommerce Super Socializer: by Team Heateor – 7.12.1 Category Order and Taxonomy Terms Order: by Nsp-Code – 1.5.5 Ultimate FAQ: by Etoile Web Design – 1.8.7 – Not tested with the active version of WooCommerce WooCommerce Custom Status: by Garman Technical Services – 1.0 – Not tested with the active version of WooCommerce WooCommerce WorldPay Gateway: by Andrew Benbow – 3.6.4 – 3.6.6 is available – Not tested with the active version of WooCommerce WooCommerce Multilingual: by OnTheGoSystems – 4.3.5 – Not tested with the active version of WooCommerce WooCommerce Product Add-ons: by WooCommerce – 2.9.1 – 3.0.4 is available – Not tested with the active version of WooCommerce WooCommerce Role Based Methods: by WPBackOffice – 2.0.9 – 2.3.10 is available – Not tested with the active version of WooCommerce WooCommerce Shop as Customer: by cxThemes – 2.12 – Not tested with the active version of WooCommerce WooCommerce: by Automattic – 3.5.0 – 3.5.2 is available WooSidebars: by WooCommerce – 1.4.5 WP GDPR Compliance: by Van Ons – 1.4.2 WP Maintenance Mode: by Designmodo – 2.2.1 Prima Utility WordPress Plugin: by First 10 Digital – 1.1.0 WPML Media: by OnTheGoSystems – 2.3.6 WPML String Translation: by OnTheGoSystems – 2.8.6 WPML Translation Management: by OnTheGoSystems – 2.6.6 ### Settings ### API Enabled: ✔ Force SSL: – Currency: GBP (£) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: simple (simple) grouped (grouped) variable (variable) external (external) custom (custom) Taxonomies: Product Visibility: exclude-from-search (exclude-from-search) exclude-from-catalog (exclude-from-catalog) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) ### WC Pages ### Shop base: #4 - /shop/ Cart: #5 - /cart/ Checkout: #6 - /checkout/ My account: ❌ Page does not contain the shortcode. Terms and conditions: #127 - /terms-conditions/ ### Theme ### Name: Genesis Teamwear Version: 1.0.0 Author URL: http://first10.co.uk/ Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ✔ ### Templates ### Archive Template: Your theme has a woocommerce.php file you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues. Overrides: genesis-puma-rebrand/woocommerce/archive-product.php genesis-puma-rebrand/woocommerce/cart/cart-empty.php version 3.1.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/cart/cart-item-data.php genesis-puma-rebrand/woocommerce/cart/cart-shipping.php version 3.2.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/cart/cart-totals.php genesis-puma-rebrand/woocommerce/cart/cart.php version 3.4.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/cart/cross-sells.php genesis-puma-rebrand/woocommerce/cart/mini-cart.php version 3.0.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/checkout/form-billing.php genesis-puma-rebrand/woocommerce/checkout/form-checkout.php version 2.3.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/checkout/form-shipping.php genesis-puma-rebrand/woocommerce/checkout/payment.php genesis-puma-rebrand/woocommerce/checkout/review-order.php genesis-puma-rebrand/woocommerce/checkout/thankyou.php genesis-puma-rebrand/woocommerce/content-product.php genesis-puma-rebrand/woocommerce/content-product_cat.php genesis-puma-rebrand/woocommerce/content-single-product.php version 1.6.4 is out of date. The core version is 3.4.0 genesis-puma-rebrand/woocommerce/emails/customer-new-account.php version 1.6.4 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/emails/customer-processing-order.php version 2.5.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/emails/email-footer.php genesis-puma-rebrand/woocommerce/emails/email-header.php genesis-puma-rebrand/woocommerce/emails/plain/customer-new-account.php version 2.0.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/emails/plain/customer-processing-order.php version 2.5.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/loop/add-to-cart.php genesis-puma-rebrand/woocommerce/loop/loop-start.php genesis-puma-rebrand/woocommerce/loop/price.php genesis-puma-rebrand/woocommerce/myaccount/form-login.php version 3.4.0 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/myaccount/my-address.php genesis-puma-rebrand/woocommerce/order/order-details.php genesis-puma-rebrand/woocommerce/single-product/add-to-cart/external.php genesis-puma-rebrand/woocommerce/single-product/add-to-cart/grouped.php genesis-puma-rebrand/woocommerce/single-product/add-to-cart/simple.php genesis-puma-rebrand/woocommerce/single-product/add-to-cart/variable.php genesis-puma-rebrand/woocommerce/single-product/meta.php genesis-puma-rebrand/woocommerce/single-product/price.php genesis-puma-rebrand/woocommerce/single-product/product-image.php version 3.3.2 is out of date. The core version is 3.5.0 genesis-puma-rebrand/woocommerce/single-product/product-thumbnails.php genesis-puma-rebrand/woocommerce/single-product/tabs/description.php genesis-puma-rebrand/woocommerce/single-product/tabs/tabs.php genesis-puma-rebrand/woocommerce/single-product/title.php genesis-puma-rebrand/woocommerce/single-product/up-sells.php genesis-puma-rebrand/woocommerce/single-product.php Outdated Templates: ❌ Learn how to update ### Customer/Order CSV Export ### Order Export Format: custom Customer Export Format: import Automatically Export Orders: disabled Automatically Export Customers: disabled ` ```
rrennick commented 5 years ago

WooCommerce has wrapper functions to create WC objects. For this you should be using wc_get_product() which will return the correct WC product type object.

dogzy commented 5 years ago

Thanks for the clarification on this :)