Closed
Description
Preconditions (*)
- Magento Open Source 2.4-develop
Steps to reproduce (*)
- Install fresh copy of Magento 2.4-develop
- Create new module that has an event observer which listens for the
cms_page_save_after
event. Contents:
<?php
declare(strict_types=1);
namespace VendorName\ModuleName\Observer
class CmsPageSaveAfter
{
public function execute(Observer $observer)
{
if (rand(0, 1)) {
throw new \Error('this is an instance of \Error and will cause many problems');
} else {
$this->causeTypeError(1); // will also break.
}
}
private function causeTypeError(string $foo): void
{
// dummy for purposes of reproducing bug
}
}
- Log into the admin, open a cms page (or begin creating new page) for editing, make any change, and save page.
Expected result (*)
- Since
\Magento\Cms\Controller\Adminhtml\Page\Save::execute()
is written to catch objects of\Throwable
, it should pass to\Magento\Framework\Message\ManagerInterface
an object that will be accepted.
Actual result (*)
- The Save controller catches
\Throwable
, and passes toManagerInterface::addExceptionMessage()
an instance of\Error
(or\TypeError
, which extends\Error
), and sinceaddExceptionMessage()
only accepts objects which are an instance of\Exception
rather than\Throwable
, yet another\TypeError
is thrown. This\TypeError
trickles up to the catch statement in\Magento\Framework\App\Bootstrap::run()
which catches objects of\Throwable
, and the application is terminated.
⚠️ Note: Points 1-3 need to be investigated if they are relevant to /Error
object before fix
Original expected result:
- If updating an existing page,
\Magento\Framework\EntityManager\Operation\Update::execute()
should roll back the mysql transaction - If creating a new page,
\Magento\Framework\EntityManager\Opteration\Create::execute()
should roll back the mysql transaction - On the same note, if this were to happen on a entity where it's ResourceModel still performed CRUD operations using
\Magento\Framework\Model\ResourceModel\Db\AbstractDb::save()
, the transaction should be rolled back here as well. - Since
\Magento\Cms\Controller\Adminhtml\Page\Save::execute()
is written to catch objects of\Throwable
, it should pass to\Magento\Framework\Message\ManagerInterface
an object that will be accepted.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
Since this requires customization to the application to occur, I will not mark any of the Severity issues, as I have not found any occurrences where this issue is able to be reproduced from native stock code. However, I believe there to clearly be areas in the core code where revisions are appropriate to handle these situations more properly.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchAffects non-critical data or functionality and does not force users to employ a workaround.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Type
Projects
Status
Done