You are here

function media_entity_update_8002 in Media entity 8

Same name and namespace in other branches
  1. 8.2 media_entity.install \media_entity_update_8002()

Ensure media entity status value (defaulting to 1).

File

./media_entity.install, line 87
Install, uninstall and update hooks for Media entity module.

Code

function media_entity_update_8002() {

  // Ensure status values in 'media_field_data' table.
  if (\Drupal::database()
    ->schema()
    ->tableExists('media_field_data')) {
    \Drupal::database()
      ->update('media_field_data')
      ->fields([
      'status' => 1,
    ])
      ->condition('status', NULL, 'IS NULL')
      ->execute();
  }

  // Ensure status values in 'media_field_revision' table.
  if (\Drupal::database()
    ->schema()
    ->tableExists('media_field_revision')) {
    \Drupal::database()
      ->update('media_field_revision')
      ->fields([
      'status' => 1,
    ])
      ->condition('status', NULL, 'IS NULL')
      ->execute();
  }

  // Flush all caches.
  drupal_flush_all_caches();
}