Skip to content

Commit bd0cb12

Browse files
authored
[PHP 8.1] Fix passing null to non-nullable internal function params (#2586)
1 parent e7cd88b commit bd0cb12

File tree

26 files changed

+37
-37
lines changed

26 files changed

+37
-37
lines changed

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public function getCurrentStatus()
154154
{
155155
$log = $this->getCustomerLog();
156156
if ($log->getLogoutAt()
157+
|| !$log->getLastVisitAt()
157158
|| strtotime(Varien_Date::now()) - strtotime($log->getLastVisitAt()) > Mage_Log_Model_Visitor::getOnlineMinutesInterval() * 60
158159
) {
159160
return Mage::helper('customer')->__('Offline');

app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Mage_Adminhtml_Block_Customer_Online_Grid_Renderer_Url extends Mage_Adminh
3636
*/
3737
public function render(Varien_Object $row)
3838
{
39-
return htmlspecialchars($row->getData($this->getColumn()->getIndex()));
39+
$value = $row->getData($this->getColumn()->getIndex());
40+
return empty($value) ? '' : htmlspecialchars($value);
4041
}
4142
}

app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Preview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function _toHtml()
4141
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
4242
}
4343
$template->setTemplateStyles(
44-
$this->maliciousCodeFilter($template->getTemplateStyles())
44+
$this->maliciousCodeFilter((string)$template->getTemplateStyles())
4545
);
4646
$template->setTemplateText(
4747
$this->maliciousCodeFilter($template->getTemplateText())

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',
153153
}
154154

155155
$menuArr['active'] = ($this->getActive() == $path . $childName)
156-
|| (strpos($this->getActive(), $path . $childName . '/') === 0);
156+
|| (strpos((string)$this->getActive(), $path . $childName . '/') === 0);
157157

158158
$menuArr['level'] = $level;
159159

app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function _getStoreIds()
135135
{
136136
$filterData = $this->getFilterData();
137137
if ($filterData) {
138-
$storeIds = explode(',', $filterData->getData('store_ids'));
138+
$storeIds = explode(',', (string)$filterData->getData('store_ids'));
139139
} else {
140140
$storeIds = [];
141141
}

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function setRenderer($renderer)
233233

234234
protected function _getRendererByType()
235235
{
236-
$type = strtolower($this->getType());
236+
$type = strtolower((string)$this->getType());
237237
$renderers = $this->getGrid()->getColumnRenderers();
238238

239239
if (is_array($renderers) && isset($renderers[$type])) {
@@ -328,7 +328,7 @@ public function setFilter($filterClass)
328328

329329
protected function _getFilterByType()
330330
{
331-
$type = strtolower($this->getType());
331+
$type = strtolower((string)$this->getType());
332332
$filters = $this->getGrid()->getColumnFilters();
333333
if (is_array($filters) && isset($filters[$type])) {
334334
return $filters[$type];

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Abstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _getHtmlId()
8787
*/
8888
public function getEscapedValue($index = null)
8989
{
90-
return htmlspecialchars($this->getValue($index));
90+
return htmlspecialchars((string)$this->getValue($index));
9191
}
9292

9393
/**

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ protected function _getValue(Varien_Object $row)
9292
}
9393
return '';
9494
}
95-
return $row->getData($this->getColumn()->getIndex());
95+
if ($index = $this->getColumn()->getIndex()) {
96+
return $row->getData($index);
97+
}
98+
return null;
9699
}
97100

98101
/**
@@ -123,7 +126,7 @@ public function renderHeader()
123126
{
124127
if ($this->getColumn()->getGrid()->getSortable() !== false && $this->getColumn()->getSortable() !== false) {
125128
$className = 'not-sort';
126-
$dir = strtolower($this->getColumn()->getDir());
129+
$dir = strtolower((string)$this->getColumn()->getDir());
127130
$nDir = ($dir == 'asc') ? 'desc' : 'asc';
128131
if ($this->getColumn()->getDir()) {
129132
$className = 'sort-arrow-' . $dir;

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Currency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _getRate($row)
8787
if ($rate = $this->getColumn()->getRate()) {
8888
return (float) $rate;
8989
}
90-
if ($rate = $row->getData($this->getColumn()->getRateField())) {
90+
if (($rateField = $this->getColumn()->getRateField()) && ($rate = $row->getData($rateField))) {
9191
return (float) $rate;
9292
}
9393
return 1;

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Longtext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function render(Varien_Object $row)
4747
if ($this->getColumn()->getTruncate()) {
4848
$truncateLength = $this->getColumn()->getTruncate();
4949
}
50-
$text = Mage::helper('core/string')->truncate(parent::_getValue($row), $truncateLength);
50+
$text = Mage::helper('core/string')->truncate((string)parent::_getValue($row), $truncateLength);
5151
if ($this->getColumn()->getEscape() !== false) {
5252
$text = $this->escapeHtml($text);
5353
}

0 commit comments

Comments
 (0)