sebastian-lenz / craft-linkfield

Link field for Craft 3
MIT License
122 stars 65 forks source link

Craft 4 upgrade issues with decode #248

Open rosskenney opened 1 year ago

rosskenney commented 1 year ago

Hi,

I looked through some of the other bug items and I did not see the same issue. For some reason the migration is failing with the following message.


*** applying m190417_202153_migrateDataToTable
    > create table {{%lenz_linkfield}} ... done (time: 0.003s)
    > create unique index craft_idx_exuxitlreqlravmedvrgqekbjetbqvkvqzyn on {{%lenz_linkfield}} (elementId,siteId,fieldId) ... done (time: 0.002s)
    > create index craft_idx_vhxtfrljiosqubmpdgbnwglbylwzuamfupap on {{%lenz_linkfield}} (fieldId) ... done (time: 0.002s)
    > create index craft_idx_gqlgmfjcethtadeisyzrscwltefxwldldrfr on {{%lenz_linkfield}} (siteId) ... done (time: 0.002s)
    > add foreign key craft_fk_pcreterntabybhfdwubgkuukdrxqbexlblui: {{%lenz_linkfield}} (elementId) references {{%elements}} (id) ... done (time: 0.007s)
    > add foreign key craft_fk_lggympzbocjgalrhikmifyvuwejqtawwgrlp: {{%lenz_linkfield}} (fieldId) references {{%fields}} (id) ... done (time: 0.007s)
    > add foreign key craft_fk_swveplxifggnppwgipxrfzkvnjwxrpjpgpmq: {{%lenz_linkfield}} (linkedId) references {{%elements}} (id) ... done (time: 0.008s)
    > add foreign key craft_fk_dluwlytroltnzaqaaiscyppjpexodnjotlmx: {{%lenz_linkfield}} (linkedSiteId) references {{%sites}} (id) ... done (time: 0.007s)
    > update in {{%fields}} ... done (time: 0.001s)
    > update in {{%fields}} ... done (time: 0.000s)
    > update in {{%fields}} ... done (time: 0.000s)
Exception: Syntax error (/var/www/html/vendor/yiisoft/yii2/helpers/BaseJson.php:147)
#0 /var/www/html/vendor/yiisoft/yii2/helpers/BaseJson.php(128): yii\helpers\BaseJson::handleJsonError(4)
#1 /var/www/html/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(143): yii\helpers\BaseJson::decode('https://www1.ny/...')
#2 /var/www/html/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(91): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateLinkField(Object(lenz\linkfield\fields\LinkField), '{{%content}}', '')
#3 /var/www/html/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(55): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateField(Object(lenz\linkfield\fields\LinkField), '{{%content}}')
#4 /var/www/html/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(31): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateAllFields()
#5 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(49): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->safeUp()
#6 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#7 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp('m190417_202153_...')
#8 [internal function]: craft\console\controllers\MigrateController->actionAll()
#9 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#11 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('all', Array)
#13 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#14 /var/www/html/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('migrate/all', Array)
#15 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#16 /var/www/html/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#17 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#18 /var/www/html/craft(22): yii\base\Application->run()
#19 {main}
*** failed to apply m190417_202153_migrateDataToTable (time: 0.121s)
bpurtoncc commented 1 year ago

I am getting this same thing when attempting to upgrade from Craft 3.7 to Craft 4

xswirelab commented 1 year ago

Same here

xswirelab commented 1 year ago

@rosskenney @bpurtoncc I solved it by updating the linkfield first, then run the migrations. Then update the supertable plugin and run its migrations. After that just continue as usual.

mateostabio commented 1 year ago

@xswirelab Can you explain with further details please. What did you exactly. I've been on this problem for months. https://github.com/sebastian-lenz/craft-linkfield/issues/230

xswirelab commented 1 year ago

@mateostabio I noticed that the order of migrations is important.

So I made sure that I ran the update of the linkfield first. Than ran the migrations.

After that I just added(composer require) all other packages, ran migrations and that made sure I was able to update to Craft4 without any errors or data loss.

Tldr; If you have the supertable plugin and linkfield plugin installed, make sure you update linkfield first before supertable.

saml0us commented 9 months ago

Same problem here.

Tried what xswirelab suggested, unfortunately without result.