Skip to content
Snippets Groups Projects
Unverified Commit 91dc8831 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3040746 by Berdir, amateescu, Sam152: Update functions that set owner...

Issue #3040746 by Berdir, amateescu, Sam152: Update functions that set owner entity key updates can fail on existing data with NULL values
parent f4420c5f
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -5,6 +5,7 @@
* Install, uninstall and update hooks for Media module.
*/
use Drupal\Core\Entity\Sql\SqlEntityStorageInterface;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Url;
......@@ -180,6 +181,24 @@ function media_update_8600() {
function media_update_8700() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$entity_type = $definition_update_manager->getEntityType('media');
$database = \Drupal::database();
if (\Drupal::entityTypeManager()->getStorage('media') instanceof SqlEntityStorageInterface) {
if ($database->schema()->tableExists($entity_type->getDataTable())) {
$database->update($entity_type->getDataTable())
->fields(['uid' => 0])
->isNull('uid')
->execute();
}
if ($database->schema()->tableExists($entity_type->getRevisionDataTable())) {
$database->update($entity_type->getRevisionDataTable())
->fields(['uid' => 0])
->isNull('uid')
->execute();
}
}
$keys = $entity_type->getKeys();
$keys['owner'] = 'uid';
$entity_type->set('entity_keys', $keys);
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment