From: Matteo Nastasi (mop) Date: Mon, 23 Nov 2015 18:02:45 +0000 (+0100) Subject: avoid inconsistency during db blackout X-Git-Tag: v5.3.0~45 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=a08888cb6500fa8c7bc3c241c4a56e5d59fa6da3;p=brisk.git avoid inconsistency during db blackout --- diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 8316d85..8463884 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -113,6 +113,10 @@ class BriskDB function query($sql) { + if (!$this->dbconn) + if (($this->dbconn = DBConn::recover()) == FALSE) + return FALSE; + if (($res = @pg_query($this->dbconn->db(), $sql)) == FALSE) { error_log('pg_result_status: ' . pg_result_status($res)); error_log('pg_connection_status: ' . pg_connection_status($this->dbconn->db())); @@ -355,11 +359,9 @@ class BriskDB $user_sql = sprintf("UPDATE %susers SET (type, supp_comp) = (%d, '%s') WHERE code = %d;", $G_dbpfx, $flags, escsql($supp_comp), $code); - fprintf(STDERR, "REQUEST [%s]\n", $user_sql); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; } - fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql); return TRUE; } @@ -370,11 +372,9 @@ class BriskDB $user_sql = sprintf("UPDATE %susers SET (type, disa_reas) = (%d, %d) WHERE code = %d;", $G_dbpfx, $flags, $disa_reas, $code); - fprintf(STDERR, "REQUEST [%s]\n", $user_sql); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; } - fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql); return TRUE; } @@ -385,11 +385,9 @@ class BriskDB $user_sql = sprintf("UPDATE %susers SET (tos_vers) = ('%s') WHERE code = %d;", $G_dbpfx, escsql($tos_vers), $code); - fprintf(STDERR, "REQUEST [%s]\n", $user_sql); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; } - fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql); return TRUE; }