verbb / comments

A Craft CMS plugin for managing comments directly within the CMS.
Other
137 stars 33 forks source link

When delete a Product, the Comment Dashboard Widget throws an Error #219

Closed francoislevesque closed 3 years ago

francoislevesque commented 3 years ago

Description

When deleting a Product having comments, the Comment Dashboard Widget throws an Error: craft\services\Elements::getElementById() must be of the type int, null given.

Steps to reproduce

  1. Create a product (or an entry)
  2. Add a comment
  3. Delete the product
  4. Show the comment widget on the dashboard
  5. Error!

Additional info

Additional context

// /verbb/comments/src/elements/Comment.php

if ($cacheKey && $this->_owner = $renderCache->getElement($cacheKey)) {
  return $this->_owner;
}

// ⚠ This line seems to be problematic!
$this->_owner = Craft::$app->getElements()->getElementById($this->ownerId, null, $this->siteId);

if ($this->_owner) {
  $renderCache->addElement($cacheKey, $this->_owner);
}
engram-design commented 3 years ago

Should be fixed in 1.8.5