diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-06-29 13:23:45 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-06-29 13:23:45 -0700 |
commit | dd1fc46f0986e5675d24208199b88150f643925d (patch) | |
tree | b19ecc1c4f60882f5cc231214398e57190d6ce14 /index.php | |
parent | f65015b24a8448ecbb12b3897992cdaf6b563212 (diff) | |
parent | 5b8e40aaa9bdb0c07cce0cf53cd913b0c397fdc4 (diff) |
Merge branch '0.8.x' into design_reset
* 0.8.x: (32 commits)
admin indicators in groups
show section with admins in sidebar of group
update to latest (r76) version of XMPPHP
better output for common error handler
fix logging error
note when going background
change name of constructor for xmppdaemon
add a lot more logging to xmppdaemon
error in get_option_value wasn't returning a value
reformat commandline.inc
if not in daemon mode, xmppdaemon sends log to stdout
extract log-line formatting to its own function
got my background/foreground logic backwards
twitter status fetcher takes an id argument
more efficient fixup of conversations
commandline processing handles errors better
xmppdaemon.php can stay in foreground
command line arg handling a little more flexible
Daemon can optionally not go into the background
don't canonicalize people's text into URLs
...
Conflicts:
theme/base/css/display.css
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 48 |
1 files changed, 34 insertions, 14 deletions
@@ -73,13 +73,45 @@ function handleError($error) exit(-1); } +function checkMirror($action_obj) +{ + global $config; + + static $alwaysRW = array('session', 'remember_me'); + + if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) { + if (is_array(common_config('db', 'mirror'))) { + // "load balancing", ha ha + $arr = common_config('db', 'mirror'); + $k = array_rand($arr); + $mirror = $arr[$k]; + } else { + $mirror = common_config('db', 'mirror'); + } + + // We ensure that these tables always are used + // on the master DB + + $config['db']['database_rw'] = $config['db']['database']; + $config['db']['ini_rw'] = INSTALLDIR.'/classes/laconica.ini'; + + foreach ($alwaysRW as $table) { + $config['db']['table_'.$table] = 'rw'; + } + + // everyone else uses the mirror + + $config['db']['database'] = $mirror; + } +} + function main() { // quick check for fancy URL auto-detection support in installer. if (isset($_SERVER['REDIRECT_URL']) && ((dirname($_SERVER['REQUEST_URI']) . '/check-fancy') === $_SERVER['REDIRECT_URL'])) { die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs."); } - global $user, $action, $config; + global $user, $action; Snapshot::check(); @@ -146,19 +178,7 @@ function main() } else { $action_obj = new $action_class(); - // XXX: find somewhere for this little block to live - - if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) { - if (is_array(common_config('db', 'mirror'))) { - // "load balancing", ha ha - $arr = common_config('db', 'mirror'); - $k = array_rand($arr); - $mirror = $arr[$k]; - } else { - $mirror = common_config('db', 'mirror'); - } - $config['db']['database'] = $mirror; - } + checkMirror($action_obj); try { if ($action_obj->prepare($args)) { |