dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
48 stars 64 forks source link

Error: Unable to apply data patch Dotdigitalgroup\Email\Setup\Patch\Data\SetCronsWithOffset for module Dotdigitalgroup_Email #581

Closed amjadm61 closed 2 years ago

amjadm61 commented 2 years ago

current environment: Magento 2.4.2 Enterprise php version: 7.4.21

steps to reproduce:

  1. upgrade module from 4.10.0 to latest (4.14.1)
  2. run bin/magento setup:upgrade

Expected Result: setup upgrade should complete without any error

Actual Result: throwing an error during setup:upgrade Unable to apply data patch Dotdigitalgroup\Email\Setup\Patch\Data\SetCronsWithOffset for module Dotdigitalgroup_Email. Original exception message: Notice: Undefined offset: 1 in /var/www/html/vendor/dotdigital/dotdigital-magento2-extension/Setup/Patch/Data/SetCronsWithOffset.php on line 118

file: https://github.com/dotmailer/dotmailer-magento2-extension/blob/master/Setup/Patch/Data/SetCronsWithOffset.php#L118 line: $offset = (int) explode("*", explode("/", $configuration["value"])[1])[0];

sta1r commented 2 years ago

@amjadm61 Thanks for raising.

The patch script has discovered that you have existing Dotdigital cron configurations saved i.e.

connector_developer_settings/cron_schedules/importer
connector_developer_settings/cron_schedules/order
connector_developer_settings/cron_schedules/contact
connector_developer_settings/cron_schedules/catalog
connector_developer_settings/cron_schedules/review_wishlist

However at least one of your paths has a value that does not contain a /. Perhaps you modified these in the past?

The default values are here: https://github.com/dotmailer/dotmailer-magento2-extension/blob/master/etc/config.xml#L315-L321

We'll add some error handling into the patch, but for you in the meantime you could simply remove or update any connector_developer_settings/cron_schedules values so that they contain a /, so the explode() will function correctly.

sta1r commented 2 years ago

We've realised that if you had cron schedules set to 'Every 60 minutes' this stores a value of 00 * * * * in the table - and these rows would break at the explode().

So - you can change any such settings to e.g. every 30 minutes, run the upgrade, then set them back once the patch is run successfully.

amjadm61 commented 2 years ago

@sta1r Thanks. it worked

sta1r commented 2 years ago

This is fixed in 4.15.1.