Cms: Craft update 3.0.37 to 3.1 -

Created on 16 Jan 2019  Â·  10Comments  Â·  Source: craftcms/cms

Description

Getting this after upgrading Craft update 3.0.37 to 3.1
view screenshot

yii\base\ErrorException: Undefined offset: 1

Migration: craft\migrations\m180516_153000_uids_in_field_settings

Output:

Exception: Undefined offset: 1 (/Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/migrations/m180516_153000_uids_in_field_settings.php:45)
#0 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(8, 'Undefined offse...', '/Users/Mattias/...', 45)
#1 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/migrations/m180516_153000_uids_in_field_settings.php(45): craft\web\ErrorHandler->handleError(8, 'Undefined offse...', '/Users/Mattias/...', 45, Array)
#2 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m180516_153000_uids_in_field_settings->safeUp()
#3 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#4 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m180516_153000_uids_in_field_settings))
#5 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/services/Updates.php(215): craft\db\MigrationManager->up()
#6 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(445): craft\services\Updates->runMigrations(Array)
#7 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/controllers/UpdaterController.php(208): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#8 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#9 /Users/Mattias/Sites/techbox/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /Users/Mattias/Sites/techbox/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#11 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('migrate', Array)
#12 /Users/Mattias/Sites/techbox/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#13 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('updater/migrate', Array)
#14 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/web/Application.php(683): craft\web\Application->runAction('updater/migrate')
#15 /Users/Mattias/Sites/techbox/vendor/craftcms/cms/src/web/Application.php(223): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#16 /Users/Mattias/Sites/techbox/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#17 /Users/Mattias/Sites/techbox/web/index.php(21): yii\base\Application->run()
#18 /Users/Mattias/.composer/vendor/laravel/valet/server.php(151): require('/Users/Mattias/...')
#19 {main}

Additional info

  • Craft version: 3.0.37 -> 3.1
  • PHP version: PHP 7.3.1 (cli) (built: Jan 10 2019 13:15:37) ( NTS )
  • Database driver & version: MariaDB 10.3.12
  • Plugins & versions:
bug normal

Most helpful comment

Migrated up successfully.

Thanks @andris-sevcenko

All 10 comments

Getting this:

Unknown Property: Getting unknown property: craft\redactor\Field::contentTable

Migration: craft\migrations\m190108_113000_asset_field_setting_change

@elfacht that's an unrelated issue and was fixed in 717a04a766f32a1f433146c8a6fc52f178a154c7. There should be a release later today!

I am still getting an error when running the craft\migrations\m180516_153000_uids_in_field_settings migration on one of our sites. I don’t know how this has happened but we have asset fields where defaultUploadLocationSource, singleUploadLocationSource and/or source settings are missing completely. It might have been caused by some Import plugin we were using in the past, therefor not necessarily something this migration has to guard against.

Exception: Undefined index: defaultUploadLocationSource (/Users/Christian/Websites/foo/vendor/craftcms/cms/src/migrations/m180516_153000_uids_in_field_settings.php:50)
#0 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\migrations\m180516_153000_uids_in_field_settings->up()
#1 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp()
#2 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/services/Updates.php(215): craft\db\MigrationManager->up()
#3 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/console/controllers/MigrateController.php(243): craft\services\Updates->runMigrations()
#4 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/InlineAction.php(57): craft\console\controllers\MigrateController->actionAll()
#5 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#6 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams()
#7 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Controller.php(148): craft\console\controllers\MigrateController->runAction()
#8 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Module.php(528): craft\console\controllers\MigrateController->runAction()
#9 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Application.php(180): craft\console\Application->runAction()
#10 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/console/Application.php(99): craft\console\Application->runAction()
#11 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#12 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Application.php(386): craft\console\Application->handleRequest()
#13 /Users/Christian/Websites/foo/craft(22): craft\console\Application->run()
#14 {main}

I fixed it for us by re-saving the fields from the CP before running migrations. Here’s the code that helped me find all fields in question.

public function findCorruptAssetFields()
{
    return (new Query())
        ->select(['handle'])
        ->from(['{{%fields}}'])
        ->where([
            'and',
            ['type' => 'craft\fields\Assets'],
            [
                'or',
                ['not like', 'settings', 'defaultUploadLocationSource'],
                ['not like', 'settings', 'singleUploadLocationSource'],
            ]
        ])
        ->column();
}

Yeah those keys should definitely be present in the settings.

Im having the same issue when upgrading from Craft v 2.7.4 to 3. Logs below

yii\base\ErrorException: Undefined index: defaultUploadLocationSource
Migration: craft\migrations\m180516_153000_uids_in_field_settings
Output:
Exception: Undefined index: defaultUploadLocationSource (/Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/migrations/m180516_153000_uids_in_field_settings.php:45)

#0 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/Users/00005201...', 45)

#1 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/migrations/m180516_153000_uids_in_field_settings.php(45): craft\web\ErrorHandler->handleError(8, 'Undefined index...', '/Users/00005201...', 45, Array)

#2 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m180516_153000_uids_in_field_settings->safeUp()

#3 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)

#4 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m180516_153000_uids_in_field_settings))

#5 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/services/Updates.php(215): craft\db\MigrationManager->up()

#6 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(445): craft\services\Updates->runMigrations(Array)

#7 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/controllers/UpdaterController.php(208): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')

#8 [internal function]: craft\controllers\UpdaterController->actionMigrate()

#9 /Users/00005201/Documents/projects/corpweb3/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

#10 /Users/00005201/Documents/projects/corpweb3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

#11 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('migrate', Array)

#12 /Users/00005201/Documents/projects/corpweb3/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)

#13 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('updater/migrate', Array)

#14 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/web/Application.php(683): craft\web\Application->runAction('updater/migrate')

#15 /Users/00005201/Documents/projects/corpweb3/vendor/craftcms/cms/src/web/Application.php(223): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))

#16 /Users/00005201/Documents/projects/corpweb3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))

#17 /Users/00005201/Documents/projects/corpweb3/web/index.php(21): yii\base\Application->run()

#18 {main}

We’re also running into issues with the defaultUploadLocationSource, singleUploadLocationSource and source related migration, upgrading from 2.7.4 to 3.1.1.

@andris-sevcenko there is one more migration affected

Exception: Undefined index: singleUploadLocationSource (/Users/Christian/Websites/foo/vendor/craftcms/cms/src/migrations/m190108_113000_asset_field_setting_change.php:47)
#0 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/migrations/m190108_113000_asset_field_setting_change.php(47): yii\base\ErrorHandler->handleError(8, 'Undefined index...', '/Users/Christia...', 47, Array)
#1 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m190108_113000_asset_field_setting_change->safeUp()
#2 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#3 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m190108_113000_asset_field_setting_change))
#4 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/services/Updates.php(215): craft\db\MigrationManager->up()
#5 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/console/controllers/MigrateController.php(243): craft\services\Updates->runMigrations(Array)
#6 [internal function]: craft\console\controllers\MigrateController->actionAll()
#7 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#9 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('all', Array)
#10 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#11 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#12 /Users/Christian/Websites/foo/vendor/craftcms/cms/src/console/Application.php(99): yii\console\Application->runAction('migrate/all', Array)
#13 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#14 /Users/Christian/Websites/foo/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#15 /Users/Christian/Websites/foo/craft(22): yii\base\Application->run()
#16 {main}

Grrrrr.

Migrated up successfully.

Thanks @andris-sevcenko

3.1.2 is out now with the fix for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitboxfw picture bitboxfw  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments

michel-o picture michel-o  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments