Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[5.x]: Attempt to assign property "oldHandle" on null when applying the project config #16150

Closed
MoritzLost opened this issue Nov 19, 2024 · 2 comments
Labels

Comments

@MoritzLost
Copy link
Contributor

What happened?

Description

We're getting an error when trying to apply the project config in a specific branch:

    // …
    - updating fields.06eed33c-c17f-430a-a737-f2ed308e8b04 ... done
    - updating fields.2abfda72-f82c-4f85-9f31-d4629af6203b ... done
    - updating fields.12509575-856b-4382-85d0-129873f04b1b ... done
    - adding meta.__names__.af59d206-1262-40e8-b67d-8b1507070163 ... done
    - adding fields.af59d206-1262-40e8-b67d-8b1507070163 ... 
error: Attempt to assign property "oldHandle" on null
Failed to run craft project-config/apply --force: exit status 1

Here's the full stack trace:

2024-11-19 16:03:17 [console.INFO] [craft\services\ProjectConfig::_applyChanges] Looking for pending changes {"memory":9247160} 
2024-11-19 16:03:17 [console.INFO] [craft\services\ProjectConfig::_applyChanges] Parsing 45 removed configuration items {"memory":9248264} 
2024-11-19 16:03:18 [console.ERROR] [Error] Error: Attempt to assign property "oldHandle" on null in /var/www/html/vendor/craftcms/cms/src/services/Fields.php:1419
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/services/Fields.php(696): craft\services\Fields->applyFieldSave()
#1 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1829): craft\services\Fields->handleChangedField()
#2 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1179): craft\console\Application->craft\base\{closure}()
#3 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#4 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#5 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger()
#6 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(739): craft\models\ProjectConfigData->commitChanges()
#7 /var/www/html/vendor/craftcms/cms/src/helpers/ProjectConfig.php(116): craft\services\ProjectConfig->processConfigChanges()
#8 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(1549): craft\helpers\ProjectConfig::ensureAllFieldsProcessed()
#9 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1829): craft\services\Entries->handleChangedEntryType()
#10 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1179): craft\console\Application->craft\base\{closure}()
#11 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#12 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#13 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(85): yii\base\Component->trigger()
#14 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1169): craft\models\ProjectConfigData->commitChanges()
#15 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#16 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#17 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(85): yii\base\Component->trigger()
#18 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1289): craft\models\ProjectConfigData->commitChanges()
#19 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1295): craft\services\ProjectConfig->craft\services\{closure}()
#20 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(627): craft\services\ProjectConfig->_applyChanges()
#21 /var/www/html/vendor/craftcms/cms/src/console/controllers/ProjectConfigController.php(328): craft\services\ProjectConfig->applyExternalChanges()
#22 [internal function]: craft\console\controllers\ProjectConfigController->actionApply()
#23 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#24 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#25 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#26 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#27 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction()
#28 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction()
#29 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#30 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#31 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction()
#32 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(207): yii\base\Controller->run()
#33 /var/www/html/vendor/craftcms/cms/src/console/controllers/UpController.php(76): craft\console\Controller->run()
#34 [internal function]: craft\console\controllers\UpController->actionIndex()
#35 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#36 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#37 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#38 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#39 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction()
#40 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction()
#41 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#42 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#43 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#44 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#45 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#46 /var/www/html/craft(12): yii\base\Application->run()
#47 {main} {"memory":17590512,"exception":"[object] (Error(code: 0): Attempt to assign property \"oldHandle\" on null at /var/www/html/vendor/craftcms/cms/src/services/Fields.php:1419)"} 

After this error, running craft up again just displayed the Your system is up to date message. Running project-config/apply then reset the config again to the previous state (as described in #16086).

Steps to reproduce

Not sure. There were a lot of issues with the project config recently (#16086, #16087, #16145). All of those might have left database in an intermediate stage (though we also tried to restore an earlier backup and got the same error again). And since the config/ is frequently overwritten unexpectedly (see #16086), some changes might get lost on the way. This makes it difficult to isolate those problems and provide a clear way to reproduce them.

We manually added the fix from #16146 to be able to work at all.

Craft CMS version

5.5.1.1

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@brandonkelly
Copy link
Member

Thanks for reporting that! It was a bug in the logic for restoring a soft-deleted custom field, via project-config/apply. Fixed now in 5.5.2.

As for the site this occurred on, it should be fine after running project-config/apply a second time. The field’s database record should have been restored the first time (when the error occurred), and running it a second time gets the project config data fully in sync.

@MoritzLost
Copy link
Contributor Author

@brandonkelly Thanks for the fix! After the update, applying the config worked correctly again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants