Set HTTP status code 500 if database connection fails. Should avoid pages
authorJeremy Laine <jeremy.laine@m4x.org>
Thu, 1 Jun 2006 06:42:55 +0000 (06:42 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Thu, 1 Jun 2006 06:42:55 +0000 (06:42 +0000)
getting indexed by search engines with an error in case of DB failure.

include/diogenes/ChangeLog
include/diogenes/diogenes.core.globals.inc.php

index 42d3d55..3d79608 100644 (file)
@@ -1,3 +1,6 @@
+libdiogenes 0.9.19
+ * improved - (globals) set HTTP status code 500 if database connection fails
+
 libdiogenes 0.9.18
  * improved - (mime) recognise MIME type of OMA DRM content
  * added - (mime) add function to retrieve a multipart content's boundary
index 61132b1..b940478 100644 (file)
@@ -59,7 +59,11 @@ class DiogenesCoreGlobals {
   {
     $db = new DiogenesDatabase($this->dbdb, $this->dbhost, $this->dbuser, $this->dbpwd);
     if (!$db->connect_id)
+    {
+      if (!headers_sent())
+        header("HTTP/1.0 500 Internal Server Error");
       die("Could not connect to database (".mysql_error().")");
+    }
     $this->db = $db;
   }