Skip to content
Snippets Groups Projects
Commit 60fb9536 authored by Noah Siegrist's avatar Noah Siegrist Committed by Jonathan Sacksick
Browse files

Issue #3488115 by siegrist, bobburns, jsacksick, czigor: SQL error

parent b85e8c5e
Branches
No related tags found
1 merge request!412Add update hook to fix outdated classreference.
Pipeline #496994 failed
......@@ -130,3 +130,37 @@ function commerce_update_8203() {
);
\Drupal::service('commerce.inbox_message_storage')->save($inbox_message);
}
/**
* Remove \Drupal\commerce\BundleFieldDefinition from field storage definitions.
*/
function commerce_update_8204() {
$old_string = 'O:37:"Drupal\\commerce\\BundleFieldDefinition":5:';
$new_string = 'O:35:"Drupal\\entity\\BundleFieldDefinition":5:';
$database = \Drupal::database();
$query = $database->select('key_value', 'kv')
->fields('kv', ['name', 'value'])
->condition('collection', 'entity.definitions.installed')
->condition('name', '%.field_storage_definitions', 'LIKE');
$results = $query->execute();
$updated_count = 0;
foreach ($results as $row) {
$new_value = str_replace($old_string, $new_string, $row->value);
if ($new_value !== $row->value) {
$database->update('key_value')
->fields(['value' => $new_value])
->condition('collection', 'entity.definitions.installed')
->condition('name', $row->name)
->execute();
$updated_count++;
}
}
\Drupal::logger('commerce')->notice('Updated @count records in key_value table.', ['@count' => $updated_count]);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment