Last active
July 4, 2017 09:58
-
-
Save IT-Cru/c976c908ec2b29fa8ceb54bcd4dc4b05 to your computer and use it in GitHub Desktop.
Add table exists check for DCX Integration module 8.x-2.0-beta2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/dcx_migration/dcx_migration.module b/modules/dcx_migration/dcx_migration.module | |
index c39fb56..d97048a 100644 | |
--- a/modules/dcx_migration/dcx_migration.module | |
+++ b/modules/dcx_migration/dcx_migration.module | |
@@ -4,18 +4,19 @@ | |
* @file | |
*/ | |
-/** | |
- * Implements hook_ENTITY_TYPE_delete(). | |
- */use Drupal\Core\Database\Database; | |
+use Drupal\Core\Database\Database; | |
use Drupal\Core\Entity\EntityInterface; | |
/** | |
- * | |
+ * Implements hook_ENTITY_TYPE_delete(). | |
*/ | |
function dcx_migration_media_delete(EntityInterface $entity) { | |
- // Remove the migrate map entry for this entity to allow remigration. | |
- $db = Database::getConnection('default'); | |
- $query = $db->delete('migrate_map_dcx_migration') | |
- ->condition('destid1', $entity->id()) | |
- ->execute(); | |
+ // Remove the migrate map entry for this entity to allow remigration if the | |
+ // table exists. | |
+ if (Database::getConnection()->schema()->tableExists('migrate_map_dcx_migration')) { | |
+ $db = Database::getConnection('default'); | |
+ $db->delete('migrate_map_dcx_migration') | |
+ ->condition('destid1', $entity->id()) | |
+ ->execute(); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment