craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.27k stars 635 forks source link

[4.x]: An error occurred when opening a duplicate Draft. #11976

Closed mersy closed 2 years ago

mersy commented 2 years ago

What happened?

Description

In entry index page , I can duplicate draft. After that error occurred when open duplicated draft.

I don't need to duplicate it, but I happened to find it when I duplicated other entries.

Steps to reproduce

  1. Check draft data and duplicate it.
20220921-052059
  1. Filterd draft and click title
20220921-052111

3 . Error occurred

TypeError: Cannot assign bool to property craft\base\Element::$_canonicalAnySite of type ?craft\base\ElementInterface in /home/XXXXXXXXXX/craft4-test/vendor/craftcms/cms/src/base/Element.php:2482
Stack trace:
#0 /home/XXXXXXXXXX/craft4-test/vendor/craftcms/cms/src/controllers/ElementsController.php(277): craft\base\Element->getCanonical(true)
#1 [internal function]: craft\controllers\ElementsController->actionEdit(Object(craft\elements\Entry), 446)
#2 /home/XXXXXXXXXX/craft4-test/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /home/XXXXXXXXXX/craft4-test/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 /home/XXXXXXXXXX/craft4-test/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('edit', Array)
#5 /home/XXXXXXXXXX/craft4-test/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('elements/edit', Array)
#6 /home/XXXXXXXXXX/craft4-test/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('elements/edit', Array)
#7 /home/XXXXXXXXXX/craft4-test/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#8 /home/XXXXXXXXXX/craft4-test/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /home/XXXXXXXXXX/public_html/craft4-test/index.php(13): yii\base\Application->run()
#10 {main}

Expected behavior

Maybe open draft edit page or Draft can't duplicate

Actual behavior

Error occurred

Craft CMS version

4.2.5

PHP version

8.0.22

Operating system and version

Linux 3.10.0-962.3.2.lve1.5.39.el7.x86_64

Database type and version

MySQL 10.3.36

Image driver and version

GD 8.0.23

Installed plugins and versions

brandonkelly commented 2 years ago

Thanks for reporting that! Craft 4.2.5.1 is out with a fix.