From 4ffe7bb490322b44c46cac6056b8b2a79f577fe1 Mon Sep 17 00:00:00 2001
From: Adam Vessey <adam@discoverygarden.ca>
Date: Tue, 20 Sep 2022 11:13:59 -0300
Subject: [PATCH] Avoid referencing non-existent table.

---
 islandora_fits.install | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/islandora_fits.install b/islandora_fits.install
index 7ef59491..9e0da0b7 100644
--- a/islandora_fits.install
+++ b/islandora_fits.install
@@ -64,6 +64,13 @@ function islandora_fits_requirements($phase) : array {
  * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
  */
 function _islandora_fits_term_exists() {
+  $table_exists = \Drupal::database()->schema()->tableExists('taxonomy_term__field_external_uri');
+  if (!$table_exists) {
+    // XXX: If the table does not exist, then avoid attempting to make a query
+    // making use of the non-existent table.
+    return FALSE;
+  }
+
   $query = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->getQuery()
     ->condition('vid', 'islandora_media_use')
     ->condition('field_external_uri.uri', 'https://projects.iq.harvard.edu/fits')