mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 21:41:59 +01:00
Added read-only connection support for manticore
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
3637d59942
commit
8da731c174
@ -1,7 +1,15 @@
|
||||
1.4.5:
|
||||
------
|
||||
|
||||
- Added read-only connection support for manticore
|
||||
If using sphinx, add the following to config-site.php:
|
||||
$config['SPHINX_HOSTNAME_READONLY'] = '127.0.0.1:9306';
|
||||
|
||||
|
||||
1.4.4:
|
||||
------
|
||||
|
||||
Renamed "group" table to "usergroup"
|
||||
- Renamed "group" table to "usergroup"
|
||||
Be sure to run util/db-upgrade.sql on the mysql piler database
|
||||
|
||||
|
||||
|
@ -248,7 +248,8 @@ index note1
|
||||
searchd
|
||||
{
|
||||
listen = 127.0.0.1:9312
|
||||
listen = 127.0.0.1:9306:mysql41
|
||||
listen = 127.0.0.1:9306
|
||||
listen = 127.0.0.1:9307:mysql_readonly
|
||||
log = /var/piler/manticore/manticore.log
|
||||
binlog_max_log_size = 256M
|
||||
binlog_path = /var/piler/manticore
|
||||
|
@ -49,8 +49,8 @@ class ControllerMessageBulkremove extends Controller {
|
||||
AUDIT(ACTION_REMOVE_MESSAGE, '', '', $id, '');
|
||||
$db->query("UPDATE " . TABLE_META . " SET retained=? WHERE id=?", [NOW, $id]);
|
||||
if(RT) {
|
||||
$sphx = Registry::get('sphx');
|
||||
$sphx->query("DELETE FROM " . SPHINX_MAIN_INDEX . " WHERE id=" . (int)$this->data['id']);
|
||||
$sphxrw = Registry::get('sphxrw');
|
||||
$sphxrw->query("DELETE FROM " . SPHINX_MAIN_INDEX . " WHERE id=" . (int)$this->data['id']);
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, $this->data['username'] . " removed message: $id");
|
||||
|
@ -41,8 +41,8 @@ class ControllerMessageRemove extends Controller {
|
||||
$db->query("UPDATE " . TABLE_META . " SET retained=? WHERE id=?", [NOW, $id]);
|
||||
$db->query("UPDATE " . TABLE_DELETED . " SET deleted=1 WHERE id=?", [$id]);
|
||||
if(RT) {
|
||||
$sphx = Registry::get('sphx');
|
||||
$sphx->query("DELETE FROM " . SPHINX_MAIN_INDEX . " WHERE id=", (int)$this->data['id']);
|
||||
$sphxrw = Registry::get('sphxrw');
|
||||
$sphxrw->query("DELETE FROM " . SPHINX_MAIN_INDEX . " WHERE id=", (int)$this->data['id']);
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, $this->data['username'] . " removed message: $id");
|
||||
|
@ -41,8 +41,10 @@ Registry::set('db', $db);
|
||||
|
||||
Registry::set('DB_DRIVER', DB_DRIVER);
|
||||
|
||||
$sphx = new DB(SPHINX_DRIVER, SPHINX_HOSTNAME, "", "", SPHINX_DATABASE, "");
|
||||
$sphx = new DB(SPHINX_DRIVER, SPHINX_HOSTNAME_READONLY, "", "", SPHINX_DATABASE, "");
|
||||
$sphxrw = new DB(SPHINX_DRIVER, SPHINX_HOSTNAME, "", "", SPHINX_DATABASE, "");
|
||||
Registry::set('sphx', $sphx);
|
||||
Registry::set('sphxrw', $sphxrw);
|
||||
|
||||
|
||||
if(MEMCACHED_ENABLED) {
|
||||
@ -112,6 +114,3 @@ else {
|
||||
|
||||
$controller = new Front();
|
||||
$controller->dispatch($action, new Router('common/not_found'));
|
||||
|
||||
|
||||
?>
|
||||
|
@ -486,13 +486,13 @@ class ModelSearchMessage extends Model {
|
||||
|
||||
if($tag == '') {
|
||||
if(RT) {
|
||||
$this->sphx->query("DELETE FROM " . SPHINX_TAG_INDEX . " WHERE uid=$uid AND mid=$id");
|
||||
$this->sphxrw->query("DELETE FROM " . SPHINX_TAG_INDEX . " WHERE uid=$uid AND mid=$id");
|
||||
} else {
|
||||
$query = $this->db->query("DELETE FROM " . TABLE_TAG . " WHERE uid=? AND id=?", array($uid, $id));
|
||||
}
|
||||
} else {
|
||||
if(RT) {
|
||||
$this->sphx->query("REPLACE INTO " . SPHINX_TAG_INDEX . " (mid, uid, tag) VALUES (?,?,?)",[$id,$uid,$tag]);
|
||||
$this->sphxrw->query("REPLACE INTO " . SPHINX_TAG_INDEX . " (mid, uid, tag) VALUES (?,?,?)",[$id,$uid,$tag]);
|
||||
} else {
|
||||
$query = $this->db->query("UPDATE " . TABLE_TAG . " SET tag=? WHERE uid=? AND id=?", array($tag, $uid, $id));
|
||||
if($this->db->countAffected() == 0) {
|
||||
@ -510,7 +510,7 @@ class ModelSearchMessage extends Model {
|
||||
|
||||
if(RT) {
|
||||
$ids_str = implode(",", $ids);
|
||||
$this->sphx->query("DELETE FROM " . SPHINX_TAG_INDEX . " WHERE uid=$uid AND mid IN ($ids_str)");
|
||||
$this->sphxrw->query("DELETE FROM " . SPHINX_TAG_INDEX . " WHERE uid=$uid AND mid IN ($ids_str)");
|
||||
} else {
|
||||
$query = $this->db->query("DELETE FROM " . TABLE_TAG . " WHERE uid=? AND id IN ($q)", $arr);
|
||||
}
|
||||
@ -518,7 +518,7 @@ class ModelSearchMessage extends Model {
|
||||
if($tag) {
|
||||
foreach ($ids as $id) {
|
||||
if(RT) {
|
||||
$this->sphx->query("INSERT INTO " . SPHINX_TAG_INDEX . " (mid, uid, tag) VALUES(?,?,?)", [$id, $uid, $tag]);
|
||||
$this->sphxrw->query("INSERT INTO " . SPHINX_TAG_INDEX . " (mid, uid, tag) VALUES(?,?,?)", [$id, $uid, $tag]);
|
||||
} else {
|
||||
$query = $this->db->query("INSERT INTO " . TABLE_TAG . " (id, uid, tag) VALUES(?,?,?)", array($id, $uid, $tag));
|
||||
}
|
||||
@ -561,10 +561,10 @@ class ModelSearchMessage extends Model {
|
||||
public function add_message_rt_note($id = '', $uid = 0, $note = '') {
|
||||
if($id == '' || $uid <= 0) { return 0; }
|
||||
|
||||
$this->sphx->query("DELETE FROM " . SPHINX_NOTE_INDEX . " WHERE uid=$uid AND mid=$id");
|
||||
$this->sphxrw->query("DELETE FROM " . SPHINX_NOTE_INDEX . " WHERE uid=$uid AND mid=$id");
|
||||
|
||||
if($note) {
|
||||
$this->sphx->query("INSERT INTO " . SPHINX_NOTE_INDEX . " (mid, uid, note) VALUES (?,?,?)",[$id,$uid,$note]);
|
||||
$this->sphxrw->query("INSERT INTO " . SPHINX_NOTE_INDEX . " (mid, uid, note) VALUES (?,?,?)",[$id,$uid,$note]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user