summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-17 17:00:24 +0400
committerAndrew Dolgov <[email protected]>2013-04-17 17:00:35 +0400
commiteefaa2df381686f771396baae2d0ae71b345c2e7 (patch)
tree767f9d583e38a27c0150854fcb1b02c2cd507aa2
parent6322ac79a020ab584d412d782d62b2ee77d7c6cf (diff)
remove db_connect, db_close; CLI fixes
-rw-r--r--backend.php4
-rw-r--r--classes/db/mysql.php1
-rw-r--r--include/db.php8
-rw-r--r--include/errorhandler.php4
-rw-r--r--index.php4
-rw-r--r--opml.php4
-rw-r--r--prefs.php4
-rw-r--r--public.php4
-rw-r--r--register.php2
-rwxr-xr-xupdate_daemon2.php5
10 files changed, 4 insertions, 36 deletions
diff --git a/backend.php b/backend.php
index b06cca2d2..d3d8622d9 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 241d2a063..fe5d05e2f 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 11e7312ad..72c78474a 100644
--- a/include/db.php
+++ b/include/db.php
@@ -1,9 +1,5 @@
<?php
-function db_connect($host, $user, $pass, $db) {
- return Db::get()->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 b1a0d3d0c..2c8d35f83 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 cb95b96f0..d8b584071 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 @@
</div>
</div>
-<?php db_close(); ?>
-
</body>
</html>
diff --git a/opml.php b/opml.php
index c8fbf1c39..b93221614 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 54d5ebad8..826728315 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 @@
</div>
-<?php db_close(); ?>
-
</body>
</html>
diff --git a/public.php b/public.php
index fa8ea29b8..6ace943c4 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 a8fdb483a..5bc6563b0 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 f5e031c9e..a1d7e7d66 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);