verbb / tablemaker

A user-definable table field type for Craft CMS
MIT License
40 stars 32 forks source link

Undefined constant craft\services\Plugins::CONFIG_PLUGINS_KEY #30

Closed seb-jones closed 2 years ago

seb-jones commented 2 years ago

Description

We are getting the following error when running craft migrate/all after installing this plugin via composer, on an existing Craft site that has recently been upgraded from v3 to v4.

Exception: Undefined constant craft\services\Plugins::CONFIG_PLUGINS_KEY (/sites/craft-framework/releases/4/vendor/verbb/tablemaker/src/migrations/m190412_182837_update_craft2_fieldtype.php:26)
#0 /sites/craft-framework/releases/4/vendor/craftcms/cms/src/db/Migration.php(49): verbb\tablemaker\migrations\m190412_182837_update_craft2_fieldtype->safeUp()
#1 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#2 /sites/craft-framework/releases/4/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp()
#3 [internal function]: craft\console\controllers\MigrateController->actionAll()
#4 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#5 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#6 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/console/Controller.php(182): yii\base\Controller->runAction()
#7 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction()
#8 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#9 /sites/craft-framework/releases/4/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction()
#10 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#11 /sites/craft-framework/releases/4/vendor/yiisoft/yii2/base/Application.php(384): yii\console\Application->handleRequest()
#12 /sites/craft-framework/releases/4/craft(27): yii\base\Application->run()
#13 {main}
*** failed to apply m190412_182837_update_craft2_fieldtype (time: 0.008s)
0 from 2 migrations were applied.
Migration failed. The rest of the migrations are canceled.

Additional info

Additional context

It looks like the issue is coming from this line.

I note that the CONFIG_PLUGINS_KEY constant isn't defined in the Plugins service in the Craft 4 repo, but is present in the same class in Craft 3, so I think your use of CONFIG_PLUGINS_KEY needs to be updated.

engram-design commented 2 years ago

Actually going to remove the Craft 2 migration, as it's just more cruft we don't need for Craft 4 and onwards. I'm also adding a requirement to update to the latest version (3.0.0) for Craft 3 before updating to Craft 4, which is just a general good practice to ensure we don't have to handle lots of different Craft versions to upgrade from.

Fixed in 4.0.1

seb-jones commented 2 years ago

Thank you very much for the quick fix :)