Skip to content

Commit 95c0aed

Browse files
committed
Fix migration tests
I had to make current_query protected, I did not find another way
1 parent 0052f9e commit 95c0aed

3 files changed

Lines changed: 272 additions & 84 deletions

File tree

src/DBmysql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class DBmysql
200200

201201
private bool $cache_disabled = false;
202202

203-
private string $current_query;
203+
protected string $current_query;
204204

205205
private DBmysqlIterator $iterator;
206206

@@ -478,7 +478,7 @@ public function prepare($query)
478478
}
479479

480480
/**
481-
* Give result from a sql result
481+
* Give result from a SQL result
482482
*
483483
* @param mysqli_result $result MySQL result handler
484484
* @param int $i Row offset to give

src/Migration.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use Glpi\DBAL\Prepared;
3737
use Glpi\DBAL\QueryExpression;
3838
use Glpi\DBAL\QueryFunction;
39+
use Glpi\Exception\Database\StatementException;
3940
use Glpi\Message\MessageType;
4041
use Glpi\Progress\AbstractProgressIndicator;
4142

@@ -1101,14 +1102,20 @@ private function storeConfig()
11011102
}
11021103
if (count($config)) {
11031104
foreach ($config as $name => $value) {
1104-
$this->db->insert(
1105-
'glpi_configs',
1106-
[
1107-
'context' => $context,
1108-
'name' => $name,
1109-
'value' => $value,
1110-
]
1111-
);
1105+
try {
1106+
$this->db->insert(
1107+
'glpi_configs',
1108+
[
1109+
'context' => $context,
1110+
'name' => $name,
1111+
'value' => $value,
1112+
]
1113+
);
1114+
} catch (StatementException $e) {
1115+
if (!str_contains($e->getMessage(), 'Duplicate entry')) {
1116+
throw $e;
1117+
}
1118+
}
11121119
}
11131120
$this->addDebugMessage(sprintf(
11141121
__('Configuration values added for %1$s (%2$s).'),

0 commit comments

Comments
 (0)