WooCommerce upgrade 2.8 > 3.5 – “Scalar value” warning
-
Hi!
I recently upgraded one of my WooCommerce stores from 2.8.X to 3.5.1. Everything went pretty well, including the database upgrade but there is one residual issue.
With any of the product pages, near the bottom of the product description (but above the “Related products” section), there is a warning being displayed:
Warning: Cannot use a scalar value as an array in /home/teetotinc/public_html/wp-content/plugins/woocommerce/includes/wc-product-functions.php on line 906
I have checked what wc-product-functions.php has around line 906 and it is as follows:
if ( $transient ) { $transient[ $query_args ] = $related_posts; } else { $transient = array( $query_args => $related_posts ); }
I went through the basics such as reverting back to a default theme (Twenty Seventeen) and disabled all plugins to see if this takes care of the problem, but it still remains.
I ran the store with just my regular theme (Avada) and its two core plugins turned on (Fusion Core / Fusion Builder) and just WooCommerce. The message still shows.
What is this part of the store trying to do / display?
How do i get rid of this?Thanks everyone!
The page I need help with: [log in to see the link]
-
2.8 doesn’t exist, but that shoudn’t matter.
First, if you still get the message “WooCommerce data update – We need to update your store database to the latest version” do that. (Don’t forget to make a backup just in case)
Then try this: WooCommerce > Status > Tools > WooCommerce transients > Clear transients.
If nothing helps, you can disable WP_DEBUG_DISPLAY (See https://codex.www.ads-software.com/Debugging_in_WordPress ) which is a good idea anyway, but this just hides the message, the problem still exists…
Hi Soft79-
Thanks for the suggestions.
Yes, i did perform the store database upgrade after installing the new version of WooCommerce. Clicked the button, it did its thing. No errors.
I went into WooCommerce > Status > Tools > WooCommerce transients > and clicked “Clear transients” but the error message still remains:
https://www.teetot.com/store/dragon-knight/
Warning: Cannot use a scalar value as an array in /home/teetotinc/public_html/wp-content/plugins/woocommerce/includes/wc-product-functions.php on line 906
Anyone else know why this would be happening? Seems like a WooCommerce function since it’s being pulled from wc-product-functions.php
I do see some warning about PHP and MySQL versions in the WooCommerce status page:
PHP version: 5.4.45 – WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version
MySQL version:n 5.5.61-cll – We recommend a minimum MySQL version of 5.6. See: WordPress requirements
Would upgrading this fix the problem?
Has anyone else seen this issue before?
Has anyone else seen this issue before?
I had a look at the issue tracker for WooCommerce and this specific message has not been reported:
https://github.com/woocommerce/woocommerce/issues?utf8=%E2%9C%93&q=is%3Aissue+scalar+valueAnyone else know why this would be happening?
The transient name variable is set here: https://github.com/woocommerce/woocommerce/blob/3.5.2/includes/wc-product-functions.php#L880
And then the transient is retrieved here: https://github.com/woocommerce/woocommerce/blob/3.5.2/includes/wc-product-functions.php#L888
Whatever is stored in that piece of data is not an array. The ‘clear transients’ button doesn’t clear those particular transients so that wouldn’t have helped.
If you have database access (you could use the ARI Adminer plugin https://www.ads-software.com/plugins/ari-adminer/ for that) you could run the following query against the database to see what is stored in those transients:
SELECT * FROM
wp_optionsWHERE
option_nameLIKE '%_transient_wc_related_%' LIMIT 50
That is assuming that the database prefix is wp_ – adjust as necessary.
What you would expect to see would be something like this:
Where that
a:1
part of that designates an array with one element (the array is stored as a serialized string in the database). In all likeliehood, there is one or more of those options that have stored either a string or an integer.It’s probably worth updating PHP to a more recent version
- This reply was modified 5 years, 11 months ago by wbrubaker.a11n.
wbrubaker-
Thanks for taking the time to reply here. I do have database access and ran the query you mentioned, although the output I saw was different that your screenshot (see mine).
PHP upgrade is in the works, will probably take care of that after the holidays.
- This reply was modified 5 years, 11 months ago by 409industries. Reason: better link for viewing screenshot
So, right, the values there are what is causing the notices which leaves the question of how did those values get set like that in the first place.
My first guess would be that something is hooked into one (or likely both) of these two filters: https://github.com/woocommerce/woocommerce/blob/3.5.2/includes/wc-product-functions.php#L894-L895
and the callback function to that is not returning an array. You might consider installing and activating the String Locator plugin https://www.ads-software.com/plugins/string-locator/ and using that to search for any instances of
woocommerce_product_related_posts_relate_by_category
andwoocommerce_product_related_posts_relate_by_tag
– my guess would be the theme, but there is also a chance that there is a plugin hooked in.Before you bother with trying to track it down, however, here is what I recommend to first establish that it is not WooCommerce doing this.
1. Run the following query to remove those transients:
DELETE FROM wp_options WHERE option_name LIKE '%_transient_wc_related_%' LIMIT 50
2. Switch to a default theme such as Twenty Seventeen or Storefront
3. Deactivate all plugins except for WooCommerce
4. Visit any product page for a product that would have related products (related by either category or tag)
5. Again, runSELECT * FROM wp_options WHERE option_name LIKE '%_transient_wc_related_%' LIMIT 50
and see how the data was stored under those conditionsKind regards,
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.
I got busy and didn’t have a chance to try that latest suggestion. I’ll give it a go and report back! Thank you!
@409industries Please do not start duplicate topics. I have archived your new one.
OK @jdembowski
I didn’t realize that as a user I can change the status back to “not resolved”, I thought this was something only moderators and plugin support could do. I’ll repost my update here and hopefully we can continue moving towards a solution.
With my duplicate thread now archived, i’ll have to repost my reply here again, here it goes:
We upgraded PHP. Not a big jump but we’re on 5.6 now, I can’t move to 7.X just yet.
@wbrubaker- I followed your latest suggestion, here was the result of removing the transients again.
I used the string locator plugin as directed and this was the result:
Even with being switched back to Twenty Seventeen theme and having every plugin disabled except for WooCommerce, there is still an error on this page.
For grins, here’s the status report since I didn’t include this previously.
### WordPress Environment ### Home URL: https://www.teetot.com Site URL: https://www.teetot.com WC Version: 3.5.1 Log Directory Writable: ? WP Version: ? 4.9.8 - There is a newer version of WordPress available (5.0.2) WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ? Language: en_US External object cache: – ### Server Environment ### Server Info: Apache/2.4.37 (cPanel) OpenSSL/1.0.2q mod_bwlimited/1.4 PHP Version: 5.6.39 - We recommend using PHP version 7.2 or above for greater performance and security. How to update your PHP version PHP Post Max Size: 32 MB PHP Time Limit: 0 PHP Max Input Vars: 1940 cURL Version: 7.62.0 OpenSSL/1.0.2q SUHOSIN Installed: – MySQL Version: ? 5.5.61-cll - We recommend a minimum MySQL version of 5.6. See: WordPress requirements Max Upload Size: 32 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 3.5.1 WC Database Prefix: wp_ Total Database Size: 35.21MB Database Data Size: 31.63MB Database Index Size: 3.58MB wp_woocommerce_sessions: Data: 14.38MB + Index: 0.43MB wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.01MB wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB wp_woocommerce_order_items: Data: 0.03MB + Index: 0.02MB wp_woocommerce_order_itemmeta: Data: 0.19MB + Index: 0.14MB wp_woocommerce_tax_rates: Data: 0.10MB + Index: 0.07MB wp_woocommerce_tax_rate_locations: Data: 0.07MB + Index: 0.09MB wp_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB wp_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.01MB wp_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB wp_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB wp_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB wp_woocommerce_log: Data: 0.00MB + Index: 0.00MB upstracking: Data: 0.07MB + Index: 0.07MB v_ups_woo: Data: 0.00MB + Index: 0.00MB wp_aws_index: Data: 0.14MB + Index: 0.00MB wp_commentmeta: Data: 0.01MB + Index: 0.01MB wp_comments: Data: 0.13MB + Index: 0.07MB wp_csp3_subscribers: Data: 0.00MB + Index: 0.00MB wp_cspv5_pages: Data: 0.00MB + Index: 0.00MB wp_gglcptch_whitelist: Data: 0.02MB + Index: 0.02MB wp_layerslider: Data: 0.00MB + Index: 0.00MB wp_links: Data: 0.00MB + Index: 0.00MB wp_options: Data: 4.75MB + Index: 0.14MB wp_pmxi_files: Data: 0.00MB + Index: 0.00MB wp_pmxi_history: Data: 0.00MB + Index: 0.00MB wp_pmxi_images: Data: 0.00MB + Index: 0.00MB wp_pmxi_imports: Data: 0.00MB + Index: 0.00MB wp_pmxi_posts: Data: 0.00MB + Index: 0.00MB wp_pmxi_templates: Data: 0.00MB + Index: 0.00MB wp_postmeta: Data: 7.06MB + Index: 1.87MB wp_posts: Data: 4.27MB + Index: 0.34MB wp_say_what_strings: Data: 0.00MB + Index: 0.00MB wp_simple_history: Data: 0.06MB + Index: 0.02MB wp_simple_history_contexts: Data: 0.21MB + Index: 0.11MB wp_termmeta: Data: 0.04MB + Index: 0.01MB wp_terms: Data: 0.00MB + Index: 0.01MB wp_term_relationships: Data: 0.03MB + Index: 0.08MB wp_term_taxonomy: Data: 0.01MB + Index: 0.01MB wp_usermeta: Data: 0.04MB + Index: 0.03MB wp_users: Data: 0.00MB + Index: 0.01MB wp_wcpdf_invoice_number: Data: 0.00MB + Index: 0.00MB wp_wc_download_log: Data: 0.00MB + Index: 0.00MB wp_wc_webhooks: Data: 0.00MB + Index: 0.00MB wp_wpmelon_advbedit_temp: Data: 0.00MB + Index: 0.00MB wp_wpmm_subscribers: Data: 0.00MB + Index: 0.00MB wp_yoast_seo_links: Data: 0.01MB + Index: 0.00MB wp_yoast_seo_meta: Data: 0.01MB + Index: 0.01MB ### Post Type Counts ### attachment: 140 avada_faq: 16 flamingo_contact: 368 flamingo_inbound: 1164 fusion_element: 4 nav_menu_item: 8 page: 11 popup: 1 popup_theme: 6 post: 2 postman_sent_mail: 250 product: 38 product_variation: 91 revision: 270 shop_order: 221 shop_order_refund: 7 slide: 27 wpcf7_contact_form: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (36) ### ManageWP - Worker: by ManageWP – 4.6.3 Advanced Woo Search PRO: by ILLID – 1.00 – Not tested with the active version of WooCommerce BackWPup: by Inpsyde GmbH – 3.6.6 Contact Form 7: by Takayuki Miyoshi – 5.1.1 Duplicate Post: by Enrico Battocchi – 3.2.2 Flamingo: by Takayuki Miyoshi – 1.9 Fusion Builder: by ThemeFusion – 1.7.2 Fusion Core: by ThemeFusion – 3.7.2 Google Captcha (reCAPTCHA) by BestWebSoft: by BestWebSoft – 1.38 Instagram Feed Pro Business: by Smash Balloon – 2.7 Limit Login Attempts Reloaded: by wpchefgadget – 2.7.1 Login Logo: by Mark Jaquith – 0.9.0 Popup Maker: by WP Popup Maker – 1.7.30 Postman SMTP: by Jason Hendriks – 1.7.2 Say What?: by Lee Willis – 1.9.1 Search & Replace: by Inpsyde GmbH – 3.1.2 SeedProd Coming Soon Page Pro: by SeedProd – 5.10.6 SeedProd Login Page Pro: by SeedProd – 1.1.9 Shortcode Pagination for WooCommerce: by James Kemp – 1.0.10 – Not tested with the active version of WooCommerce Simple History: by P?r Thernstr?m – 2.28.1 String Locator: by Clorith – 2.3.1 User Role Editor: by Vladimir Garagulya – 4.47 Woocommerce Advanced Bulk Edit: by George Iron – 4.2.1 – Not tested with the active version of WooCommerce WooCommerce PayPal Pro (Classic and PayFlow Editions) Gateway: by WooCommerce – 4.4.6 – 4.4.15 is available – Not tested with the active version of WooCommerce WooCommerce PDF Invoices & Packing Slips: by Ewout Fernhout – 2.2.4 WooCommerce PDF Invoices & Packing Slips Premium Templates: by Ewout Fernhout – 2.3.2 – Not tested with the active version of WooCommerce WooCommerce Prices By User Role: by Festi-Team – 3.1.1 – Not tested with the active version of WooCommerce WooCommerce Products Visibility: by codemine – 2.0 – 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 Shipment Tracking: by WooCommerce – 1.6.3 – 1.6.12 is available – Not tested with the active version of WooCommerce WooCommerce: by Automattic – 3.5.1 – 3.5.3 is available Yoast SEO: by Team Yoast – 9.2.1 WP Maintenance Mode: by Designmodo – 2.2.2 WP Notification Bars: by MyThemeShop – 1.0.5 WPide: by Simon @ WPsites – 2.4.0 WP Overnight Sidekick: by Jeremiah Prummer Ewout Fernhout Michael Kluver – 2.0.3 ### Settings ### API Enabled: ? Force SSL: ? Currency: USD ($) 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) ### WC Pages ### Shop base: #286 - /store/ Cart: #33 - /cart/ Checkout: #34 - /checkout/ My account: #35 - /wholesale/ Terms and conditions: ? Page not set ### Theme ### Name: Avada Version: 5.7.2 Author URL: https://themeforest.net/user/ThemeFusion 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 ### Overrides: Avada/woocommerce/cart/cart.php Avada/woocommerce/checkout/form-pay.php Avada/woocommerce/checkout/review-order.php Avada/woocommerce/checkout/thankyou.php Avada/woocommerce/loop/loop-start.php Avada/woocommerce/single-product/add-to-cart/variable.php Avada/woocommerce/single-product/short-description.php Avada/woocommerce/single-product/tabs/additional-information.php Avada/woocommerce/single-product/tabs/description.php
Let me know if someone can take a peek at this. Happy to provide additional details as necessary. Thank you!
Did the invalid transients return to your database?
Try locating this string: woocommerce_related_products
Hi @Soft79-
Not really sure what is going on here. The error message has changed though:
Warning: Illegal string offset ‘limit=4&exclude_ids%5B0%5D=0&exclude_ids%5B1%5D=2205’ in /home/teetotinc/public_html/wp-content/plugins/woocommerce/includes/wc-product-functions.php on line 906
I looked for “woocommerce_related_products” with the String Locator plugin and got this output.
Just for reference, here’s what line 906 is in /home/teetotinc/public_html/wp-content/plugins/woocommerce/includes/wc-product-functions.php
It’s calling something:
$transient[ $query_args ] = $related_posts;
I’m suspecting this has something to do with related items in the same category / tag that are supposed to be displayed on each product page? I can’t remember how this looked when it was working properly or when this message was not being displayed.
Try upgrading the “WooCommerce Products Visibility” plugin, it’s very outdated (pre-WC3). In the changelog I see version 2.12 has this fix:
= 25.07.2018 version 2.12
* Fix – WooCommerce related products fixDo you have more very outdated plugins? Update them.
Ahhh yes! You found it. Still, I am not quite clear on why when I disabled all plugins, there was still an error appearing on the product page.
Turns out this was a manually installed plugin that came from codecanyon that never alerts when it has an update. All updates need to be installed manually by downloading the zip an re-installing.
Ugh, I apologize for all the run around. Thanks for all your help!
Kudos to @Soft79 for finding the offending plugin!
- The topic ‘WooCommerce upgrade 2.8 > 3.5 – “Scalar value” warning’ is closed to new replies.