From 91b15046abfdbd02c2db29a905e26a08407425ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Wed, 14 Dec 2022 16:38:02 +0100 Subject: [PATCH] Fix fields renaming fixes #605 --- inc/toolbox.class.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/inc/toolbox.class.php b/inc/toolbox.class.php index 4cfc432b..53fbdf14 100644 --- a/inc/toolbox.class.php +++ b/inc/toolbox.class.php @@ -100,20 +100,22 @@ public function fixFieldsNames(Migration $migration, $condition) { global $DB; - $bad_named_fields = $DB->request( + $bad_named_fields = []; + $fields = $DB->request( [ 'FROM' => PluginFieldsField::getTable(), - 'WHERE' => [ - 'name' => [ - 'REGEXP', - $DB->escape('[0-9]+') - ], - $condition, - ], + 'WHERE' => $condition, ] ); + foreach ($fields as $field) { + $field_copy = $field; + unset($field_copy['name']); + if ($field['name'] !== (new PluginFieldsField())->prepareName($field_copy)) { + $bad_named_fields[] = $field; + } + } - if ($bad_named_fields->count() === 0) { + if (count($bad_named_fields) === 0) { return; }