Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix migration of bad named items #505

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,13 @@ static function install(Migration $migration, $version) {
}

// Fix containers names that were generated prior to Fields 1.9.2.
$glpi_version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
$bad_named_containers = $DB->request(
[
'FROM' => self::getTable(),
'WHERE' => [
'name' => [
'REGEXP',
// Regex will be escaped by PDO in GLPI 10+, but has to be escaped for GLPI < 10
version_compare($glpi_version, '10.0', '>=') ? '\d+' : $DB->escape('\d+')
$DB->escape('\d+')
],
],
]
Expand Down
4 changes: 1 addition & 3 deletions inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,13 @@ private function replaceIntByLetters($str) {
public function fixFieldsNames(Migration $migration, $condition) {
global $DB;

$glpi_version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
$bad_named_fields = $DB->request(
[
'FROM' => PluginFieldsField::getTable(),
'WHERE' => [
'name' => [
'REGEXP',
// Regex will be escaped by PDO in GLPI 10+, but has to be escaped for GLPI < 10
version_compare($glpi_version, '10.0', '>=') ? '[0-9]+' : $DB->escape('[0-9]+')
$DB->escape('[0-9]+')
],
$condition,
],
Expand Down