Closed
Description
This issue is automatically created based on existing pull request: #31275: Declare optional argument after required.
Description
This prevents PHP fatal error when a plugin is added to the one of parent classes.
Manual testing scenarios
- Create a plugin for
\Magento\Framework\View\Element\BlockInterface
. - Navigate to Content > Pages.
Plugin example
Open Magento/Cms/etc/di.xml
and add the following code:
<type name="Magento\Framework\View\Element\BlockInterface">
<plugin name="cms_plugin" type="Magento\Cms\Plugin\Block" />
</type>
Create Magento\Cms\Plugin\Block
class:
<?php
namespace Magento\Cms\Plugin;
class Block
{
/**
* @param mixed $subject
* @param mixed $result
* @return mixed
*/
public function afterToHtml(
$subject,
$result
) {
return $result;
}
}
Actual Result: ✖️ A fatal error will be rendered: 'Error: Cannot instantiate interface Magento\Framework\Data\OptionSourceInterface'Magento\Framework\Data\OptionSourceInterface
Expected Result: ✔️ The page is successfully loaded
Contribution checklist (*)
- Pull request has a meaningful description of its purpose
- All commits are accompanied by meaningful commit messages
- All new or changed code is covered with unit/integration tests (if applicable)
- All automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.4-develop branchGate 3 Passed. Manual verification of the issue completed. Issue is confirmedOnce P0 defects have been fixed, a defect having this priority is the next candidate for fixing.The issue has been reproduced on latest 2.4-develop branchMajor restrictions or short-term circumventions are required until a fix is available.
Type
Projects
Status
Done