Fix for travis and PHP 8.1 with PGSQL
This commit is contained in:
parent
46011509bc
commit
8f1ea59bc6
@ -51,9 +51,11 @@ addons:
|
||||
- php7.1-pgsql
|
||||
- php7.1-mysqli
|
||||
- php7.1-xml
|
||||
- php7.1-intl
|
||||
- php8.1-pgsql
|
||||
- php8.1-mysqli
|
||||
- php8.1-xml
|
||||
- php8.1-intl
|
||||
|
||||
env:
|
||||
global:
|
||||
|
||||
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php';
|
||||
*/
|
||||
abstract class DoliDB implements Database
|
||||
{
|
||||
/** @var bool|resource|SQLite3 Database handler */
|
||||
/** @var bool|resource|SQLite3|PgSql\connection Database handler */
|
||||
public $db;
|
||||
/** @var string Database type */
|
||||
public $type;
|
||||
|
||||
@ -1164,7 +1164,17 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
|
||||
function dol_clone($object, $native = 0)
|
||||
{
|
||||
if (empty($native)) {
|
||||
$tmpsavdb = null;
|
||||
if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) == 'PgSql\Connection') {
|
||||
$tmpsavdb = $object->db;
|
||||
unset($object->db); // Such property can not be serialized when PgSql/Connection
|
||||
}
|
||||
|
||||
$myclone = unserialize(serialize($object)); // serialize then unserialize is hack to be sure to have a new object for all fields
|
||||
|
||||
if ($tmpsavdb) {
|
||||
$object->db = $tmpsavdb;
|
||||
}
|
||||
} else {
|
||||
$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep the reference (refering to the same target/variable)
|
||||
}
|
||||
@ -3723,6 +3733,8 @@ function isValidMXRecord($domain)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// function idn_to_ascii or checkdnsrr does not exists
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4957,7 +4969,9 @@ function dol_print_error($db = '', $error = '', $errors = null)
|
||||
|
||||
// Return a http header with error code if possible
|
||||
if (!headers_sent()) {
|
||||
top_httphead();
|
||||
if (function_exists('top_httphead')) { // In CLI context, the method does not exists
|
||||
top_httphead();
|
||||
}
|
||||
http_response_code(500);
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ global $conf,$user,$langs,$db;
|
||||
//require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php';
|
||||
|
||||
if (! defined('NOREQUIREUSER')) {
|
||||
define('NOREQUIREUSER', '1');
|
||||
@ -166,6 +167,30 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolClone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDolClone()
|
||||
{
|
||||
$newproduct1 = new Product($this->savdb);
|
||||
|
||||
print __METHOD__." this->savdb has type ".(is_resource($this->savdb->db) ? get_resource_type($this->savdb->db) : (is_object($this->savdb->db) ? 'object' : 'unknown'))."\n";
|
||||
print __METHOD__." newproduct1->db->db has type ".(is_resource($newproduct1->db->db) ? get_resource_type($newproduct1->db->db) : (is_object($newproduct1->db->db) ? 'object' : 'unknown'))."\n";
|
||||
$this->assertEquals($this->savdb->connected, 1, 'Savdb is connected');
|
||||
$this->assertNotNull($newproduct1->db->db, 'newproduct1->db is not null');
|
||||
|
||||
$newproductcloned1 = dol_clone($newproduct1);
|
||||
|
||||
print __METHOD__." this->savdb has type ".(is_resource($this->savdb->db) ? get_resource_type($this->savdb->db) : (is_object($this->savdb->db) ? 'object' : 'unknown'))."\n";
|
||||
print __METHOD__." newproduct1->db->db has type ".(is_resource($newproduct1->db->db) ? get_resource_type($newproduct1->db->db) : (is_object($newproduct1->db->db) ? 'object' : 'unknown'))."\n";
|
||||
$this->assertEquals($this->savdb->connected, 1, 'Savdb is connected');
|
||||
$this->assertNotNull($newproduct1->db->db, 'newproduct1->db is not null');
|
||||
|
||||
//print __METHOD__." newproductcloned1->db must be null\n";
|
||||
//$this->assertNull($newproductcloned1->db, 'newproductcloned1->db is null');
|
||||
}
|
||||
|
||||
/**
|
||||
* testNum2Alpha
|
||||
|
||||
Loading…
Reference in New Issue
Block a user