DBAL: _die() now detects installation environment and, if present, calls installer UI library for error display chrome
authorDan
Sun, 19 Apr 2009 18:42:21 -0400
changeset 940 645727469415
parent 939 32a43ae3649b
child 941 9be6dba92adf
DBAL: _die() now detects installation environment and, if present, calls installer UI library for error display chrome
includes/dbal.php
--- a/includes/dbal.php	Sun Apr 19 18:35:35 2009 -0400
+++ b/includes/dbal.php	Sun Apr 19 18:42:21 2009 -0400
@@ -83,10 +83,14 @@
   }
   
   function _die($t = '') {
-    if(defined('ENANO_HEADERS_SENT')) {
+    if ( defined('ENANO_HEADERS_SENT') )
+    {
       ob_clean();
     }
-    header('HTTP/1.1 500 Internal Server Error');
+    
+    if ( !headers_sent() )
+      header('HTTP/1.1 500 Internal Server Error');
+    
     $bt = $this->latest_query; // $this->sql_backtrace();
     $e = htmlspecialchars(mysql_error());
     if($e=='') $e='<none>';
@@ -99,6 +103,15 @@
                       Error returned by MySQL extension: ' . $e . '<br />
                       Most recent SQL query:</p>
                       <pre>'.$bt.'</pre>';
+    if ( defined('IN_ENANO_INSTALL') && is_object(@$GLOBALS['ui']) )
+    {
+      global $ui;
+      echo '<h2>Database error!</h2>';
+      echo $internal_text;
+      $ui->show_footer();
+      
+      exit;
+    }
     if(defined('ENANO_CONFIG_FETCHED')) die_semicritical('Database error', $internal_text);
     else                                   grinding_halt('Database error', $internal_text);
     exit;