mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Don't spam database server with connections
- MOD: Silently ignore failures to e_db_mysql::close(); if it's failing, it's probably already closed - FIX: Close the PDO or mysqli connection after each e_db_abstractTest test - MOD: Changed class2.php's $sql variable to be hinted as an e_db instead of e_db_mysql
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
@@ -391,7 +391,7 @@ e107::getSingleton('e107_traffic'); // We start traffic counting ASAP
|
|||||||
// e107_require_once(e_HANDLER.'mysql_class.php');
|
// e107_require_once(e_HANDLER.'mysql_class.php');
|
||||||
|
|
||||||
//DEPRECATED, BC, $e107->sql caught by __get()
|
//DEPRECATED, BC, $e107->sql caught by __get()
|
||||||
/** @var e_db_mysql $sql */
|
/** @var e_db $sql */
|
||||||
$sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
|
$sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
|
||||||
$sql->db_SetErrorReporting(false);
|
$sql->db_SetErrorReporting(false);
|
||||||
|
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* e107 website system
|
||||||
* Date: 2/8/2019
|
*
|
||||||
* Time: 11:46 AM
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* PDO MySQL Handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Legacy Fix.
|
// Legacy Fix.
|
||||||
|
@@ -1290,8 +1290,7 @@ class e_db_mysql implements e_db
|
|||||||
{
|
{
|
||||||
$this->provide_mySQLaccess();
|
$this->provide_mySQLaccess();
|
||||||
e107::getSingleton('e107_traffic')->BumpWho('db Close', 1);
|
e107::getSingleton('e107_traffic')->BumpWho('db Close', 1);
|
||||||
$result = mysqli_close($this->mySQLaccess);
|
@mysqli_close($this->mySQLaccess);
|
||||||
if ($result === false) $this->dbError('dbClose');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2019 e107 Inc (e107.org)
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
@@ -20,6 +20,14 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
*/
|
*/
|
||||||
abstract protected function makeDb();
|
abstract protected function makeDb();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent creating too many connections to database server
|
||||||
|
*/
|
||||||
|
public function _after()
|
||||||
|
{
|
||||||
|
$this->db->close();
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadConfig()
|
protected function loadConfig()
|
||||||
{
|
{
|
||||||
/** @var Helper\DelayedDb $db */
|
/** @var Helper\DelayedDb $db */
|
||||||
@@ -47,9 +55,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testGetMode()
|
public function testGetMode()
|
||||||
{
|
{
|
||||||
$actual = $this->db->getMode();
|
$actual = $this->db->getMode();
|
||||||
@@ -1006,7 +1011,6 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
*/
|
*/
|
||||||
public function testSecondaryDatabaseInstance()
|
public function testSecondaryDatabaseInstance()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$xql = $this->makeDb();
|
$xql = $this->makeDb();
|
||||||
@@ -1128,8 +1132,7 @@ abstract class e_db_abstractTest extends \Codeception\Test\Unit
|
|||||||
$empty = $xql->isEmpty($table);
|
$empty = $xql->isEmpty($table);
|
||||||
$this->assertTrue($empty,"isEmpty() or truncate() failed");
|
$this->assertTrue($empty,"isEmpty() or truncate() failed");
|
||||||
|
|
||||||
|
$xql->close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2018 e107 Inc (e107.org)
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2018 e107 Inc (e107.org)
|
* Copyright (C) 2008-2020 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user