]> git.wh0rd.org Git - tt-rss.git/commitdiff
remove db_connect, db_close; CLI fixes
authorAndrew Dolgov <fox@fakecake.org>
Wed, 17 Apr 2013 13:00:24 +0000 (17:00 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Wed, 17 Apr 2013 13:00:35 +0000 (17:00 +0400)
backend.php
classes/db/mysql.php
include/db.php
include/errorhandler.php
index.php
opml.php
prefs.php
public.php
register.php
update_daemon2.php

index b06cca2d24e0dbe6f185ecfc23bd01c0df1b4eb7..d3d8622d97025c6440cfbf110895d2e300988007 100644 (file)
@@ -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");
        header("Content-Type: text/json");
        print json_encode(array("error" => array("code" => 7)));
 
-       // We close the connection to database.
-       db_close();
 ?>
index 241d2a063b42234a4b614528b5fc9c58690d4552..fe5d05e2f540de0d245f30d168bb83b9507fe2b1 100644 (file)
@@ -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) {
index 11e7312ad1ee04ff646ec5f521e5fb0ceed9aa44..72c78474acd4248235d85180b65ff73dad6ef8c1 100644 (file)
@@ -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);
 }
index b1a0d3d0cfe2bb358f02cf8fbb22b8ea9f61be40..2c8d35f8371c4a8b2759d014642245910b50ad97 100644 (file)
@@ -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);
index cb95b96f0219afdc4fe7e359e3a0a41597588611..d8b58407194d8288faece81398b161e96b6d52f9 100644 (file)
--- 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;
 </div>
 </div>
 
-<?php db_close(); ?>
-
 </body>
 </html>
index c8fbf1c394c20a0d32d44c762c7fac98351aa2a2..b932216148bf39b922e7fc9585528c97876baa4e 100644 (file)
--- 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();
-
 ?>
index 54d5ebad8cf7c47b4ba98759941ed92f5e8a9cc8..826728315ea3c994ffe912815efc55394b02ceda 100644 (file)
--- 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();
 
 </div>
 
-<?php db_close(); ?>
-
 </body>
 </html>
index fa8ea29b8f4623f9dceb037d6ff5bc49a62c5ee3..6ace943c411744af99d348a4e936673d80640f3a 100644 (file)
@@ -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();
 ?>
index a8fdb483aec1c476f6f9c098a81a745d09f12326..5bc6563b0829c6a449ab243ac4ec22e0d3a2ab3f 100644 (file)
@@ -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") {
index f5e031c9ea977f59db8433663f46ed29a50003ca..a1d7e7d66a35c7cca0e0370726762f98ffb5a733 100755 (executable)
 
        $schema_version = get_schema_version();
 
-       db_close();
-
        if ($schema_version != SCHEMA_VERSION) {
                die("Schema version is wrong, please upgrade the database.\n");
        }
 
                        /* Check if schema version changed */
 
-                       init_plugins();
                        $test_schema_version = get_schema_version();
 
                        if ($test_schema_version != $schema_version) {
                                                }
                                        }
 
-                                       db_close();
-
                                        // We are in a fork.
                                        // We wait a little before exiting to avoid to be faster than our parent process.
                                        sleep(1);