bigcommerce / bigcommerce-for-wordpress

A headless commerce integration for WordPress, powered by BigCommerce
https://www.bigcommerce.com/wordpress/
GNU General Public License v2.0
109 stars 49 forks source link

Product sync stuck at 'requesting store information' #407

Closed zdlldz closed 1 year ago

zdlldz commented 1 year ago

Greetings -- Longtime store seeing issues with product sync since recent php8.0 upgrade (same on php8.1).

Product sync is frozen at Step 1: Fetching store information. Headless sync option has same problem; new/updated + all products options both stuck.

Wordpress logs show no errors. BC logs are an endless loop of:

BigCommerce.INFO: Running import task {"state":"started","description":"Fetching store information"} []
BigCommerce.DEBUG: Requesting store settings [] []

Any ideas?

rmykolas commented 1 year ago

I am working with @zdlldz on this issue and I am now fairly certain that this is an issue with the BC4WP compatibility with PHP 8. A few steps that I took to test this out:

  1. Create two identical copies of the website and set them up locally.
  2. One install runs of PHP 8.0.22 and the other on PHP 7.4.3.
  3. On the PHP 7 version, the sync went through just fine, while it fails just the same on the first step, on the PHP 8 version.

I even tried disabling all the plugins and enabling the Twenty-Twenty Three theme on the PHP 8 install to test for any plugin/theme incompatibility with no luck.

However, with the BC4WP 5.0.1 update it seems that now there's more potentially more helpful stuff being output in the error logs:


[2023-02-23 11:34:17] BigCommerce.DEBUG: #0 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Import/Task_Manager.php(91): BigCommerce\Import\Task_Manager->get_task('fetching_store') #1 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Import.php(369): BigCommerce\Import\Task_Manager->run_next('fetching_store') #2 /www/website/public/wp-includes/class-wp-hook.php(308): BigCommerce\Container\Import->BigCommerce\Container\{closure}('fetching_store') #3 /www/website/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #4 /www/website/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Import/Runner/Cron_Runner.php(53): do_action('bigcommerce/imp...', 'fetching_store') #6 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Import.php(132): BigCommerce\Import\Runner\Cron_Runner->continue_import() #7 /www/website/public/wp-includes/class-wp-hook.php(306): BigCommerce\Container\Import->BigCommerce\Container\{closure}() #8 /www/website/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) #9 /www/website/public/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #10 /www/website/public/wp-cron.php(188): do_action_ref_array('bigcommerce_con...', Array) #11 {main} [] []
[2023-02-23 11:34:17] BigCommerce.INFO: Exit from 2nd thread because status is not allowed {"status":"fetching_store"} []
[2023-02-23 11:34:19] BigCommerce.NOTICE: No handler found for current import state {"state":"fetching_store"} []
[2023-02-23 11:34:19] BigCommerce.DEBUG: #0 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Settings/Import_Status.php(227): BigCommerce\Import\Task_Manager->get_task('fetching_store') #1 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Settings/Import_Status.php(139): BigCommerce\Settings\Import_Status->get_current_task('fetching_store') #2 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Settings/Import_Status.php(118): BigCommerce\Settings\Import_Status->current_status() #3 /www/website/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Settings.php(385): BigCommerce\Settings\Import_Status->ajax_current_status() #4 /www/website/public/wp-includes/class-wp-hook.php(306): BigCommerce\Container\Settings->BigCommerce\Container\{closure}() #5 /www/website/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #6 /www/website/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /www/website/public/wp-admin/admin-ajax.php(188): do_action('wp_ajax_bigcomm...') #8 {main} [] []
[2023-02-23 11:34:19] BigCommerce.NOTICE: Import process has been aborted. Run import cleanup [] []
[2023-02-23 11:34:19] BigCommerce.INFO: Clean tasks queue is empty [] []
[2023-02-23 11:34:19] BigCommerce.INFO: Import complete [] []
[2023-02-23 11:34:23] BigCommerce.INFO: Starting import [] []
[2023-02-23 11:34:23] BigCommerce.INFO: Clean tasks queue is empty [] []
[2023-02-23 11:34:24] BigCommerce.INFO: Running import task {"state":"started","description":"Fetching store information"} []
[2023-02-23 11:34:24] BigCommerce.DEBUG: Requesting store settings [] []
[2023-02-23 11:35:25] BigCommerce.INFO: Exit from 2nd thread because status is not allowed {"status":"fetching_store"} []```
MlKilderkin commented 1 year ago

Hello @rmykolas @zdlldz

It will be nice if you try once more. But before you do that would you please clear server cache(if it is applicable), and re-run import. Please also check that WP-Cron runs without error. If you still have such issue it will be also good to check server error logs(not only the plugin). Unfortunately we are not able to replicate this error on our end on PHP8.0.2 setup or any other. You can also contact Bigcommerce Support and provide them extra details:

  1. Server error logs during import run
  2. Full plugin logs
  3. Maybe extra details about environment
  4. You can also provide for them temporary login(with admin rights). That will help us check your setup and maybe found a root cause of issue

From my experience very often this issue may appear due to incorrect permissions on folder, missing PHP-ext, not-enough scopes for Bigcommerce credentials or WP-Cron problems.

We are still investigating on our end and if you can provide information to us via Bigcommerce support it may us help identify the problem. Thank you

rmykolas commented 1 year ago

@MlKilderkin thanks for the extra details, I installed one of the WP Cron status plugins and noticed that whenever I try to trigger a BC product sync, the bigcommerce_continue_import hook fails:

CleanShot 2023-03-09 at 13 06 25@2x

With the following error:

Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, bool given in /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Api/Store_Api.php:104
Stack trace:
#0 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Api/Store_Api.php(104): array_map(Object(Closure), false)
#1 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Import/Processors/Store_Settings.php(64): BigCommerce\Api\Store_Api->get_analytics_settings()
#2 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Import.php(249): BigCommerce\Import\Processors\Store_Settings->run()
#3 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Import/Task_Manager.php(97): BigCommerce\Container\Import->BigCommerce\Container\{closure}('fetching_store')
#4 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Import.php(340): BigCommerce\Import\Task_Manager->run_next('fetching_store')
#5 /www/redacted/public/wp-includes/class-wp-hook.php(308): BigCommerce\Container\Import->BigCommerce\Container\{closure}('fetching_store')
#6 /www/redacted/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#7 /www/redacted/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#8 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Import/Runner/Cron_Runner.php(51): do_action('bigcommerce/imp...', 'fetching_store')
#9 /www/redacted/public/wp-content/plugins/bigcommerce/src/BigCommerce/Container/Import.php(115): BigCommerce\Import\Runner\Cron_Runner->continue_import()
#10 /www/redacted/public/wp-includes/class-wp-hook.php(306): BigCommerce\Container\Import->BigCommerce\Container\{closure}()
#11 /www/redacted/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#12 /www/redacted/public/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#13 /www/redacted/public/wp-cron.php(188): do_action_ref_array('bigcommerce_con...', Array)
#14 {main}
thrown
MlKilderkin commented 1 year ago

Awesome, thank you @rmykolas for additional details. I'll check and try to handle this

rmykolas commented 1 year ago

I just realized that this issue was present with the BC4WP plugin version 4.36.0, but just tested it with 5.0.1 and it's exactly the same.

rmykolas commented 1 year ago

@MlKilderkin any update on the issue? Also by reading the code it seems that unchecking the "Keep analytics tracking IDs in sync with your BigCommerce store settings" checkbox made the sync bypass the wrong code and make the sync run:

CleanShot 2023-03-15 at 18 53 55@2x
MlKilderkin commented 1 year ago

Hello @rmykolas The issue is found it is related to analytics settings. v2 API has been deprecated and that caused the issue. Right now this and other issue in QA. The ETA for next release is 1-2 weeks