[Piwik-svn] r334 - in trunk: modules modules/DataTable/Filter plugins/Installation tests/modules
svnmaster at piwik.org
svnmaster at piwik.org
Sun Mar 9 00:57:56 CET 2008
Author: matt
Date: 2008-03-09 00:57:55 +0100 (Sun, 09 Mar 2008)
New Revision: 334
Modified:
trunk/modules/Config.php
trunk/modules/DataTable/Filter/Pattern.php
trunk/modules/LogStats.php
trunk/modules/Piwik.php
trunk/modules/PluginsManager.php
trunk/plugins/Installation/Controller.php
trunk/tests/modules/DataTable.test.php
Log:
- Fixed #129 Error parsing ./config/config.ini.php on line 11
- improved performance on pattern searching in datatables
Modified: trunk/modules/Config.php
===================================================================
--- trunk/modules/Config.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/modules/Config.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -102,7 +102,16 @@
}
}
else
- {
+ {
+ // hack
+ // we add " " around the password because when requesting this data using Zend_Config
+ // the toArray removes the " around the value
+ if( ($section == 'database' || $section == 'database_tests')
+ && $name == 'password')
+ {
+ $value = '"'.$value.'"';
+ }
+
$configFile .= $name." = $value\n";
}
}
Modified: trunk/modules/DataTable/Filter/Pattern.php
===================================================================
--- trunk/modules/DataTable/Filter/Pattern.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/modules/DataTable/Filter/Pattern.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -25,7 +25,9 @@
public function __construct( $table, $columnToFilter, $patternToSearch )
{
parent::__construct($table);
- $this->patternToSearch = preg_quote($patternToSearch);
+// $patternToSearch = preg_quote($patternToSearch, '/');
+// $patternToSearch = str_replace('*','\*',$patternToSearch);
+ $this->patternToSearch = $patternToSearch;
$this->columnToFilter = $columnToFilter;
$this->filter();
}
@@ -34,7 +36,7 @@
{
foreach($this->table->getRows() as $key => $row)
{
- if( !eregi($this->patternToSearch, $row->getColumn($this->columnToFilter)))
+ if( stripos($row->getColumn($this->columnToFilter), $this->patternToSearch) === false)
{
$this->table->deleteRow($key);
}
Modified: trunk/modules/LogStats.php
===================================================================
--- trunk/modules/LogStats.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/modules/LogStats.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -74,6 +74,10 @@
function connectDatabase()
{
$configDb = Piwik_LogStats_Config::getInstance()->database;
+
+ // we decode the password. Password is html encoded because it's enclosed between " double quotes
+ $configDb['password'] = htmlspecialchars_decode($configDb['password']);
+
$this->db = new Piwik_LogStats_Db( $configDb['host'],
$configDb['username'],
$configDb['password'],
Modified: trunk/modules/Piwik.php
===================================================================
--- trunk/modules/Piwik.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/modules/Piwik.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -692,6 +692,17 @@
{
$dbInfos = $config->database->toArray();
}
+
+// var_dump($dbInfos);
+ if(substr($dbInfos['password'],0,1) == '"'
+ && substr($dbInfos['password'],-1,1) == '"'
+ && strlen($dbInfos['password']) >= 2 )
+ {
+ $dbInfos['password'] = substr($dbInfos['password'], 1, -1);
+ }
+ $dbInfos['password'] = htmlspecialchars_decode($dbInfos['password']);
+// var_dump($dbInfos);exit;// we remove the slashes
+
$db = Zend_Db::factory($config->database->adapter, $dbInfos);
$db->getConnection();
// see http://framework.zend.com/issues/browse/ZF-1398
Modified: trunk/modules/PluginsManager.php
===================================================================
--- trunk/modules/PluginsManager.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/modules/PluginsManager.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -39,6 +39,11 @@
*/
class Piwik_PluginsManager
{
+ /**
+ * Dispatcher
+ *
+ * @var Event_Dispatcher
+ */
public $dispatcher;
protected $pluginsToLoad = array();
protected $installPlugins = false;
Modified: trunk/plugins/Installation/Controller.php
===================================================================
--- trunk/plugins/Installation/Controller.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/plugins/Installation/Controller.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -114,7 +114,6 @@
if($form->validate())
{
-// var_dump(Zend_Registry::get('config')->database);
$dbInfos = array(
'host' => $form->getSubmitValue('host'),
'username' => $form->getSubmitValue('username'),
@@ -127,9 +126,13 @@
// we test the DB connection with these settings
try{
+// var_dump($dbInfos);exit;
+ $dbInfos['password'] = '"'.htmlspecialchars($form->getSubmitValue('password')).'"';
+
Piwik::createDatabaseObject($dbInfos);
+
$_SESSION['db_infos'] = $dbInfos;
-
+
$this->redirectToNextStep( __FUNCTION__ );
} catch(Exception $e) {
$view->errorMessage = $e->getMessage();
@@ -404,7 +407,8 @@
protected function createDbFromSessionInformation()
{
- $dbInfos = $_SESSION['db_infos'];
+ $dbInfos = $_SESSION['db_infos'];
+
Zend_Registry::get('config')->database = $dbInfos;
Piwik::createDatabaseObject($dbInfos);
}
Modified: trunk/tests/modules/DataTable.test.php
===================================================================
--- trunk/tests/modules/DataTable.test.php 2008-03-08 23:17:52 UTC (rev 333)
+++ trunk/tests/modules/DataTable.test.php 2008-03-08 23:57:55 UTC (rev 334)
@@ -318,7 +318,7 @@
return;
}
}
-
+
/**
* Test to filter a column with a pattern
*/
@@ -343,11 +343,39 @@
$expectedtable = clone $table;
$expectedtable->deleteRows(array(1,2,4,5,6));
- $filter = new Piwik_DataTable_Filter_Pattern($table, 'label', '(oo)');
+ $filter = new Piwik_DataTable_Filter_Pattern($table, 'label', 'oo');
$this->assertEqual($table->getRows(), $expectedtable->getRows());
}
/**
+ * Test to filter a column with a pattern
+ */
+ function test_filter_Pattern2()
+ {
+ $table = new Piwik_DataTable;
+
+ $idcol = Piwik_DataTable_Row::COLUMNS;
+
+ $rows = array(
+ array( $idcol => array('label'=>'google')),
+ array( $idcol => array('label'=>'ask')),
+ array( $idcol => array('label'=>'piwik')),
+ array( $idcol => array('label'=>'yahoo')),
+ array( $idcol => array('label'=>'amazon')),
+ array( $idcol => array('label'=>'238975247578949')),
+ array( $idcol => array('label'=>'Q*(%&*("$&%*(&"$*")"))')));
+
+ $table->loadFromArray( $rows );
+
+
+ $expectedtable = clone $table;
+ $expectedtable->deleteRows(array(0,1,2,3,4,5));
+
+ $filter = new Piwik_DataTable_Filter_Pattern($table, 'label', '*');
+
+ $this->assertEqual($table->getRows(), $expectedtable->getRows());
+ }
+ /**
* Test to filter a table with a offset, limit
*/
function test_filter_OffsetLimit()
More information about the Piwik-svn
mailing list