From baa6abdb007f40736d12cdff2439de136eb7214a Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@netways.de>
Date: Wed, 8 Oct 2014 11:24:05 +0200
Subject: [PATCH] Relax schema check

Checking one table for its existence is more than enough. Creating a diff
implies conditional CREATE TABLE instructions and the like, what we want
to avoid.

refs #7163
---
 library/Icinga/Application/WebInstaller.php |  6 ++----
 library/Icinga/Application/WebSetup.php     | 10 +---------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/library/Icinga/Application/WebInstaller.php b/library/Icinga/Application/WebInstaller.php
index 54323f966..1e225f94e 100644
--- a/library/Icinga/Application/WebInstaller.php
+++ b/library/Icinga/Application/WebInstaller.php
@@ -272,8 +272,7 @@ class WebInstaller implements Installer
             ));
         }
 
-        $diff = array_diff(array('account', 'preference'), $db->listTables());
-        if (empty($diff)) {
+        if (array_search('account', $db->listTables()) !== false) {
             $this->log(t('Database schema already exists...'));
         } else {
             $this->log(t('Creating database schema...'));
@@ -337,8 +336,7 @@ class WebInstaller implements Installer
             ));
         }
 
-        $diff = array_diff(array('account', 'preference'), $db->listTables());
-        if (empty($diff)) {
+        if (array_search('account', $db->listTables()) !== false) {
             $this->log(t('Database schema already exists...'));
         } else {
             $this->log(t('Creating database schema...'));
diff --git a/library/Icinga/Application/WebSetup.php b/library/Icinga/Application/WebSetup.php
index 9f0fa04b6..84f732789 100644
--- a/library/Icinga/Application/WebSetup.php
+++ b/library/Icinga/Application/WebSetup.php
@@ -29,13 +29,6 @@ use Icinga\Application\Platform;
  */
 class WebSetup extends Wizard implements SetupWizard
 {
-    /**
-     * The database tables required by Icinga Web 2
-     *
-     * @var array
-     */
-    protected $databaseTables = array('account', 'preference');
-
     /**
      * The privileges required by Icinga Web 2 to setup the database
      *
@@ -148,8 +141,7 @@ class WebSetup extends Wizard implements SetupWizard
 
                 try {
                     $db->connectToDb();
-                    $diff = array_diff($this->databaseTables, $db->listTables());
-                    if (false === empty($diff)) {
+                    if (array_search('account', $db->listTables()) === false) {
                         $skip = $db->checkPrivileges($this->databaseSetupPrivileges);
                     } else {
                         $skip = true;