summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-10-01 15:11:12 -0400
committerEvan Prodromou <evan@status.net>2009-10-01 15:11:12 -0400
commitd103522ff364098ed26305b31d1cb62f87de1318 (patch)
tree2e40dc7163f60777ea7466dac1134f8f50a5e3b3
parentb980f5e45b613d60e968e84b304ef9db260f24c2 (diff)
check the schema
-rw-r--r--EVENTS.txt2
-rw-r--r--README8
-rw-r--r--lib/common.php6
-rw-r--r--lib/default.php3
-rw-r--r--scripts/checkschema.php30
5 files changed, 48 insertions, 1 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index e0d4bbd06..fbb2f36a7 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -283,3 +283,5 @@ StartShowHeadElements: Right after the <head> tag
EndShowHeadElements: Right before the </head> tag; put <script>s here if you need them in <head>
- $action: the current action
+
+CheckSchema: chance to check the schema
diff --git a/README b/README
index f3b2528b8..486656a3b 100644
--- a/README
+++ b/README
@@ -1037,6 +1037,14 @@ utf8: whether to talk to the database in UTF-8 mode. This is the default
with new installations, but older sites may want to turn it off
until they get their databases fixed up. See "UTF-8 database"
above for details.
+schemacheck: when to let plugins check the database schema to add
+ tables or update them. Values can be 'runtime' (default)
+ or 'script'. 'runtime' can be costly (plugins check the
+ schema on every hit, adding potentially several db
+ queries, some quite long), but not everyone knows how to
+ run a script. If you can, set this to 'script' and run
+ scripts/checkschema.php whenever you install or upgrade a
+ plugin.
syslog
------
diff --git a/lib/common.php b/lib/common.php
index 58e208a4e..ce33c871b 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -232,6 +232,12 @@ require_once INSTALLDIR.'/lib/serverexception.php';
Config::loadSettings();
+// XXX: if plugins should check the schema at runtime, do that here.
+
+if ($config['db']['schemacheck'] == 'runtime') {
+ Event::handle('CheckSchema');
+}
+
// XXX: other formats here
define('NICKNAME_FMT', VALIDATE_NUM.VALIDATE_ALPHA_LOWER);
diff --git a/lib/default.php b/lib/default.php
index 7af94d2ad..f9670cb7f 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -64,7 +64,8 @@ $default =
'utf8' => true,
'db_driver' => 'DB', # XXX: JanRain libs only work with DB
'quote_identifiers' => false,
- 'type' => 'mysql' ),
+ 'type' => 'mysql',
+ 'schemacheck' => 'runtime'), // 'runtime' or 'script'
'syslog' =>
array('appname' => 'statusnet', # for syslog
'priority' => 'debug', # XXX: currently ignored
diff --git a/scripts/checkschema.php b/scripts/checkschema.php
new file mode 100644
index 000000000..bf52abe15
--- /dev/null
+++ b/scripts/checkschema.php
@@ -0,0 +1,30 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$helptext = <<<END_OF_CHECKSCHEMA_HELP
+Gives plugins a chance to update the database schema.
+
+END_OF_CHECKSCHEMA_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+Event::handle('CheckSchema');