devdocs: Undocumented breaking change in 2.3.6 - \Magento\Sales\Model\Order\Pdf\Invoice class
Summary (*)
After upgrading from 2.3.5-p1 to 2.3.6 an undocumented breaking change was introduced to the \Magento\Sales\Model\Order\Pdf\Invoice class. This prevents invoices from being printed if the class has been extended.
Ref: https://devdocs.magento.com/guides/v2.3/release-notes/backward-incompatible-changes/reference.html
Examples (*)
Before (2.3.5-p1):
public function __construct(
....
\Magento\Framework\Locale\ResolverInterface $localeResolver,
....
public function getPdf($invoices = []) {
..............
if ($invoice->getStoreId()) {
$this->_localeResolver->emulate($invoice->getStoreId());
$this->_storeManager->setCurrentStore($invoice->getStoreId());
}
.........
if ($invoice->getStoreId()) {
$this->_localeResolver->revert();
}
After (2.3.6):
/**
* @var \Magento\Store\Model\App\Emulation
*/
private $appEmulation;
public function __construct(
....
\Magento\Store\Model\App\Emulation $appEmulation,
....
if ($invoice->getStoreId()) {
$this->appEmulation->startEnvironmentEmulation(
$invoice->getStoreId(),
\Magento\Framework\App\Area::AREA_FRONTEND,
true
);
$this->_storeManager->setCurrentStore($invoice->getStoreId());
}
......................
if ($invoice->getStoreId()) {
$this->appEmulation->stopEnvironmentEmulation();
}
Because of this change and the introduction of a private function, extending this class has significantly changed.
Proposed solution
Ensure breaking changes are documented
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (9 by maintainers)
If people end up here from a search engine, here’s how we solved the constructor problem if you have a module which needs to support both Magento 2.3.5 and 2.3.6: https://github.com/magento/magento2/issues/30684#issuecomment-722602562
@pixel-paul, thanks for bringing this issue to our attention. I’ve updated the 2.3.6 release notes and will close this issue now. Let us know if we need to add additional information – we want to get this right! Thanks again.