CVS update: /cowiki/htdocs/

[email protected] 6 May 2005 20:21:38 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: dgorski 
Date: 2005/05/06 13:21:38

Modified:
   cowiki/htdocs/admin.php

Log:
 Catch exceptions thrown by the main() controller function

File Changes:

Directory: /cowiki/htdocs/
==========================

File [changed]: admin.php
Url: http://cowiki.tigris.org/source/browse/cowiki/htdocs/admin.php?r1=1.16&r2=1.17
Delta lines:  +57 -8
--------------------
--- admin.php	13 Mar 2005 03:51:20 -0000	1.16
+++ admin.php	6 May 2005 20:21:36 -0000	1.17
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: admin.php,v 1.16 2005/03/13 03:51:20 dgorski Exp $
+ * $Id: admin.php,v 1.17 2005/05/06 20:21:36 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.16 $
+ * @version     $Revision: 1.17 $
  *
  */
 
@@ -42,7 +42,7 @@
     //
     // The wizard itself is located in the 'setup/' folder.
 
-/* DISABLED UNTIL THE WIZARD WORKS
+/* DISABLED UNTIL THE SETUP INSTALLER WIZARD WORKS
     if (file_exists(realpath(dirname(__FILE__)) . '/install.pending')) {
         // FIX: scheme (https) and port (other than 80)
         $sScheme = 'http';
@@ -68,13 +68,53 @@
 
     // --------------------------------------------------------------------
 
+    // Start the main controller
+    try {
+
     // Include 'core.base.php'. This file resolves basic dependances
     // and takes care of initializations.
     include_once 'core.base.php';
 
+        // {{{ DEBUG }}}
+        Logger::info('Started processing.');
+
     // Start the main controller
     main();
 
+        // {{{ DEBUG }}}
+        Logger::info('Stopped processing - a clean run.');
+
+    } catch (GenericException $e) {
+        $e->printStackTrace();
+
+        // {{{ DEBUG }}}
+        Logger::info(
+            'Crashed with '.$e->getName().' "'.$e->getExceptionMessage().'"
+            in line '.$e->getLine()
+        );
+
+        exit;
+
+    } catch (Exception $e) {
+
+        // This should never should happen - do not throw only Exception,
+        // but a GenericException instead.
+        echo  'Build-in exception in '.$e->getFile().' in line '.$e->getLine();
+        echo  '<br />';
+        echo  '<pre>';
+        echo    $e->getTraceAsString();
+        echo  '</pre>';
+        echo  'This should never happen. Report it to the coWiki developers.';
+
+        // {{{ DEBUG }}}
+        Logger::info('Crashed with build-in exception in line '.$e->getLine());
+        Logger::info('THIS IS SERIOUS - Report it to the coWiki developers.');
+
+        exit;
+    }        
+
+    // --------------------------------------------------------------------
+
     /**
      * Main
      *
@@ -137,6 +177,15 @@
         // ----------------------------------------------------------------
 
         // Dispatch controller actions
+
+        // Call setup installer, script will terminate after this redirect
+        if ($sModule == 'setup') {
+            HttpResponse::getInstance()->redirectTo(
+                'setup/installer.php?ref=admin.php'
+            );
+        }
+
+        // ----------------------------------------------------------------
 
         // Webstructure
         if ($sModule == 'struct') {