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

Warnings when deleting records in the front end #70

Open
fritzmg opened this issue May 27, 2024 · 0 comments
Open

Warnings when deleting records in the front end #70

fritzmg opened this issue May 27, 2024 · 0 comments
Assignees
Labels

Comments

@fritzmg
Copy link

fritzmg commented May 27, 2024

When records are deleted, warnings can appear (albeit only in sentry) due to missing translations. For example:

ErrorException: Warning: Trying to access array offset on value of type null
#42 /vendor/contao/news-bundle/src/Resources/contao/modules/ModuleNewsList.php(43): Contao\ModuleNewsList::generate
[…]
#21 /vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php(622): Contao\Controller::getContentElement
#20 /var/cache/prod/contao/dca/tl_content.php(318): tl_content::addCteType
[…]
#16 /vendor/contao/core-bundle/src/EventListener/DataContainer/RecordPreviewListener.php(85): Contao\CoreBundle\EventListener\DataContainer\RecordPreviewListener::compilePreview
#15 /vendor/contao/core-bundle/src/EventListener/DataContainer/RecordPreviewListener.php(67): Contao\CoreBundle\EventListener\DataContainer\RecordPreviewListener::storePrecompiledRecordPreview
#14 /vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(1542): Contao\DC_Table::delete
#13 /vendor/madeyourday/contao-rocksolid-frontend-helper/src/Controller/JsonApiController.php(258): MadeYourDay\RockSolidFrontendHelper\Controller\JsonApiController::callDcaMethod
#12 /vendor/madeyourday/contao-rocksolid-frontend-helper/src/Controller/JsonApiController.php(184): MadeYourDay\RockSolidFrontendHelper\Controller\JsonApiController::deleteAction
[…]
#0 /public/index.php(44): null

I have shortened the stack trace a bit, as it would be very long in this case. Basically what happens is, that the JsonApiController instantiates the respective data container to call ->delete() on it - but this in turn triggers the ondelete_callback which in turn triggers other callbacks that will in turn render the content elements in this case. But within the JsonApiController's context, no translations are loaded and thus a warning occurs when the news list module is rendered for the back end for example.

Not really sure how to solve this though 🤔. I mean we could add System::loadLanguageFile('default') in the JsonApiController's actions. However, since it executes back end actions it might also need to load other language files.

@ausi ausi self-assigned this May 27, 2024
@ausi ausi added the bug label May 27, 2024
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