From: Andrew Dolgov Date: Wed, 17 Apr 2013 13:00:24 +0000 (+0400) Subject: remove db_connect, db_close; CLI fixes X-Git-Tag: 1.7.9~25^2~171 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=eefaa2df381686f771396baae2d0ae71b345c2e7;p=tt-rss.git remove db_connect, db_close; CLI fixes --- diff --git a/backend.php b/backend.php index b06cca2d..d3d8622d 100644 --- a/backend.php +++ b/backend.php @@ -48,8 +48,6 @@ $script_started = microtime(true); - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; header("Content-Type: text/json; charset=utf-8"); @@ -154,6 +152,4 @@ header("Content-Type: text/json"); print json_encode(array("error" => array("code" => 7))); - // We close the connection to database. - db_close(); ?> diff --git a/classes/db/mysql.php b/classes/db/mysql.php index 241d2a06..fe5d05e2 100644 --- a/classes/db/mysql.php +++ b/classes/db/mysql.php @@ -4,6 +4,7 @@ class Db_Mysql implements IDb { function connect($host, $user, $pass, $db, $port) { $this->link = mysql_connect($host, $user, $pass); + if ($this->link) { $result = mysql_select_db($db, $this->link); if (!$result) { diff --git a/include/db.php b/include/db.php index 11e7312a..72c78474 100644 --- a/include/db.php +++ b/include/db.php @@ -1,9 +1,5 @@ connect($host, $user, $pass, $db, 0); -} - function db_escape_string( $s, $strip_tags = true) { return Db::get()->escape_string($s, $strip_tags); } @@ -25,10 +21,6 @@ function db_fetch_result($result, $row, $param) { return Db::get()->fetch_result($result, $row, $param); } -function db_close() { - return Db::get()->close(); -} - function db_affected_rows( $result) { return Db::get()->affected_rows($result); } diff --git a/include/errorhandler.php b/include/errorhandler.php index b1a0d3d0..2c8d35f8 100644 --- a/include/errorhandler.php +++ b/include/errorhandler.php @@ -6,7 +6,7 @@ require_once "classes/logger/sql.php"; function ttrss_error_handler($errno, $errstr, $file, $line, $context) { global $logger; - if (error_reporting() == 0) return false; + if (error_reporting() == 0 || !$errno) return false; if (!$logger) $logger = new Logger_SQL(); @@ -30,6 +30,8 @@ function ttrss_fatal_handler() { $line = $error["line"]; $errstr = $error["message"]; + if (!$errno) return false; + $context = debug_backtrace(); $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); diff --git a/index.php b/index.php index cb95b96f..d8b58407 100644 --- a/index.php +++ b/index.php @@ -30,8 +30,6 @@ $mobile = new Mobile_Detect(); - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; global $pluginhost; @@ -285,7 +283,5 @@ - - diff --git a/opml.php b/opml.php index c8fbf1c3..b9322161 100644 --- a/opml.php +++ b/opml.php @@ -10,8 +10,6 @@ require_once "db.php"; require_once "db-prefs.php"; - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; $op = $_REQUEST['op']; @@ -34,6 +32,4 @@ } } - db_close(); - ?> diff --git a/prefs.php b/prefs.php index 54d5ebad..82672831 100644 --- a/prefs.php +++ b/prefs.php @@ -20,8 +20,6 @@ require_once "config.php"; require_once "db-prefs.php"; - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; login_sequence(); @@ -154,7 +152,5 @@ - - diff --git a/public.php b/public.php index fa8ea29b..6ace943c 100644 --- a/public.php +++ b/public.php @@ -29,8 +29,6 @@ $script_started = microtime(true); - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { @@ -61,6 +59,4 @@ header("Content-Type: text/plain"); print json_encode(array("error" => array("code" => 7))); - // We close the connection to database. - db_close(); ?> diff --git a/register.php b/register.php index a8fdb483..5bc6563b 100644 --- a/register.php +++ b/register.php @@ -17,8 +17,6 @@ $action = $_REQUEST["action"]; - $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_plugins()) return; if ($_REQUEST["format"] == "feed") { diff --git a/update_daemon2.php b/update_daemon2.php index f5e031c9..a1d7e7d6 100755 --- a/update_daemon2.php +++ b/update_daemon2.php @@ -178,8 +178,6 @@ $schema_version = get_schema_version(); - db_close(); - if ($schema_version != SCHEMA_VERSION) { die("Schema version is wrong, please upgrade the database.\n"); } @@ -199,7 +197,6 @@ /* Check if schema version changed */ - init_plugins(); $test_schema_version = get_schema_version(); if ($test_schema_version != $schema_version) { @@ -289,8 +286,6 @@ } } - db_close(); - // We are in a fork. // We wait a little before exiting to avoid to be faster than our parent process. sleep(1);