Skip to content

Commit

Permalink
Fix fields renaming
Browse files Browse the repository at this point in the history
fixes #605
  • Loading branch information
cedric-anne committed Dec 14, 2022
1 parent 1e47225 commit 91b1504
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 91b1504

Please sign in to comment.