verbb / snipcart

A Craft CMS plugin to integrate with Snipcart.
Other
21 stars 9 forks source link

Plugin fails to migrate to Craft 5 #66

Closed elvdm closed 3 months ago

elvdm commented 5 months ago

Describe the bug

While trying to upgrade to Craft 5 from Craft 4.9.2 using ddev composer update and then ddev php craft up, the migration fails due to this error:

*** applying m230511_000000_field_layout_configs
Exception: Setting unknown property: verbb\snipcart\fields\ProductDetails::columnType (/var/www/html/vendor/yiisoft/yii2/base/Component.php:209)
#0 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('columnType', Array)
#1 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(verbb\snipcart\fields\ProductDetails), Array)
#2 /var/www/html/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#3 /var/www/html/vendor/craftcms/cms/src/base/Field.php(271): craft\base\Model->__construct(Array)
#4 [internal function]: craft\base\Field->__construct(Array)
#5 /var/www/html/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#6 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('verbb\\snipcart\\...', Array, Array)
#7 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('verbb\\snipcart\\...', Array, Array)
#8 /var/www/html/vendor/craftcms/cms/src/Craft.php(70): yii\BaseYii::createObject(Array, Array)
#9 /var/www/html/vendor/craftcms/cms/src/helpers/Component.php(142): Craft::createObject(Array)
#10 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(372): craft\helpers\Component::createComponent(Array, 'craft\\base\\Fiel...')
#11 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(399): craft\services\Fields->createField(Array)
#12 [internal function]: craft\services\Fields->craft\services\{closure}(Array, 10)
#13 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(90): call_user_func(Object(Closure), Array, 10)
#14 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(171): craft\base\MemoizableArray->normalizeByKey(10)
#15 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(497): craft\base\MemoizableArray->firstWhere('uid', 'b3ed16c8-fc50-4...', true)
#16 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(183): craft\services\Fields->getFieldByUid('b3ed16c8-fc50-4...')
#17 /var/www/html/vendor/yiisoft/yii2/base/Component.php(180): craft\fieldlayoutelements\CustomField->setFieldUid('b3ed16c8-fc50-4...')
#18 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('fieldUid', 'b3ed16c8-fc50-4...')
#19 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\fieldlayoutelements\CustomField), Array)
#20 /var/www/html/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#21 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(73): craft\base\Model->__construct(Array)
#22 /var/www/html/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(47): craft\fieldlayoutelements\BaseField->__construct(Array)
#23 [internal function]: craft\fieldlayoutelements\CustomField->__construct(NULL, Array)
#24 /var/www/html/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#25 /var/www/html/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\fieldlayo...', Array, Array)
#26 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\fieldlayo...', Array, Array)
#27 /var/www/html/vendor/craftcms/cms/src/Craft.php(70): yii\BaseYii::createObject(Array, Array)
#28 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(1033): Craft::createObject(Array)
#29 /var/www/html/vendor/craftcms/cms/src/models/FieldLayoutTab.php(281): craft\services\Fields->createLayoutElement(Array)
#30 /var/www/html/vendor/yiisoft/yii2/base/Component.php(180): craft\models\FieldLayoutTab->setElements(Array)
#31 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('elements', Array)
#32 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\models\FieldLayoutTab), Array)
#33 /var/www/html/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#34 /var/www/html/vendor/craftcms/cms/src/models/FieldLayoutTab.php(140): craft\base\Model->__construct(Array)
#35 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(923): craft\models\FieldLayoutTab->__construct(Array)
#36 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(849): craft\services\Fields->_legacyTabsByLayoutId(Object(craft\models\FieldLayout))
#37 [internal function]: craft\services\Fields->craft\services\{closure}(Array, 4)
#38 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(90): call_user_func(Object(Closure), Array, 4)
#39 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(76): craft\base\MemoizableArray->normalizeByKey(4)
#40 [internal function]: craft\base\MemoizableArray->craft\base\{closure}(4)
#41 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(76): array_map(Object(Closure), Array)
#42 /var/www/html/vendor/craftcms/cms/src/base/MemoizableArray.php(104): craft\base\MemoizableArray->normalize(Array)
#43 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(937): craft\base\MemoizableArray->all()
#44 /var/www/html/vendor/craftcms/cms/src/migrations/m230511_000000_field_layout_configs.php(25): craft\services\Fields->getAllLayouts()
#45 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\m230511_000000_field_layout_configs->safeUp()
#46 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#47 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(382): yii\console\controllers\BaseMigrateController->migrateUp('m230511_000000_...')
#48 [internal function]: craft\console\controllers\MigrateController->actionAll()
#49 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#50 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#51 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#52 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(195): yii\console\Controller->runAction('all', Array)
#53 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction('all', Array)
#54 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#55 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('migrate/all', Array)
#56 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction('migrate/all', Array)
#57 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(207): yii\base\Controller->run('migrate/all', Array)
#58 /var/www/html/vendor/craftcms/cms/src/console/controllers/UpController.php(60): craft\console\Controller->run('migrate/all', Array)
#59 [internal function]: craft\console\controllers\UpController->actionIndex()
#60 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#61 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#62 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('', Array)
#63 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(89): yii\console\Controller->runAction('', Array)
#64 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction('', Array)
#65 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('', Array)
#66 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('up', Array)
#67 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('up', Array)
#68 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('up', Array)
#69 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#70 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#71 /var/www/html/craft(13): yii\base\Application->run()
#72 {main}
*** failed to apply m230511_000000_field_layout_configs (time: 0.018s)

If I upgrade to Craft 5 without the plugin, it runs smoothly. If I try to then install the Snipcart plugin from the Plugin Store on the Craft 5 control panel, I run across a similar error as follows. As soon as I disable the Snipcart plugin using the command line, the errors disappear and I can use Craft 5 as usual.

Unknown Property – [yii\base\UnknownPropertyException](https://www.yiiframework.com/doc-2.0/yii-base-unknownpropertyexception.html)
Setting unknown property: verbb\snipcart\fields\ProductDetails::columnType
1. in /var/www/html/vendor/yiisoft/yii2/base/Component.phpat line 209
2. in /var/www/html/vendor/yiisoft/yii2/BaseYii.php at line 558– [yii\base\Component::__set](https://www.yiiframework.com/doc-2.0/yii-base-component.html#__set()-detail)('columnType', ['sku' => 'string', 'inventory' => 'integer', 'price' => 'money', 'taxable' => 'boolean', ...])
3. in /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php at line 107– [yii\BaseYii::configure](https://www.yiiframework.com/doc-2.0/yii-baseyii.html#configure()-detail)(verbb\snipcart\fields\ProductDetails, ['id' => 15, 'dateCreated' => DateTime, 'dateUpdated' => DateTime, 'name' => 'Product Details', ...])
4. in /var/www/html/vendor/craftcms/cms/src/base/Model.php at line 78– [yii\base\BaseObject::__construct](https://www.yiiframework.com/doc-2.0/yii-base-baseobject.html#__construct()-detail)(['id' => 15, 'dateCreated' => DateTime, 'dateUpdated' => DateTime, 'name' => 'Product Details', ...])
5. in /var/www/html/vendor/craftcms/cms/src/base/Field.php at line 271– craft\base\Model::__construct(['id' => 15, 'dateCreated' => DateTime, 'dateUpdated' => DateTime, 'name' => 'Product Details', ...])

Steps to reproduce

  1. Upgrade to Craft 5
  2. Install Snipcart plugin
  3. Get errors

Craft CMS version

5.1.7

Plugin version

3.0.0

Multi-site?

No

Additional context

PHP version: 8.2.13

Other plugins installed: CKEditor, CP Clear Cache, CP Field Inspect, Control Panel CSS, Dumper, Elements Panel, Empty Coalesce, Mix, Sprig

Disabling all of these does not prevent the errors occurring when trying to install the Snipcart Plugin.

engram-design commented 5 months ago

Should be fixed for the next release. To get this early, run composer require verbb/snipcart:"dev-craft-5 as 3.0.0".

elvdm commented 5 months ago

It does appear to be fixed now. Thanks!

engram-design commented 3 months ago

Fixed in 3.0.1