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]: Invalid entry type ID after deleting entry type and field used within matrix. #14888

Open
jdsdev opened this issue Apr 28, 2024 · 2 comments
Labels

Comments

@jdsdev
Copy link

jdsdev commented Apr 28, 2024

What happened?

Description

Invalid entry type ID after deleting entry type and field used within matrix.

yii\base\InvalidConfigException: Invalid entry type ID: 10 in /app/vendor/craftcms/cms/src/elements/Entry.php:1413
Stack trace:
#0 /app/vendor/twig/twig/src/Extension/CoreExtension.php(1635): craft\elements\Entry->getType()
#1 /app/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\Entry), 'getType', Array, 'method', false, false, false, 1)
#2 /app/storage/runtime/compiled_templates/d7/d7ce7320ab5a139aadaeb16b61b794cc.php(38): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\Entry), 'getType', Array, 'method', false, false, false, 1)
#3 /app/vendor/twig/twig/src/Template.php(394): __TwigTemplate_4e09212327d8fa75dbd62a7c5219246b->doDisplay(Array, Array)
#4 /app/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#5 /app/storage/runtime/compiled_templates/42/4245ea3a3886fd59a45dadd307e5469e.php(77): Twig\Template->display(Array)
#6 /app/vendor/twig/twig/src/Template.php(394): __TwigTemplate_cf8b1a86c7075bec2c288a1b846f7d10->doDisplay(Array, Array)
#7 /app/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#8 /app/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#9 /app/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
#10 /app/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render(Array)
#11 /app/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render('_components/fie...', Array)
#12 /app/vendor/craftcms/cms/src/fields/Matrix.php(876): craft\web\View->renderTemplate('_components/fie...', Array)
#13 /app/vendor/craftcms/cms/src/fields/Matrix.php(794): craft\fields\Matrix->blockInputHtml(Array, Object(craft\elements\Entry))
#14 /app/vendor/craftcms/cms/src/base/Field.php(592): craft\fields\Matrix->inputHtml(Object(craft\elements\db\EntryQuery), Object(craft\elements\Entry), false)
#15 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(372): craft\base\Field->getInputHtml(Object(craft\elements\db\EntryQuery), Object(craft\elements\Entry))
#16 /app/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(350): craft\fieldlayoutelements\CustomField->inputHtml(Object(craft\elements\Entry), false)
#17 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(324): craft\fieldlayoutelements\BaseField->formHtml(Object(craft\elements\Entry), false)
#18 /app/vendor/craftcms/cms/src/web/View.php(1669): craft\fieldlayoutelements\CustomField->craft\fieldlayoutelements\{closure}()
#19 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(323): craft\web\View->namespaceInputs(Object(Closure), 'fields')
#20 /app/vendor/craftcms/cms/src/models/FieldLayout.php(832): craft\fieldlayoutelements\CustomField->formHtml(Object(craft\elements\Entry), false)
#21 /app/vendor/craftcms/cms/src/web/View.php(1663): craft\models\FieldLayout->craft\models\{closure}()
#22 /app/vendor/craftcms/cms/src/models/FieldLayout.php(831): craft\web\View->namespaceInputs(Object(Closure), NULL)
#23 /app/vendor/craftcms/cms/src/controllers/ElementsController.php(925): craft\models\FieldLayout->createForm(Object(craft\elements\Entry), false, Array)
#24 /app/vendor/craftcms/cms/src/controllers/ElementsController.php(398): craft\controllers\ElementsController->_prepareEditor(Object(craft\elements\Entry), false, true, Object(craft\web\Response), 'main-form', Object(Closure), Object(Closure), Object(Closure))
#25 [internal function]: craft\controllers\ElementsController->craft\controllers\{closure}(Object(craft\web\Response), 'main-form')
#26 /app/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(125): call_user_func(Object(Closure), Object(craft\web\Response), 'main-form')
#27 /app/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(50): craft\web\CpScreenResponseFormatter->_formatTemplate(Object(craft\web\Response), Object(craft\web\CpScreenResponseBehavior))
#28 /app/vendor/yiisoft/yii2/web/Response.php(1100): craft\web\CpScreenResponseFormatter->format(Object(craft\web\Response))
#29 /app/vendor/craftcms/cms/src/web/Response.php(337): yii\web\Response->prepare()
#30 /app/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#31 /app/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#32 /app/web/index.php(16): yii\base\Application->run()
#33 {main}

Steps to reproduce

  1. Create a matrix field that can include itself.
  2. Add matrix field to another matrix field currently in use in an entry.
  3. Use the field in an entry. (Uncertain whether it's also necessary to include the new matrix in itself.)
  4. Delete the new matrix field without removing it anywhere else.
  5. View entry that used new field.

Expected behavior

Deletion should cascade to entries where the field is in use.

Actual behavior

Entries now throw the above error: Invalid entry type ID.

Craft CMS version

6.0.5

PHP version

8.2.14

Operating system and version

No response

Database type and version

MySQL 8.0.30

Image driver and version

No response

Installed plugins and versions

@jdsdev jdsdev added the bug label Apr 28, 2024
@jdsdev
Copy link
Author

jdsdev commented Apr 28, 2024

As a note, the problem was resolved after I ran garbage collection in the console with gc/run. However, this should really happen automatically.

@i-just
Copy link
Contributor

i-just commented Apr 29, 2024

Hi, thanks for reaching out! I’m having trouble replicating this behaviour. Could you describe how to replicate it in more detail?

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