From 3094dd3822db3ceb22619d66520b4f0012f4d9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Peters?= Date: Wed, 24 Oct 2018 22:32:05 +0200 Subject: [PATCH] [Web] Cleanup _sogo_static_view and memcached --- data/web/inc/init_db.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index 388772b1..ee653cf4 100644 --- a/data/web/inc/init_db.inc.php +++ b/data/web/inc/init_db.inc.php @@ -1016,5 +1016,22 @@ if (php_sapi_name() == "cli") { PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone = '" . $offset . "', group_concat_max_len = 3423543543;", ]; $pdo = new PDO($dsn, $database_user, $database_pass, $opt); + $stmt = $pdo->query("SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_NAME = 'sogo_view'"); + $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); + if ($num_results != 0) { + $stmt = $pdo->query("REPLACE INTO _sogo_static_view SELECT * from sogo_view"); + $stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');"); + } + echo "Fixed _sogo_static_view" . PHP_EOL; + try { + $m = new Memcached(); + $m->addServer('memcached', 11211); + $m->flush(); + } + catch ( Exception $e ) { + // Dunno + } + echo "Cleaned up memcached". PHP_EOL; init_db_schema(); }