Skip to content

Commit

Permalink
Unify quotations, really don't use an undefined array key in _renderO…
Browse files Browse the repository at this point in the history
…ption
  • Loading branch information
alexh-swdev committed Aug 8, 2024
1 parent 98d1ea0 commit 876c9cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$defTextArr = [];
foreach ($options as $k => $v) {
if ($isMultiple) {
if (array_key_exists('value', $v) && is_array($v['value']) && in_array($k, $v['value'])) {
if (array_key_exists("value", $v) && is_array($v['value']) && in_array($k, $v['value'])) {
$defTextArr[] = $v['label'];
}
} elseif (is_array($v) && array_key_exists('value', $v)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ protected function _getOptions()
*/
protected function _renderOption($option, $value)
{
if(!array_key_exists('value', $option)) {
if(!array_key_exists('label', $option)) {
return "";
}

$lbl = $this->escapeHtml($option['label']); // or just empty as well?
return '<option value="' . $lbl . '">' . $lbl . '</option>';
}

$selected = (!is_null($value) && array_key_exists('value', $option) && ($option['value'] == $value)) ? ' selected="selected"' : '';

Check failure on line 66 in app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Select.php

View workflow job for this annotation

GitHub Actions / PHPStan / Analyze (ubuntu-latest, 8.3)

Call to function array_key_exists() with 'value' and array will always evaluate to true.
return '<option value="' . $this->escapeHtml($option['value']) . '"' . $selected . '>' . $this->escapeHtml($option['label']) . '</option>';
}
Expand Down

0 comments on commit 876c9cb

Please sign in to comment.