Fix PHP 8.5 "null as array offset" deprecation in AbstractPdf::_getRenderer() - #41135
Fix PHP 8.5 "null as array offset" deprecation in AbstractPdf::_getRenderer()#41135Bashev wants to merge 3 commits into
Conversation
…nderer() On PHP 8.5, using null as an array offset is deprecated. When a PDF renderer type resolves to null (e.g. a grouped-product order item whose real product type is null), _getRenderer() calls isset($this->_renderers[$type]) with $type === null, emitting a deprecation at AbstractPdf.php. In production mode, where deprecations are promoted to exceptions, PDF generation aborts. Guard the array offset against null before the isset() check so a null type falls back to the 'default' renderer, consistent with the other PHP 8.5 null-array-offset fixes (e.g. magento#40889). Covered by a unit test that promotes deprecations to exceptions and asserts the null type resolves to the default renderer (fails on the unpatched code).
|
Hi @Bashev. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
Also can you edit your opening post and put a link to #41134 in there, so this PR and the issue are linked together? Thanks! |
|
@magento run all tests |
|
@magento run Database Compare, Functional Tests B2B, Functional Tests CE, Functional Tests EE |
|
@magento run all tests |
|
@magento run Functional Tests CE |
Description
On PHP 8.5, using
nullas an array offset is deprecated ("Using null as an array offset is deprecated, use an empty string instead").Magento\Sales\Model\Order\Pdf\AbstractPdf::_getRenderer()callsisset($this->_renderers[$type])without guarding$typeagainstnull. When the renderer type resolves tonull— e.g. a grouped-product order item whosegetRealProductType()returnsnull— theisset()triggers the deprecation. In production mode, where deprecations are promoted to exceptions, PDF generation aborts (HTTP 404 / error page) instead of falling back to thedefaultrenderer.This mirrors the other PHP 8.5 null-array-offset fixes already merged (e.g. #40889 for
ScopeCodeResolver).Fixed Issues
Manual testing scenarios
bin/magento deploy:mode:set production).null(e.g. an order item wheregetRealProductType()returnsnull, such as some grouped-product scenarios or data migrated from older versions).defaultrenderer.Covered by a new unit test
AbstractTest::testGetRendererFallsBackToDefaultForNullType(), which promotesE_DEPRECATEDto an exception so a regression fails the test:Contribution checklist