summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/installer.php2
-rw-r--r--lib/mysqlschema.php15
-rw-r--r--lib/schema.php37
3 files changed, 23 insertions, 31 deletions
diff --git a/lib/installer.php b/lib/installer.php
index bd9d69cd4..ff2bed140 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -91,7 +91,7 @@ abstract class Installer
}
if (version_compare(PHP_VERSION, '5.2.3', '<')) {
- $errors[] = 'Require PHP version 5.2.3 or greater.';
+ $this->warning('Require PHP version 5.2.3 or greater.');
$pass = false;
}
diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php
index 455695366..464c718f9 100644
--- a/lib/mysqlschema.php
+++ b/lib/mysqlschema.php
@@ -50,21 +50,6 @@ class MysqlSchema extends Schema
static $_single = null;
protected $conn = null;
- /**
- * Constructor. Only run once for singleton object.
- */
-
- protected function __construct()
- {
- // XXX: there should be an easier way to do this.
- $user = new User();
-
- $this->conn = $user->getDatabaseConnection();
-
- $user->free();
-
- unset($user);
- }
/**
* Main public entry point. Use this to get
diff --git a/lib/schema.php b/lib/schema.php
index 1503c96d4..e5def514e 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -47,40 +47,47 @@ if (!defined('STATUSNET')) {
class Schema
{
- static $_single = null;
+ static $_static = null;
protected $conn = null;
/**
* Constructor. Only run once for singleton object.
*/
- protected function __construct()
+ protected function __construct($conn = null)
{
- // XXX: there should be an easier way to do this.
- $user = new User();
-
- $this->conn = $user->getDatabaseConnection();
-
- $user->free();
+ if (is_null($conn)) {
+ // XXX: there should be an easier way to do this.
+ $user = new User();
+ $conn = $user->getDatabaseConnection();
+ $user->free();
+ unset($user);
+ }
- unset($user);
+ $this->conn = $conn;
}
/**
* Main public entry point. Use this to get
- * the singleton object.
+ * the schema object.
*
- * @return Schema the (single) Schema object
+ * @return Schema the Schema object for the connection
*/
- static function get()
+ static function get($conn = null)
{
+ if (is_null($conn)) {
+ $key = 'default';
+ } else {
+ $key = md5(serialize($conn->dsn));
+ }
+
$type = common_config('db', 'type');
- if (empty(self::$_single)) {
+ if (empty(self::$_static[$key])) {
$schemaClass = ucfirst($type).'Schema';
- self::$_single = new $schemaClass();
+ self::$_static[$key] = new $schemaClass($conn);
}
- return self::$_single;
+ return self::$_static[$key];
}
/**