-
Notifications
You must be signed in to change notification settings - Fork 16
fix(portalblocks): handle null/unset rows in sparse layout arrays #69
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,11 @@ public function __construct(Horde_Core_Block_Collection $collection) | |
| $emptyrows = []; | ||
|
|
||
| for ($row = 0; $row < $rows; $row++) { | ||
| // Skip null rows (sparse array) | ||
| if (!isset($this->_layout[$row]) || !is_array($this->_layout[$row])) { | ||
| continue; | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this is the right thing to do. If I undestand correctly, the _layout array can have non-consecutive indexes. And we want to go over each one that exists. But the Example: $this->_layout = [ 0 => $value1, 10 => $value2 ];in this case Possible solutions:
|
||
| $cols = count($this->_layout[$row]); | ||
| if (!isset($emptyrows[$row])) { | ||
| $emptyrows[$row] = true; | ||
|
|
@@ -760,6 +765,11 @@ public function removeRowIfEmpty($row) | |
| return true; | ||
| } | ||
|
|
||
| // Check if row is actually set (not just within bounds) | ||
| if (!isset($this->_layout[$row]) || !is_array($this->_layout[$row])) { | ||
| return true; | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be moved to |
||
| $rows = count($this->_layout[$row]); | ||
| for ($i = 0; $i < $rows; $i++) { | ||
| if (isset($this->_layout[$row][$i]) && $this->_layout[$row][$i] != 'empty') { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop $emptyrows (looks like it is assigned but never used).