[Piwik-svn] r522 - in trunk: config modules modules/LogStats plugins/Installation

svnmaster at piwik.org svnmaster at piwik.org
Wed Jun 11 02:31:05 CEST 2008


Author: matt
Date: 2008-06-11 02:31:03 +0200 (Wed, 11 Jun 2008)
New Revision: 522

Modified:
   trunk/config/global.ini.php
   trunk/modules/LogStats.php
   trunk/modules/LogStats/Db.php
   trunk/plugins/Installation/Controller.php
Log:
- fixes #205 you can now install with a mysql port non 3306 by specifying your.host:4455

Modified: trunk/config/global.ini.php
===================================================================
--- trunk/config/global.ini.php	2008-06-10 00:26:35 UTC (rev 521)
+++ trunk/config/global.ini.php	2008-06-11 00:31:03 UTC (rev 522)
@@ -9,6 +9,7 @@
 password		= 
 dbname			= 
 tables_prefix	= 
+port			= 3306
 adapter			= PDO_MYSQL ; PDO_MYSQL or MYSQLI
 
 [database_tests]
@@ -17,6 +18,7 @@
 password 		= 
 dbname			= piwik_tests
 tables_prefix	= piwiktests_
+port			= 3306
 adapter 		= PDO_MYSQL
 
 [Language]

Modified: trunk/modules/LogStats/Db.php
===================================================================
--- trunk/modules/LogStats/Db.php	2008-06-10 00:26:35 UTC (rev 521)
+++ trunk/modules/LogStats/Db.php	2008-06-11 00:31:03 UTC (rev 522)
@@ -30,9 +30,9 @@
 	/**
 	 * Builds the DB object
 	 */
-	public function __construct( $host, $username, $password, $dbname, $driverName = 'mysql') 
+	public function __construct( $host, $username, $password, $dbname, $port, $driverName = 'mysql') 
 	{
-		$this->dsn = $driverName.":dbname=$dbname;host=$host";
+		$this->dsn = $driverName.":dbname=$dbname;host=$host;port=$port";
 		$this->username = $username;
 		$this->password = $password;
 	}

Modified: trunk/modules/LogStats.php
===================================================================
--- trunk/modules/LogStats.php	2008-06-10 00:26:35 UTC (rev 521)
+++ trunk/modules/LogStats.php	2008-06-11 00:31:03 UTC (rev 522)
@@ -87,11 +87,16 @@
 		// we decode the password. Password is html encoded because it's enclosed between " double quotes
 		$configDb['password'] = htmlspecialchars_decode($configDb['password']);
 		
+		if(!isset($configDb['port']))
+		{
+			// before 0.2.4 there is no port specified in config file
+			$configDb['port'] = '3306';  
+		}
 		self::$db = new Piwik_LogStats_Db( 	$configDb['host'], 
 										$configDb['username'], 
 										$configDb['password'], 
-										$configDb['dbname']
-							);
+										$configDb['dbname'],
+										$configDb['port'] );
 							  
 		self::$db->connect();
 	}

Modified: trunk/plugins/Installation/Controller.php
===================================================================
--- trunk/plugins/Installation/Controller.php	2008-06-10 00:26:35 UTC (rev 521)
+++ trunk/plugins/Installation/Controller.php	2008-06-11 00:31:03 UTC (rev 522)
@@ -121,13 +121,17 @@
 				'dbname' 		=> $form->getSubmitValue('dbname'),
 				'tables_prefix' => $form->getSubmitValue('tables_prefix'),
 				'adapter' 		=> Zend_Registry::get('config')->database->adapter,
+				'port'			=> Zend_Registry::get('config')->database->port,
 			);
 			
-			// we test the DB connection with these settings
 			try{ 
-//				var_dump($dbInfos);exit;
 				$dbInfos['password'] = '"'.htmlspecialchars($form->getSubmitValue('password')).'"';
 				
+				if(($portIndex = strpos($dbInfos['host'],':')) !== false)
+				{
+					$dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1 );
+					$dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
+				}
 				Piwik::createDatabaseObject($dbInfos);
 				
 				$_SESSION['db_infos'] = $dbInfos;



More information about the Piwik-svn mailing list