Permalink
Browse files

Fix for error "Class '\Piwik\Db\Schema\' not found", default to Mysql…

… when schema is empty
  • Loading branch information...
1 parent a29bb6e commit d040733f50c62726066d40947f9b9f529d8e342a @mattab mattab committed Mar 8, 2014
Showing with 11 additions and 7 deletions.
  1. +11 −7 core/Db/Schema.php
View
18 core/Db/Schema.php
@@ -20,6 +20,7 @@
*/
class Schema extends Singleton
{
+ const DEFAULT_SCHEMA = 'Mysql';
/**
* Type of database schema
@@ -37,7 +38,14 @@ class Schema extends Singleton
*/
private static function getSchemaClassName($schemaName)
{
- return '\Piwik\Db\Schema\\' . str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($schemaName))));
+ // Upgrade from pre 2.0.4
+ if(strtolower($schemaName) == 'myisam'
+ || empty($schemaName)) {
+ $schemaName = self::DEFAULT_SCHEMA;
+ }
+
+ $class = str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($schemaName))));
+ return '\Piwik\Db\Schema\\' . $class;
}
/**
@@ -50,7 +58,7 @@ public static function getSchemas($adapterName)
{
static $allSchemaNames = array(
'MYSQL' => array(
- 'Mysql',
+ self::DEFAULT_SCHEMA,
// InfiniDB
),
@@ -110,12 +118,8 @@ private function loadSchema()
{
$config = Config::getInstance();
$dbInfos = $config->database;
- $schemaName = $dbInfos['schema'];
+ $schemaName = trim($dbInfos['schema']);
- // Upgrade from pre 2.0.4
- if(strtolower($schemaName) == 'myisam') {
- $schemaName = 'Mysql';
- }
$className = self::getSchemaClassName($schemaName);
$this->schema = new $className();
}

0 comments on commit d040733

Please sign in to comment.