Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed null parameter warning in Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php #3829

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

addison74
Copy link
Contributor

Fix for issue #3828

OpenMage 20.3.0
Magento Sample Pack
PHP 8.3
MAGE_IS_DEVELOPER_MODE=1

Steps to reproduce this issue

1 - Go to the Backend > Customers
2 - Click on any row in the grid
3 - Click on the Wishlist tab

You will get this error

Deprecated functionality: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated  in /var/www/html/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php on line 26

#0 [internal function]: mageCoreErrorHandler()
#1 /var/www/html/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php(26): htmlspecialchars()
#2 /var/www/html/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php(148): Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist_Grid_Renderer_Description->render()
#3 /var/www/html/app/design/adminhtml/default/default/template/widget/grid.phtml(153): Mage_Adminhtml_Block_Widget_Grid_Column->getRowField()
#4 /var/www/html/app/code/core/Mage/Core/Block/Template.php(273): include('...')
#5 /var/www/html/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php(240): Mage_Core_Block_Template->fetchView()
#6 /var/www/html/app/design/adminhtml/default/default/template/customer/tab/wishlist.phtml(16): Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist->getGridParentHtml()
#7 /var/www/html/app/code/core/Mage/Core/Block/Template.php(273): include('...')
#8 /var/www/html/app/code/core/Mage/Core/Block/Template.php(310): Mage_Core_Block_Template->fetchView()
#9 /var/www/html/app/code/core/Mage/Core/Block/Template.php(323): Mage_Core_Block_Template->renderView()
#10 /var/www/html/app/code/core/Mage/Adminhtml/Block/Template.php(67): Mage_Core_Block_Template->_toHtml()
#11 /var/www/html/app/code/core/Mage/Core/Block/Abstract.php(926): Mage_Adminhtml_Block_Template->_toHtml()
#12 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(573): Mage_Core_Block_Abstract->toHtml()
#13 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#14 /var/www/html/app/code/core/Mage/Adminhtml/controllers/CustomerController.php(498): Mage_Core_Controller_Varien_Action->renderLayout()
#15 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(421): Mage_Adminhtml_CustomerController->wishlistAction()
#16 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(255): Mage_Core_Controller_Varien_Action->dispatch()
#17 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(181): Mage_Core_Controller_Varien_Router_Standard->match()
#18 /var/www/html/app/code/core/Mage/Core/Model/App.php(358): Mage_Core_Controller_Varien_Front->dispatch()
#19 /var/www/html/app/Mage.php(760): Mage_Core_Model_App->run()
#20 /var/www/html/index.php(56): Mage::run()
#21 {main}

screenshot

@addison74
Copy link
Contributor Author

There are two solutions, I chose the first one. Using a cast is easier to find and replace than a coalescing operator.

(string)$variabile - previous behavior
$variable ?? '' - error suppression for TypeError on null only

return nl2br(htmlspecialchars((string)$row->getData($this->getColumn()->getIndex())));

or

return nl2br(htmlspecialchars(($row->getData($this->getColumn()->getIndex()) ?? ''));

@kiatng
Copy link
Contributor

kiatng commented Feb 15, 2024

I prefer your second solution although your first one works in this case.

@addison74
Copy link
Contributor Author

@kiatng - the same proposal as yours can be found here https://github.com/sreichel/openmage-future/pull/5/files.

I made the changes, please do a test.

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
@fballiano fballiano changed the title Deprecated functionality - Issue 3828 Fixed null parameter warning in Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php Feb 20, 2024
@addison74 addison74 merged commit d3ab364 into OpenMage:main Feb 21, 2024
19 checks passed
@addison74 addison74 deleted the ADDISON74-issue-3828 branch February 21, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml
Projects
None yet
3 participants