Skip to content

Commit

Permalink
Remove useless mysqlnd driver compatibility check
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Dec 10, 2024
1 parent 4d57bf0 commit 78aa2b8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@
$ignoreErrors[] = [
'message' => '#^Instanceof between DBmysql and DBmysql will always evaluate to true\\.$#',
'identifier' => 'instanceof.alwaysTrue',
'count' => 5,
'count' => 4,
'path' => __DIR__ . '/src/DBConnection.php',
];
$ignoreErrors[] = [
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ The present file will list all changes made to the project; according to the
- `Contract::showShort()`
- `DbUtils::closeDBConnections()`
- `DbUtils::regenerateTreeCompleteName()`
- `DBmysql::error` property.
- `Document::getImage()`
- `Document::showUploadedFilesDropdown()`
- `Document::uploadDocument()`
Expand Down
16 changes: 1 addition & 15 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,6 @@
}


//test la connection a la base de donn???.
function test_connect()
{
/** @var \DBmysql $DB */
global $DB;

if ($DB->error == 0) {
return true;
}
return false;
}



//update database
function doUpdateDb()
{
Expand Down Expand Up @@ -224,7 +210,7 @@ function showSecurityKeyCheckForm()
}
} else {
// Step 2
if (test_connect()) {
if ($DB->connected) {
echo "<h3>" . __s('Database connection successful') . "</h3>";
echo "<p class='text-center'>";
$result = Config::displayCheckDbEngine(true);
Expand Down
14 changes: 2 additions & 12 deletions src/DBConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,18 +654,8 @@ public static function displayMySQLError()
/** @var \DBmysql $DB */
global $DB;

$error = $DB instanceof DBmysql ? $DB->error : 1;
switch ($error) {
case 2:
$en_msg = "Use of mysqlnd driver is required for exchanges with the MySQL server.";
$fr_msg = "L'utilisation du driver mysqlnd est requise pour les échanges avec le serveur MySQL.";
break;
case 1:
default:
$fr_msg = "Le serveur Mysql est inaccessible. Vérifiez votre configuration.";
$en_msg = "A link to the SQL server could not be established. Please check your configuration.";
break;
}
$fr_msg = "Le serveur Mysql est inaccessible. Vérifiez votre configuration.";
$en_msg = "A link to the SQL server could not be established. Please check your configuration.";

if (!isCommandLine()) {
Html::nullHeader("Mysql Error", '');
Expand Down
11 changes: 1 addition & 10 deletions src/DBmysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class DBmysql
*/
protected $dbh;

//! Database Error
public $error = 0;

// Slave management
public $slave = false;
private $in_transaction;
Expand Down Expand Up @@ -269,13 +266,7 @@ public function connect($choice = null)
$this->dbh->real_connect($hostport[0], $this->dbuser, rawurldecode($this->dbpassword), $this->dbdefault, ini_get('mysqli.default_port'), $hostport[1]);
}

if ($this->dbh->connect_error) {
$this->connected = false;
$this->error = 1;
} else if (!defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
$this->connected = false;
$this->error = 2;
} else {
if (!$this->dbh->connect_error) {
$this->setConnectionCharset();

// force mysqlnd to return int and float types correctly (not as strings)
Expand Down

0 comments on commit 78aa2b8

Please sign in to comment.