verbb / cp-nav

Control Panel Nav is a Craft CMS plugin to help manage your Control Panel navigation.
MIT License
129 stars 11 forks source link

Migration failure when updating Craft to v4 #126

Closed tyssen closed 9 months ago

tyssen commented 1 year ago

Describe the bug

I'm trying to upgrade a 3.x site to the latest 4.x and have got to step 9 from https://craftcms.com/docs/4.x/upgrade.html craft migrate/all and get the following error:

*** applying m220409_000000_craft_4
    > update in {{%cpnav_navigation}} ... done (time: 0.005s)
    > dropping {{%cpnav_pending_navigations}} if it exists ... done (time: 0.002s)
    > update in {{%cpnav_navigation}} ... done (time: 0.000s)
   …
    > update in {{%cpnav_navigation}} ... done (time: 0.000s)
Exception: verbb\cpnav\services\Layouts::getLayoutByUid(): Argument #1 ($layoutUid) must be of type string, null given, called in /var/www/html/vendor/verbb/cp-nav/src/services/Navigations.php on line 122 (/var/www/html/vendor/verbb/cp-nav/src/services/Layouts.php:61)
#0 /var/www/html/vendor/verbb/cp-nav/src/services/Navigations.php(122): verbb\cpnav\services\Layouts->getLayoutByUid(NULL)
#1 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1126): verbb\cpnav\services\Navigations->handleChangedNavigation(Object(craft\events\ConfigEvent))
#2 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
#3 /var/www/html/vendor/yiisoft/yii2/base/Component.php(633): call_user_func(Array, Object(craft\events\ConfigEvent))
#4 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger('updateItem', Object(craft\events\ConfigEvent))
#5 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(516): craft\models\ProjectConfigData->commitChanges(Array, Array, 'cp-nav.navigati...', true, NULL, true)
#6 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(476): craft\services\ProjectConfig->_setInternal('cp-nav.navigati...', Array, NULL, true, false)
#7 /var/www/html/vendor/verbb/cp-nav/src/migrations/m220409_000000_craft_4.php(160): craft\services\ProjectConfig->set('cp-nav.navigati...', Array)
#8 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(49): verbb\cpnav\migrations\m220409_000000_craft_4->safeUp()
#9 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#10 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(358): yii\console\controllers\BaseMigrateController->migrateUp('m220409_000000_...')
#11 [internal function]: craft\console\controllers\MigrateController->actionAll()
#12 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#14 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#15 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(87): yii\console\Controller->runAction('all', Array)
#16 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction('all', Array)
#17 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#18 /var/www/html/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('migrate/all', Array)
#19 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#20 /var/www/html/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#21 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#22 /var/www/html/craft(22): yii\base\Application->run()
#23 {main}

Steps to reproduce

  1. Steps 1-8 from https://craftcms.com/docs/4.x/upgrade.html
  2. Get stuck on Step 9.

Craft CMS version

Upgrading from 3.8.14 to 4.4.14

Plugin version

Upgrading from 3.1.0 to 4.0.10

Multi-site?

No

Additional context

No response

tyssen commented 1 year ago

I've now uninstalled the plugin, run the migrations, reinstalled the plugin and recreated the nav I had before. There was only one and it wasn't very complicated. So not a deal-breaker really, but thought I'd note it here in case someone else has the same problem.

engram-design commented 1 year ago

Fixed for the next release. To get this early run composer require verbb/cp-nav:"dev-craft-4 as 4.0.10" - appreciate the bug report.

engram-design commented 9 months ago

Fixed in 4.0.11