craftcms / cms

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

[5.x]: Merging entry types for single section fails #16176

Closed ul8 closed 3 days ago

ul8 commented 4 days ago

What happened?

Description

I have been merging some entry types shared between multiple channel/structure sections without any issues (I merged literally hundreds of entry types with no such problem)

The only issue I get is when trying to merge an entry type that exists both in a single and a channel. I waited for https://github.com/craftcms/cms/pull/16102 to be merged before trying, it seems to not have fixed it

Steps to reproduce

I am running this command:

ddev craft entry-types/merge --interactive=0 home home_home

...where home_home is mapped to a single, and home to a channel. So I am attempting to merge a singe entry type into a channel entry type.

The error I receive is printed below. FYI the site was recently upgraded from Craft 4, and has a multisite setup.

For now I was able to work around the issue by reversing the merge direction (channel into single) and then renaming the entry type afterwards as needed.

 → Inspecting fields … ✓ done
 → Updating usages … error: Invalid owner ID: 1160627
Exception 'yii\base\InvalidConfigException' with message 'Invalid owner ID: 1160627'

in /var/www/html/vendor/craftcms/cms/src/base/NestedElementTrait.php:162

Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/base/NestedElementTrait.php(207): craft\elements\Entry->getPrimaryOwner()
#1 /var/www/html/vendor/craftcms/cms/src/helpers/ElementHelper.php(553): craft\elements\Entry->getOwner()
#2 /var/www/html/vendor/putyourlightson/craft-blitz/src/services/RefreshCacheService.php(279): craft\helpers\ElementHelper::isDraftOrRevision()
#3 /var/www/html/vendor/putyourlightson/craft-blitz/src/Blitz.php(387): putyourlightson\blitz\services\RefreshCacheService->isRefreshableElement()
#4 [internal function]: putyourlightson\blitz\Blitz->putyourlightson\blitz\{closure}()
#5 /var/www/html/vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#6 /var/www/html/vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2351): yii\base\Component->trigger()
#8 /var/www/html/vendor/craftcms/cms/src/elements/NestedElementManager.php(1259): craft\services\Elements->deleteElement()
#9 /var/www/html/vendor/craftcms/cms/src/fields/Matrix.php(1345): craft\elements\NestedElementManager->deleteNestedElements()
#10 /var/www/html/vendor/craftcms/cms/src/base/Element.php(6198): craft\fields\Matrix->beforeElementDelete()
#11 /var/www/html/vendor/craftcms/cms/src/elements/Entry.php(2729): craft\base\Element->beforeDelete()
#12 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2357): craft\elements\Entry->beforeDelete()
#13 /var/www/html/vendor/craftcms/cms/src/elements/NestedElementManager.php(1259): craft\services\Elements->deleteElement()
#14 /var/www/html/vendor/craftcms/cms/src/fields/Matrix.php(1345): craft\elements\NestedElementManager->deleteNestedElements()
#15 /var/www/html/vendor/craftcms/cms/src/base/Element.php(6198): craft\fields\Matrix->beforeElementDelete()
#16 /var/www/html/vendor/craftcms/cms/src/elements/Entry.php(2729): craft\base\Element->beforeDelete()
#17 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2357): craft\elements\Entry->beforeDelete()
#18 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(1032): craft\services\Elements->deleteElement()
#19 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(867): craft\services\Entries->_ensureSingleEntry()
#20 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1829): craft\services\Entries->handleChangedSection()
#21 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1179): craft\console\Application->craft\base\{closure}()
#22 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#23 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#24 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(85): yii\base\Component->trigger()
#25 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(564): craft\models\ProjectConfigData->commitChanges()
#26 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(524): craft\services\ProjectConfig->_setInternal()
#27 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(601): craft\services\ProjectConfig->set()
#28 /var/www/html/vendor/craftcms/cms/src/console/controllers/EntryTypesController.php(236): craft\services\Entries->saveSection()
#29 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(493): craft\console\controllers\EntryTypesController->craft\console\controllers\{closure}()
#30 /var/www/html/vendor/craftcms/cms/src/console/controllers/EntryTypesController.php(225): craft\console\Controller->do()
#31 [internal function]: craft\console\controllers\EntryTypesController->actionMerge()
#32 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#33 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#34 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#35 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#36 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction()
#37 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction()
#38 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#39 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#40 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#41 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#42 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()

Craft CMS version

5.5.2

PHP version

8.3

Operating system and version

ubuntu/ddev

Database type and version

MariaDB 10.4

Image driver and version

No response

Installed plugins and versions

"born05/craft-sentry": "3.0.0",
"craftcms/ckeditor": "4.4.0",
"craftcms/cms": "5.5.2",
"craftcms/feed-me": "6.5.0",
"craftcms/mailgun": "3.1.0",
"craftcms/redactor": "4.2.0",
"doublesecretagency/craft-cpcss": "3.0.0",
"fredmansky/craft-pdf-renderer": "1.3.1",
"fredmansky/craft-proper": "1.6.1",
"goldinteractive/craft-sitecopy": "2.1.1",
"guzzlehttp/guzzle": "7.9.2",
"mmikkel/cp-field-inspect": "2.0.2",
"nystudio107/craft-emptycoalesce": "5.0.0",
"nystudio107/craft-retour": "5.0.3",
"nystudio107/craft-seomatic": "5.1.6",
"nystudio107/craft-templatecomments": "5.0.3",
"nystudio107/craft-twigprofiler": "5.0.0",
"nystudio107/craft-vite": "5.0.1",
"putyourlightson/craft-blitz": "5.9.6",
"putyourlightson/craft-elements-panel": "3.0.0",
"spacecatninja/imager-x": "5.0.3",
"studioespresso/craft-dumper": "5.0.1",
"ttempleton/craft-nocache": "3.0.4",
"verbb/expanded-singles": "3.0.1",
"verbb/field-manager": "4.0.3",
"verbb/formie": "3.0.12",
"verbb/hyper": "2.2.0",
"verbb/image-resizer": "4.0.1",
"verbb/smith": "3.1.0",
"verbb/super-table": "4.0.2",
"verbb/tablemaker": "5.0.3",
"vlucas/phpdotenv": "5.6.1"
i-just commented 4 days ago

Hi, thanks for reporting! I suspect PR #16162 will fix this. If you’d like to test early, you can change your craftcms/cms requirement in composer.json to

"craftcms/cms": "5.x-dev#cab2531e1a244ae15d04e122f47d919c83f11772 as 5.5.2",

and run composer update.

brandonkelly commented 3 days ago

Craft 5.5.3 is out with the fix for this. Thanks again!