Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add NULL check for field settings during migration #3208

Merged
merged 2 commits into from
Aug 16, 2018
Merged

Add NULL check for field settings during migration #3208

merged 2 commits into from
Aug 16, 2018

Conversation

eriweb
Copy link
Contributor

@eriweb eriweb commented Aug 16, 2018

This would happen during Craft2 to Craft3 upgrade when a fields' setting is NULL.

Error/stack trace:

Exception: Argument 1 passed to craft\helpers\Json::decodeIfJson() must be of the type string, null given, called in /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/migrations/m160807_144858_sites.php on line 444 (/Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/helpers/Json.php:30)
#0 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/migrations/m160807_144858_sites.php(444): craft\helpers\Json::decodeIfJson(NULL)
#1 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m160807_144858_sites->safeUp()
#2 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#3 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m160807_144858_sites))
#4 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/services/Updates.php(207): craft\db\MigrationManager->up()
#5 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/craftcms/cms/src/console/controllers/MigrateController.php(243): craft\services\Updates->runMigrations(Array)
#6 [internal function]: craft\console\controllers\MigrateController->actionAll()
#7 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#9 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('all', Array)
#10 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#11 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#12 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate/all', Array)
#13 /Users/erik/dev/craft3-upgrade-migrationfix/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#14 /Users/erik/dev/craft3-upgrade-migrationfix/craft(22): yii\base\Application->run()
#15 {main}
Exception 'craft\errors\MigrateException' with message 'An error occurred while migrating Craft CMS.'

In my case I had an 'Entries' field with null value:

+----+---------+------------------+---------------------------+---------+--------------+--------------+---------+----------+---------------------+---------------------+--------------------------------------+
| id | groupId | name             | handle                    | context | instructions | translatable | type    | settings | dateCreated         | dateUpdated         | uid                                  |
+----+---------+------------------+---------------------------+---------+--------------+--------------+---------+----------+---------------------+---------------------+--------------------------------------+
| 77 |       1 | Page edit access | frontendeditor_pageaccess | global  | NULL         |            0 | Entries | NULL     | 2016-08-24 09:10:54 | 2016-08-24 09:10:54 | 6476201c-36ac-4c58-b1d3-3771f2083c3e |
+----+---------+------------------+---------------------------+---------+--------------+--------------+---------+----------+---------------------+---------------------+--------------------------------------+
1 row in set (0.00 sec)```

@brandonkelly brandonkelly merged commit 4810233 into craftcms:develop Aug 16, 2018
@brandonkelly
Copy link
Member

Thank you!!

brandonkelly added a commit that referenced this pull request Aug 16, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants