contao / contao

Contao Open Source CMS
https://contao.org
GNU Lesser General Public License v3.0
352 stars 160 forks source link

overriding multiple comments not working #5086

Closed jochi44 closed 2 years ago

jochi44 commented 2 years ago

Affected version(s)

4.13.6, 5.0.0-RC1

Description

Follow up to #5084.

Steps to reproduce:

  1. create at least 2 comments in the frontend
  2. in the backend in CONTENT -> Comments select "Edit multiple"
  3. choose "Select all"
  4. push button "Override"
  5. select "Available field" -> "Publish comment [published]" and click "Continue"
  6. check box "Publish comment" and "Save"

error in Contao 4.13.6:

Internal Server Error
Was ist das Problem?
Argument 1 passed to Contao\Comments::notifyCommentsSubscribers() must be an instance of Contao\CommentsModel, null given, called in /var/www/web/var/cache/prod/contao/dca/tl_comments.php on line 182

error logfile in /var/logs (4.13.6):

[2022-08-03T20:57:18.003121+02:00] request.INFO: Matched route "contao_backend". {"route":"contao_backend","route_parameters":{"_route":"contao_backend","_scope":"backend","_token_check":true,"_controller":"Contao\\CoreBundle\\Controller\\BackendController::mainAction"},"request_uri":"https://xyz.tld/contao?act=overrideAll&do=comments&fields=1&ref=23rQyZlY&rt=ca7b008aecfcf65a4be0a75b5efa9.3BImHJ-t3pCIbX9kn-fRCeXkq1f4OJRdnpbYcjEeDm0.vmhxUNn8j6DJJC4ez66OfI-w_CXOXtIs6Me1CwBOOyykX3Ip2M-Zx_BALg","method":"POST"} []
[2022-08-03T20:57:18.060573+02:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Argument 1 passed to Contao\Comments::notifyCommentsSubscribers() must be an instance of Contao\CommentsModel, null given, called in /var/www/web/var/cache/prod/contao/dca/tl_comments.php on line 182" at /var/www/web/vendor/contao/comments-bundle/src/Resources/contao/classes/Comments.php line 643 {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Contao\\Comments::notifyCommentsSubscribers() must be an instance of Contao\\CommentsModel, null given, called in /var/www/web/var/cache/prod/contao/dca/tl_comments.php on line 182 at /var/www/web/vendor/contao/comments-bundle/src/Resources/contao/classes/Comments.php:643)"} []

error in Contao 5.0.0-RC1:

Internal Server Error
What's the matter?
Model::findByPk(): Argument #1 ($varValue) must be of type int|string, got null

error logfile in /var/logs (5.0.0-RC1):

[2022-08-03T20:54:48.012542+02:00] request.INFO: Matched route "contao_backend". {"route":"contao_backend","route_parameters":{"_route":"contao_backend","_scope":"backend","_token_check":true,"_controller":"Contao\\CoreBundle\\Controller\\BackendController::mainAction"},"request_uri":"https://contao5.xyz.tld/contao?act=overrideAll&do=comments&fields=1&ref=cQQIFcLY&rt=48cb5b41.x9Fj8CzSMVSI1DAW1UcSLgUf_m_oP6KcGK3Ie7NAoZ0.j4QgpHyqXj_LsFZ-oBgqezRrtxe9D5PpVf-BFvgB1M-FoFeEQr1ZAPCcaQ","method":"POST"} []
[2022-08-03T20:54:48.017594+02:00] request.CRITICAL: Uncaught PHP Exception TypeError: "Model::findByPk(): Argument #1 ($varValue) must be of type int|string, got null" at /var/www/web/contao5/vendor/contao/core-bundle/contao/library/Contao/Model.php line 820 {"exception":"[object] (TypeError(code: 0): Model::findByPk(): Argument #1 ($varValue) must be of type int|string, got null at /var/www/web/contao5/vendor/contao/core-bundle/contao/library/Contao/Model.php:820)"} []
aschempp commented 2 years ago

@jochi44 Does this not happen on Contao 4.9 or did you not test Contao 4.9?

jochi44 commented 2 years ago

@jochi44 Does this not happen on Contao 4.9 or did you not test Contao 4.9?

Cannot and did not test Contao 4.9.

leofeyer commented 2 years ago

We should probably check if Input::get('id') is not null here:

https://github.com/contao/contao/blob/4d23716325b8d4c78fd0c7b3d1d9862d02f592dc/comments-bundle/src/Resources/contao/dca/tl_comments.php#L464-L467