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
Bug in index the label of DataTable_Row in file DataTable.php #1128
Comments
Attachment: |
The code change contains the following three points: 11original code(4 functions):
2added codes: |
Can you upload this as a patch? (use "svn diff") |
Also if you can please submit a unit test to show that there is a bug somewhere? the unit test for the dataTable is: https://github.com/piwik/piwik/blob/master/tests/core/DataTable.test.php |
jetuelle, please post a patch, your code is very hard to read in its current form. rebuildIndex is not useless, it is helpful to access quickly rows with a given label instead of looping through the hundreds of rows in the datatable. |
Attachment: The patch file for DataTable.php |
Attachment: The file with change by jetuelle |
Attachment: The diff file of DataTable.php |
Attachment: The patch file for DataTable.php |
Marking as invalid. Using delete $rows[3] is not supported, you should use $dataTable->deleteRow( $idRow ); instead. If you wish to prove a bug, please provide a new unit test to https://github.com/piwik/piwik/blob/master/tests/core/DataTable.test.php that would revel the bug. thx |
"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().
The text was updated successfully, but these errors were encountered: