CVS update: /cowiki/htdocs/setup/class/task/

[email protected] 12 May 2005 17:08:04 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/05/12 10:08:04

Modified:
   cowiki/htdocs/setup/class/task/class.TaskDocumentStorageConnector.php

Log:
 Fixes and check for availability of InnoDB

File Changes:

Directory: /cowiki/htdocs/setup/class/task/
===========================================

File [changed]: class.TaskDocumentStorageConnector.php
Url: http://cowiki.tigris.org/source/browse/cowiki/htdocs/setup/class/task/class.TaskDocumentStorageConnector.php?r1=1.4&r2=1.5
Delta lines:  +38 -9
--------------------
--- class.TaskDocumentStorageConnector.php	8 May 2005 01:01:37 -0000	1.4
+++ class.TaskDocumentStorageConnector.php	12 May 2005 17:08:02 -0000	1.5
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.TaskDocumentStorageConnector.php,v 1.4 2005/05/08 01:01:37 dgorski Exp $
+ * $Id: class.TaskDocumentStorageConnector.php,v 1.5 2005/05/12 17:08:02 dgorski Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.4 $
+ * @version     $Revision: 1.5 $
  *
  */
 
@@ -268,12 +268,12 @@
     private function checkDBConnection() {
 
         try {
-            $sResource = $this->State->mustCreateNewDocumentDatabase()
+            $sResource = $this->State->shallCreateNewDocumentDatabase()
                             ? $this->State->getDocumentStorageRootDSN()
                             : $this->State->getDocumentStorageDSN();
 
             $Storage = StorageFactory::getInstance()
-                          ->createDocumentStorage($sResource);
+                          ->create(new UriInfo($sResource));
 
         // Do we have basically the capability to access this database?
         } catch (StorageApiException $sae) {
@@ -284,15 +284,29 @@
 
         } catch (StorageConnectionFailureException $scfe) {
             return $this->addError($scfe->getExceptionMessage());
+        }
+
+        // ---
+
+        // If we should use an already existing database, select it
+        if (!$this->State->shallCreateNewDocumentDatabase()) {
+            try {
+                $Storage->useDatabase($this->State->getDocDatabaseName());
 
         } catch (StorageDatabaseSelectionException $sdse) {
-            if (!$this->State->mustCreateNewDocumentDatabase()) {
-                return $this->addError($sdse->getExceptionMessage());
+                return $this->addError(
+                    'You have chosen to use an existing database
+                    \''.$this->State->getDocDatabaseName().'\', but it
+                    isn\'t there - or is not accessible with the given
+                    connector user.'
+                );
             }
         }
         
         // ----------------------------------------------------------------
 
+        // Check the versions of the chosen storage layers
+
         // Remove alpha chars from version string and get storage name
         $sVer = preg_replace('#[^0-9.]#', '', $Storage->getStorageVersion());
         $sName = $Storage->getStorageName();
@@ -332,11 +346,26 @@
             );
         }
 
+        // Check if we have InnoDB (for MySQL only of course)
+        if (substr(strtolower($sName), 0, 5) == 'mysql') {
+            $aData = $Storage->fetchRowAndFreeResult(
+                $Storage->query('SHOW VARIABLES LIKE "HAVE_INNODB"')
+            );
+            
+            if (!isset($aData[1]) || strtolower($aData[1]) != 'yes') {
+                return $this->addError(
+                    'The MySQL database you have chosen does not support
+                     the InnoDB storage layer facility. Update or
+                     reconfigure the MySQL database.'
+                );
+            }
+        }
+        
         // ----------------------------------------------------------------
 
         // If we have to create a new database connector user, do not care
         // about the existing one.
-        if ($this->State->mustCreateNewDocumentDatabase()) {
+        if ($this->State->shallCreateNewDocumentDatabase()) {
             return true;
         }