Ticket #1128 (closed Bug: invalid)
Bug in index the label of DataTable_Row in file DataTable.php
| Reported by: | jetuelle | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | Piwik 0.5.5 |
| Component: | Core | Keywords: | |
| Cc: | Sensitive: | no |
Description
The line "$this->rowsIndexByLabel[$label] = count($this->rows)-1;" in function
"public function addRow( Piwik_DataTable_Row $row )" doesn't work correctly. For example:
$rows ( 1=>"AA", 2=>"BB", 3=>"CC", 4=>"DD", 5=>"EE", 6=>"FF"); note:1=>"AA": "1" is the index id of label "AA"
delete $rows[3], we get:
$rows ( 1=>"AA", 2=>"BB", 4=>"DD", 5=>"EE", 6=>"FF");
addRow($newrow),the label of $newrow is "GG"
The result should be: $rows ( 1=>"AA", 2=>"BB", 4=>"DD", 5=>"EE", 6=>"FF", 7=>"GG");
while according to function addRow(), the index id of $newrow's label("GG") is
$this->rowsIndexByLabel[$label] = count($this->rows)-1 =5-1=4,
but the right index id of label "GG" is 7.
We find the function rebuildIndex() useless after we change the function addRow().

