craftcms / cms

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

3.5.0-RC3: Undefined index: siteSettings on craft\migrations\m200620_230205_field_layout_changes migration #6464

Closed kjmartens closed 4 years ago

kjmartens commented 4 years ago

Description

Trying to upgrade a site from Craft 3.4.29.1 to 3.5.0-RC3, and I am getting this error during migration:

yii\base\ErrorException: Undefined index: siteSettings

Migration: craft\migrations\m200620_230205_field_layout_changes

Output:

> add column elements text AFTER name to table {{%fieldlayouttabs}} ... done (time: 0.059s)
> drop column titleLabel from table {{%entrytypes}} ... done (time: 0.076s)
Exception: Undefined index: siteSettings (/mypath/vendor/craftcms/cms/src/services/Sections.php:606)
#0 /mypath/vendor/craftcms/cms/src/web/ErrorHandler.php(75): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/mypath/...', 606)
#1 /mypath/vendor/craftcms/cms/src/services/Sections.php(606): craft\web\ErrorHandler->handleError(8, 'Undefined index...', '/mypath/...', 606, Array)
#2 /mypath/vendor/craftcms/cms/src/services/ProjectConfig.php(1087): craft\services\Sections->handleChangedSection(Object(craft\events\ConfigEvent))
#3 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
#4 /mypath/vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(craft\events\ConfigEvent))
#5 /mypath/vendor/craftcms/cms/src/services/ProjectConfig.php(665): yii\base\Component->trigger('updateItem', Object(craft\events\ConfigEvent))
#6 /mypath/vendor/craftcms/cms/src/services/ProjectConfig.php(1077): craft\services\ProjectConfig->processConfigChanges('sections.5387d1...')
#7 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
#8 /mypath/vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(craft\events\ConfigEvent))
#9 /mypath/vendor/craftcms/cms/src/services/ProjectConfig.php(665): yii\base\Component->trigger('updateItem', Object(craft\events\ConfigEvent))
#10 /mypath/vendor/craftcms/cms/src/services/ProjectConfig.php(476): craft\services\ProjectConfig->processConfigChanges('sections.5387d1...', true, '')
#11 /mypath/vendor/craftcms/cms/src/migrations/m200620_230205_field_layout_changes.php(87): craft\services\ProjectConfig->set('sections.5387d1...', Array)
#12 /mypath/vendor/craftcms/cms/src/migrations/m200620_230205_field_layout_changes.php(36): craft\migrations\m200620_230205_field_layout_changes->_updateEntryTypeFieldLayouts(Object(craft\services\ProjectConfig))
#13 /mypath/vendor/craftcms/cms/src/db/Migration.php(52): craft\migrations\m200620_230205_field_layout_changes->safeUp()
#14 /mypath/vendor/craftcms/cms/src/db/MigrationManager.php(228): craft\db\Migration->up(true)
#15 /mypath/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m200620_230205_field_layout_changes))
#16 /mypath/vendor/craftcms/cms/src/services/Updates.php(220): craft\db\MigrationManager->up()
#17 /mypath/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(509): craft\services\Updates->runMigrations(Array)
#18 /mypath/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#19 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#20 /mypath/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#21 /mypath/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#22 /mypath/vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('migrate', Array)
#23 /mypath/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#24 /mypath/vendor/craftcms/cms/src/web/Application.php(295): yii\base\Module->runAction('updater/migrate', Array)
#25 /mypath/vendor/craftcms/cms/src/web/Application.php(688): craft\web\Application->runAction('updater/migrate')
#26 /mypath/vendor/craftcms/cms/src/web/Application.php(228): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#27 /mypath/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#28 /mypath/public_html/index.php(21): yii\base\Application->run()
#29 {main}

Steps to reproduce

  1. Perform Craft 3.5.0-RC3 upgrade via Terminal
  2. Visit CP to run the updates.

Additional info

brandonkelly commented 4 years ago

Do you have a section that is somehow not enabled for any sites?

kjmartens commented 4 years ago

The site has a single site, with a single section (channel) that has a single Entry Type. :)

brandonkelly commented 4 years ago

Can you send a DB backup from before attempting the update over to support@craftcms.com, along with your Composer files?

kjmartens commented 4 years ago

Thanks, sent!

kjmartens commented 4 years ago

You can close this one out. I tried the migration on this affected database in a different environment and it worked correctly. Not sure what was up...

brandonkelly commented 4 years ago

Reopened as we've had a few other people experience the same error, though we have not been able to reproduce it yet, even with the backup/Composer files from affected installs.

kjmartens commented 4 years ago

I wonder if something related to this sort of bit me hard yesterday when I went to edit the option values of a Select dropdown field (field settings) (RC3). Upon saving the field, it appeared to wipe out all other fields in the database except that field and wiped other things like field layouts and groups, etc. The whole site became a disaster. I had a backup from previous day, but the client lost a solid 5hrs of data entry just before that.

Maybe it's completely unrelated, and/or maybe it's been fixed since, but I haven't had the guts to try it again yet. 😅 Feel very free to ignore this comment (as I have been able to sort of undo and move on), but thought I'd note this anyway. If the issue comes up again, I'll create a new GH issue.

2020-08-04 02:13:43 [-][1][9d5bb9402a3a15f3824bed8782648930][error][TypeError] TypeError: Argument 1 passed to craft\services\Fields::getGroupById() must be of the type integer, null given, called in /path/vendor/craftcms/cms/src/base/Field.php on line 554 and defined in /path/vendor/craftcms/cms/src/services/Fields.php:235
Stack trace:
#0 /path/vendor/craftcms/cms/src/base/Field.php(554): craft\services\Fields->getGroupById(NULL)
#1 /path/vendor/yiisoft/yii2/base/Component.php(139): craft\base\Field->getGroup()
#2 /path/vendor/craftcms/cms/src/helpers/Template.php(74): yii\base\Component->__get('group')
#3 /path/storage/runtime/compiled_templates/9d/9d72a9b9697a035ab1dc7c8575a3d0007dfeef3f8d691c68020ee61a4e35e63e.php(92): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\fields\Dropdown), 'group', Array)
#4 /path/vendor/twig/twig/src/Template.php(407): __TwigTemplate_9cb5303d604fb6ad5d22870c12ec6facfc36f556288ae685d7e9d6b3fb70922f->doDisplay(Array, Array)
#5 /path/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#6 /path/vendor/twig/twig/src/Template.php(392): Twig\Template->display(Array)
#7 /path/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#8 /path/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#9 /path/vendor/craftcms/cms/src/web/View.php(391): Twig\Environment->render('settings/fields', Array)
#10 /path/vendor/craftcms/cms/src/web/View.php(452): craft\web\View->renderTemplate('settings/fields', Array)
#11 /path/vendor/craftcms/cms/src/web/Controller.php(243): craft\web\View->renderPageTemplate('settings/fields', Array, 'cp')
#12 /path/vendor/craftcms/cms/src/controllers/TemplatesController.php(97): craft\web\Controller->renderTemplate('settings/fields', Array)
#13 [internal function]: craft\controllers\TemplatesController->actionRender('settings/fields', Array)
#14 /path/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /path/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#16 /path/vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('render', Array)
#17 /path/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#18 /path/vendor/craftcms/cms/src/web/Application.php(295): yii\base\Module->runAction('templates/rende...', Array)
#19 /path/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#20 /path/vendor/craftcms/cms/src/web/Application.php(280): yii\web\Application->handleRequest(Object(craft\web\Request))
#21 /path/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /path/public_html/index.php(21): yii\base\Application->run()
#23 {main}
2020-08-04 02:13:43 [-][1][9d5bb9402a3a15f3824bed8782648930][info][application] $_GET = [
    'p' => 'admin/settings/fields'
]
simondotwhite commented 4 years ago

I ran into this issue earlier as well (existing, heavily populated 3.4 site). If you want I can send over a DB and files?

Bronskiy commented 4 years ago

Got same error on 3 different projects

andris-sevcenko commented 4 years ago

@Sekonda please do! And reference this issue too, of course.

perry-garvin commented 4 years ago

I'm having this issue, too

brandonkelly commented 4 years ago

We haven’t been able to come up with reproducible steps for this in 3.5 yet, however we’ve managed to reliably reproduce it in 3.4. We just released Craft 3.5.1 with a fix based on what we found in 3.4, and hoping that will solve it for 3.5 as well. 🤞

If you’re still experiencing the issue after updating to 3.5.1, let me know and I’ll reopen this and we’ll continue looking into it.

Bronskiy commented 4 years ago

Just updated to 3.5.1 via composer but unfortunately it doesn't help. Still same error

brandonkelly commented 4 years ago

@Bronskiy Did you start from 3.4 or 3.5.0 when you tested the 3.5.1 update? We are hearing from one customer that 3.5.1 did in fact fix the bug, but only if they restored the DB/cache from 3.4.x.

simondotwhite commented 4 years ago

@brandonkelly Going from the 3.4.X straight to 3.5.1 worked for us on any projects that 3.5 didn't.

We restored the 3.4.X DB and cleared all caches before doing the upgrade.

Bronskiy commented 4 years ago

@Bronskiy Did you start from 3.4 or 3.5.0 when you tested the 3.5.1 update? We are hearing from one customer that 3.5.1 did in fact fix the bug, but only if they restored the DB/cache from 3.4.x.

I changed composer.json craft version to 3.4.30 and run composer update. Then I tried to run update from the dashboard but got the same error. Dashboard works in dev mode only otherwise it shows error. Frontend works in prod mode only. 3 different projects with same errors.

Sometimes during update it shows DB errors because there were some changes after 3.5 update. But it is fixable by removing 'elements' from fieldlayouttabs or adding 'titleLabel' to entrytypes tables and then I see 'Undefined index: siteSettings' error.

I don't have manual DB backup so I'm using DB that was restored by Craft

andris-sevcenko commented 4 years ago

@Bronskiy can you send over the DB backup to support@craftcms.com and reference this GH issue? I'll see if I can get it to update on my end and then just send it back to you. Please, also include your composer.json and composer.lock files, so I don't run into any errors about missing plugins and the like.

Bronskiy commented 4 years ago

@Bronskiy can you send over the DB backup to support@craftcms.com and reference this GH issue? I'll see if I can get it to update on my end and then just send it back to you. Please, also include your composer.json and composer.lock files, so I don't run into any errors about missing plugins and the like.

sent

simeon-smith commented 4 years ago

Not sure if this helps but I tracked down a specific issue in Craft Commerce that results in this error.

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

simeon-smith commented 4 years ago

It appears that running ./craft project-config/rebuild helps with this as a bunch of the project config files aren't getting created.

https://github.com/craftcms/cms/issues/6609