craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
219 stars 170 forks source link

[5.x]: failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: Attempt to read property "id" on null #3479

Closed alexanderloewe closed 4 months ago

alexanderloewe commented 5 months ago

What happened?

Description

By trying to install a fresh Craft CMS site with configs i get this error:

failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: Attempt to read property "id" on null

Steps to reproduce

  1. install craft cms with configs

Actual behavior

  > add foreign key fk_bxzgavushxnwanunfvflhjuancsmfbkzfbes: {{%neoblocktypes}} (fieldLayoutId) references {{%fieldlayouts}} (id) ... done (time: 0.063s)
    > add foreign key fk_pglxbhftqqmceafkgxgxvlsmaxsxfnqixxpp: {{%neoblocktypes}} (groupId) references {{%neoblocktypegroups}} (id) ... done (time: 0.057s)
    > add foreign key fk_oovrnhyvvttkktmxbvbxskutxzoyptjzzuey: {{%neoblocktypes}} (iconId) references {{%assets}} (id) ... done (time: 0.065s)
    > add foreign key fk_fwbfwhetnjovhruoiyhrzxtrtpugedpenrmf: {{%neoblocktypegroups}} (fieldId) references {{%fields}} (id) ... done (time: 0.042s)
done
    > installing seomate ... done
    > applying existing project config ... Exception: Attempt to read property "id" on null (/home/wiqusaha/public_html/nektar/vendor/craftcms/commerce/src/services/OrderStatuses.php:337)
#0 /home/wiqusaha/public_html/nektar/vendor/craftcms/commerce/src/services/OrderStatuses.php(337): yii\base\ErrorHandler->handleError(2, 'Attempt to read...', '/home/wiqusaha/...', 337)
craftcms/cms#1 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/services/ProjectConfig.php(1177): craft\commerce\services\OrderStatuses->handleChangedOrderStatus(Object(craft\events\ConfigEvent))
craftcms/cms#2 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
craftcms/cms#3 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/Component.php(633): call_user_func(Array, Object(craft\events\ConfigEvent))
craftcms/cms#4 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger('addItem', Object(craft\events\ConfigEvent))
craftcms/cms#5 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/services/ProjectConfig.php(1167): craft\models\ProjectConfigData->commitChanges(NULL, Array, 'commerce.orderS...')
craftcms/cms#6 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
craftcms/cms#7 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/Component.php(633): call_user_func(Array, Object(craft\events\ConfigEvent))
craftcms/cms#8 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger('addItem', Object(craft\events\ConfigEvent))
craftcms/cms#9 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/services/ProjectConfig.php(1286): craft\models\ProjectConfigData->commitChanges(NULL, Array, 'commerce.orderS...', true, NULL, true)
craftcms/cms#10 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/services/ProjectConfig.php(1308): craft\services\ProjectConfig->craft\services\{closure}('commerce.orderS...', true)
craftcms/cms#11 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/services/ProjectConfig.php(627): craft\services\ProjectConfig->_applyChanges(Array, Object(craft\models\ProjectConfigData), Object(craft\models\ReadOnlyProjectConfigData))
craftcms/cms#12 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/migrations/Install.php(1123): craft\services\ProjectConfig->applyExternalChanges()
craftcms/cms#13 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/migrations/Install.php(79): craft\migrations\Install->insertDefaultData()
craftcms/cms#14 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\Install->safeUp()
craftcms/cms#15 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up(true)
craftcms/cms#16 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/console/controllers/InstallController.php(213): craft\db\MigrationManager->migrateUp(Object(craft\migrations\Install))
craftcms/cms#17 [internal function]: craft\console\controllers\InstallController->actionCraft()
craftcms/cms#18 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
craftcms/cms#19 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
craftcms/cms#20 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('', Array)
craftcms/cms#21 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/console/ControllerTrait.php(89): yii\console\Controller->runAction('', Array)
craftcms/cms#22 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction('', Array)
craftcms/cms#23 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('', Array)
craftcms/cms#24 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('install', Array)
#25 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('install', Array)
#26 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('install', Array)
#27 /home/wiqusaha/public_html/nektar/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#28 /home/wiqusaha/public_html/nektar/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#29 /home/wiqusaha/public_html/nektar/craft(24): yii\base\Application->run()
#30 {main}
*** failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: Attempt to read property "id" on null

Craft CMS version

5.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

    "craftcms/ckeditor": "4.0.4",
    "craftcms/cms": "^5.1.1",
    "craftcms/commerce": "5.0.3",
    "nystudio107/craft-minify": "5.0.0",
    "putyourlightson/craft-campaign": "3.1.2",
    "spicyweb/craft-neo": "5.0.0-beta.10",
    "vaersaagod/seomate": "3.0.0-beta.6",
    "vandres/craft-matrix-extended": "v2.1.0",
    "vlucas/phpdotenv": "^5.6.0"
linear[bot] commented 5 months ago

PT-1698 [5.x]: failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: Attempt to read property "id" on null

brandonkelly commented 5 months ago

Hey @alexanderloewe, this error is coming from Craft Commerce, so transferred the issue to that repo. We’ll look into it!

lukas-jansen commented 5 months ago

Haven't tested it yet, but it should have been fixed in 5.0.3

https://github.com/craftcms/commerce/issues/3472

lukeholder commented 5 months ago

@alexanderloewe Looks like you have an existing project config in place before installing Craft (and Craft Commerce).

Could you send your backup project config folder (config/project) (that you are using before installing Craft) to support@craftcms.com with your composer.json and composer.lock and we will take a look.

Thanks

lukeholder commented 4 months ago

@alexanderloewe Thanks for reporting this. I believe we have fixed this for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#4b6c47df84e2cf67b91c12ed1494ba7e112aad82 as 5.0.4",
  "...": "..."
}

Then run composer update.

We will update this github issue once the release is out.