contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
123 stars 58 forks source link

Make sure the DataContainer's active record exists before altering it in articles #1523

Closed qzminski closed 6 years ago

qzminski commented 6 years ago

We have the below exception logged in the Sentry. Although I am not sure what exactly causes the problem, it should still be prevented.

ErrorException: Creating default object from empty value
#20 var/cache/prod/contao/dca/tl_article.php(1031): handleError
#19 var/cache/prod/contao/dca/tl_article.php(1031): toggleVisibility
#18 var/cache/prod/contao/dca/tl_article.php(912): toggleIcon
#17 vendor/contao/core-bundle/src/Resources/contao/classes/DataContainer.php(792): generateButtons
#16 vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(3913): generateTree
#15 vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(3986): generateTree
#14 vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(4006): generateTree
#13 vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(3528): treeView
#12 vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php(340): showAll
#11 vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php(620): getBackendModule
#10 vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php(132): run
#9 vendor/contao/core-bundle/src/Controller/BackendController.php(55): mainAction
#8 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(151): handleRaw
#7 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(68): handle
#6 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(202): handle
#5 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php(462): forward
#4 vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php(57): forward
#3 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php(234): pass
#2 vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php(179): handle
#1 vendor/friendsofsymfony/http-cache/src/SymfonyCache/EventDispatchingHttpCache.php(98): handle
#0 web/app.php(33): null
leofeyer commented 6 years ago

We should also try to find the root cause here.

The active record is set in line 997 if the article ID is valid. So the problem seems to be that $intId is not pointing to a valid database record in your case.

Do you have the corresponding request URL?

qzminski commented 6 years ago

Yep, here is the curl:

curl \
 --compressed \
 -H "Accept: application/json" \
 -H "Accept-Encoding: gzip, deflate, br" \
 -H "Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7" \
 -H "Connection: close" \
 -H "Host: domain.tld" \
 -H "Referer: https://domain.tld/" \
 -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36" \
 -H "X-Accel-Internal: /internal-nginx-static-location" \
 -H "X-Real-Ip: 212.90.203.26" \
 -H "X-Request: JSON" \
 -H "X-Requested-With: XMLHttpRequest" \
 "https://domain.tld/contao?do=article&rt=R2yszlX-uqfrmn7HHq8bco931Pp-S2XC9ynJCUqsZuQ&ref=KesWCDcD&tid=1504&state=1&rt=R2yszlX-uqfrmn7HHq8bco931Pp-S2XC9ynJCUqsZuQ"

We logged only 2 events in total though and the issue hasn't been seen for 2 months now.

Toflar commented 6 years ago

I couldn't reproduce this one. It's an ajax request that toggles the eye icon in the article tree view (according to the request details) but it's also strange why rt is added twice to the URL so no idea how that could happen. Let's close that one and see if we find a reproducible case somewhen.

leofeyer commented 6 years ago

Agreed.