Skip to content
Extraits de code Groupes Projets
Valider 04667193 rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Simplifying Archive BLOB by removing unused DataTable object properties before unserialize

git-svn-id: http://dev.piwik.org/svn/trunk@6575 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 2431c6c1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -783,6 +783,11 @@ class Piwik_DataTable ...@@ -783,6 +783,11 @@ class Piwik_DataTable
$this->deleteColumns(array($name)); $this->deleteColumns(array($name));
} }
public function __sleep()
{
return array('rows', 'parents', 'summaryRow');
}
/** /**
* Rename a column in all rows * Rename a column in all rows
* *
......
...@@ -51,7 +51,18 @@ class Test_Piwik_DataTable extends UnitTestCase ...@@ -51,7 +51,18 @@ class Test_Piwik_DataTable extends UnitTestCase
// normal row // normal row
$idToDelete = 1; $idToDelete = 1;
$this->assertEqual(count($table->getRowFromId($idToDelete)->getColumns()), 2); $row = $table->getRowFromId($idToDelete);
// ----- Also testing the Serialize output to ensure there is no unexpected Backward breaking changes in the future
$serializedRow = 'O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:2:{s:5:"label";s:6:"ninety";s:5:"count";i:90;}i:1;a:0:{}i:3;N;}}';
$this->assertEqual($serializedRow, serialize($row));
$serializedTable = 'O:15:"Piwik_DataTable":3:{s:7:"' . "\0" . '*' . "\0" . 'rows";a:3:{i:0;O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:2:{s:5:"label";s:3:"ten";s:5:"count";i:10;}i:1;a:0:{}i:3;N;}}i:1;O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:2:{s:5:"label";s:6:"ninety";s:5:"count";i:90;}i:1;a:0:{}i:3;N;}}i:2;O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:2:{s:5:"label";s:7:"hundred";s:5:"count";i:100;}i:1;a:0:{}i:3;N;}}}s:10:"' . "\0" . '*' . "\0" . 'parents";N;s:13:"' . "\0" . '*' . "\0" . 'summaryRow";O:19:"Piwik_DataTable_Row":1:{s:1:"c";a:3:{i:0;a:2:{s:5:"label";s:7:"summary";s:5:"count";i:200;}i:1;a:0:{}i:3;N;}}}';
$s = serialize($table);
$this->assertEqual($serializedTable, $s);
// ----- End test unserialize
$this->assertEqual(count($row->getColumns()), 2);
$table->deleteRow($idToDelete); $table->deleteRow($idToDelete);
$this->assertEqual($table->getRowFromId($idToDelete), false); $this->assertEqual($table->getRowFromId($idToDelete), false);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter