Browse Source

remove db_connect, db_close; CLI fixes

Andrew Dolgov 7 years ago
parent
commit
eefaa2df38
10 changed files with 4 additions and 36 deletions
  1. 0 4
      backend.php
  2. 1 0
      classes/db/mysql.php
  3. 0 8
      include/db.php
  4. 3 1
      include/errorhandler.php
  5. 0 4
      index.php
  6. 0 4
      opml.php
  7. 0 4
      prefs.php
  8. 0 4
      public.php
  9. 0 2
      register.php
  10. 0 5
      update_daemon2.php

+ 0 - 4
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();
 ?>

+ 1 - 0
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) {

+ 0 - 8
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);
 }

+ 3 - 1
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);

+ 0 - 4
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>

+ 0 - 4
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();
-
 ?>

+ 0 - 4
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>

+ 0 - 4
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();
 ?>

+ 0 - 2
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") {

+ 0 - 5
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);