craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Migration error related to Asset Metadata plugin when attempting to update from Craft 3.7.11 to 3.7.13 #9890

Closed ademers closed 3 years ago

ademers commented 3 years ago

Description

I get the following migration error related to the Asset Metadata plugin when attempting to update from from Craft 3.7.11 to 3.7.13. I had no issues updating to previous versions of 3.7 Migration file: https://github.com/carlcs/craft-assetmetadata/blob/v3/src/migrations/m180919_000000_craft3.php

Checking for pending migrations ...
Total 1 new Asset Metadata migration to be applied:
    - m180919_000000_craft3

Backing up the database ... done
*** applying m180919_000000_craft3
    > update in {{%fields}} ... done (time: 0.002s)
Exception: Undefined index: defaultValue (/home/vagrant/sites/example/vendor/carlcs/craft-assetmetadata/src/migrations/m180919_000000_craft3.php:39)
#0 /home/vagrant/sites/example/vendor/carlcs/craft-assetmetadata/src/migrations/m180919_000000_craft3.php(39): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/home/vagrant/s...', 39, Array)
#1 /home/vagrant/sites/example/vendor/craftcms/cms/src/db/Migration.php(52): carlcs\assetmetadata\migrations\m180919_000000_craft3->safeUp()
#2 /home/vagrant/sites/example/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#3 /home/vagrant/sites/example/vendor/craftcms/cms/src/console/controllers/MigrateController.php(384): yii\console\controllers\BaseMigrateController->migrateUp('m180919_000000_...')
#4 [internal function]: craft\console\controllers\MigrateController->actionAll()
#5 /home/vagrant/sites/example/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /home/vagrant/sites/example/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#7 /home/vagrant/sites/example/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction('all', Array)
#8 /home/vagrant/sites/example/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction('all', Array)
#9 /home/vagrant/sites/example/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction('migrate/all', Array)
#10 /home/vagrant/sites/example/vendor/craftcms/cms/src/console/Application.php(89): yii\console\Application->runAction('migrate/all', Array)
#11 /home/vagrant/sites/example/vendor/yiisoft/yii2/console/Application.php(148): craft\console\Application->runAction('migrate/all', Array)
#12 /home/vagrant/sites/example/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /home/vagrant/sites/example/craft(22): yii\base\Application->run()
#14 {main}
*** failed to apply m180919_000000_craft3 (time: 0.033s)

0 from 1 migrations were applied.

Migration failed. The rest of the migrations are canceled.

Steps to reproduce

  1. Attempt to update from Craft 3.7.11 to 3.7.13
  2. Run ./craft migrate/all --interactive=0
  3. See migration error above.

Additional info

ademers commented 3 years ago

Apparently, changing:

                    $newSubfields[$key] = [
                        'name' => $subfield['name'],
                        'handle' => $subfield['handle'],
                        'template' => $subfield['defaultValue'],
                    ];

to

                    $newSubfields[$key] = [
                        'name' => $subfield['name'],
                        'handle' => $subfield['handle'],
                        'template' => $subfield['defaultValue'] ?? null,
                    ];

may fix it. I'll open an issue and/or PR in the plugin repo.

brandonkelly commented 3 years ago

Yeah this needs to be reported to the offending plugin. Nothing we can do about it.