From 55068030d22b6faf46f216d0c2411d6a32ec655e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 6 May 2011 17:18:38 -0700 Subject: [PATCH] hook for defining new read-write tables --- EVENTS.txt | 9 +++++++++ index.php | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index e1620a7e2a..f3f45cd084 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1391,3 +1391,12 @@ EndDocFileForTitle: After searching for a doc or mail template - $title: Title we looked for - $paths: Paths we searched - &$filename: Filename so far (set this if you want) + +StartReadWriteTables: when noting which tables must be read-write, even on read-only actions +- &$tables: list of table names +- &$rwdb: read-write database URI + +EndReadWriteTables: after noting which tables must be read-write, even on read-only actions +- $tables: list of table names +- $rwdb: read-write database URI + diff --git a/index.php b/index.php index 3265f0c0e9..3534739bfa 100644 --- a/index.php +++ b/index.php @@ -175,15 +175,24 @@ function setupRW() static $alwaysRW = array('session', 'remember_me'); - // We ensure that these tables always are used - // on the master DB + $rwdb = $config['db']['database']; - $config['db']['database_rw'] = $config['db']['database']; - $config['db']['ini_rw'] = INSTALLDIR.'/classes/statusnet.ini'; + if (Event::handle('StartReadWriteTables', array(&$alwaysRW, &$rwdb))) { - foreach ($alwaysRW as $table) { - $config['db']['table_'.$table] = 'rw'; + // We ensure that these tables always are used + // on the master DB + + $config['db']['database_rw'] = $rwdb; + $config['db']['ini_rw'] = INSTALLDIR.'/classes/statusnet.ini'; + + foreach ($alwaysRW as $table) { + $config['db']['table_'.$table] = 'rw'; + } + + Event::handle('EndReadWriteTables', array($alwaysRW, $rwdb)); } + + return; } function checkMirror($action_obj, $args)