Revision: 1136
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1136&view=rev
Author:   jberanek
Date:     2009-06-28 19:14:56 +0000 (Sun, 28 Jun 2009)

Log Message:
-----------
* Improved error handing in DB upgrade system. If any errors are
 encountered, the upgrade process is now immediately stopped.

* Fixed version 5 and 6 schema upgrades for PostgreSQL, it didn't like
 being sent SQL with just a comment.

Modified Paths:
--------------
    mrbs/trunk/web/dbsys.inc
    mrbs/trunk/web/upgrade/5/pgsql.sql
    mrbs/trunk/web/upgrade/6/pgsql.sql
    mrbs/trunk/web/upgrade.inc

Modified: mrbs/trunk/web/dbsys.inc
===================================================================
--- mrbs/trunk/web/dbsys.inc    2009-06-26 14:46:27 UTC (rev 1135)
+++ mrbs/trunk/web/dbsys.inc    2009-06-28 19:14:56 UTC (rev 1136)
@@ -662,21 +662,26 @@
     }
   }
 
+  $ok = TRUE;
+
   // Do any MRBS upgrades first
   if ($current_db_schema_version < $db_schema_version)
   {
-    upgrade_database(FALSE, $current_db_schema_version, $db_schema_version);
+    $ok = upgrade_database(FALSE, $current_db_schema_version, 
$db_schema_version);
   }
   // Then any local upgrades
-  if ($current_local_db_schema_version < $local_db_schema_version)
+  if ($ok && $current_local_db_schema_version < $local_db_schema_version)
   {
-    upgrade_database(TRUE, $current_local_db_schema_version, 
$local_db_schema_version);
+    $ok = upgrade_database(TRUE, $current_local_db_schema_version, 
$local_db_schema_version);
   }
   
   // close the database connection that has admin rights
   sql_close($admin_handle);
 
-  echo "<p>" . get_vocab("upgrade_completed") . "</p>\n";
+  if ($ok)
+  {
+    echo "<p>" . get_vocab("upgrade_completed") . "</p>\n";
+  }
   echo "<a href=\"./\">" . get_vocab("returncal") . "</a>.";
 
   print_footer(TRUE);

Modified: mrbs/trunk/web/upgrade/5/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/5/pgsql.sql  2009-06-26 14:46:27 UTC (rev 1135)
+++ mrbs/trunk/web/upgrade/5/pgsql.sql  2009-06-28 19:14:56 UTC (rev 1136)
@@ -1 +0,0 @@
--- $Id$

Modified: mrbs/trunk/web/upgrade/6/pgsql.sql
===================================================================
--- mrbs/trunk/web/upgrade/6/pgsql.sql  2009-06-26 14:46:27 UTC (rev 1135)
+++ mrbs/trunk/web/upgrade/6/pgsql.sql  2009-06-28 19:14:56 UTC (rev 1136)
@@ -1 +0,0 @@
--- $Id$

Modified: mrbs/trunk/web/upgrade.inc
===================================================================
--- mrbs/trunk/web/upgrade.inc  2009-06-26 14:46:27 UTC (rev 1135)
+++ mrbs/trunk/web/upgrade.inc  2009-06-28 19:14:56 UTC (rev 1136)
@@ -3,7 +3,9 @@
 // $Id$
 
 
+// Upgrade between database schema versions.
 //
+// Returns FALSE on error, TRUE is successful
 function upgrade_database($local, $from, $to)
 {
   // $local is a boolean specifying whether the upgrades are global MRBS ones 
($local == FALSE)
@@ -39,7 +41,7 @@
     {
       // No need to localise, should never happen!
       print "Fatal error: Failed to open '$filename' for reading.\n";
-      return;
+      return FALSE;
     }
     $sql = fread($handle, filesize($filename));
     fclose($handle);
@@ -61,6 +63,7 @@
 </pre> and got error:<pre>
 ".sql_error()."
 </pre>\n";
+          return FALSE;
         }
       }
     }
@@ -75,6 +78,7 @@
       {
         // No need to localise, should never happen
         print "<span class=\"error\">Failed to update database version 
variable.</span>";
+        return FALSE;
       }
     }
     print "</p>\n";
@@ -85,6 +89,7 @@
       include($php_filename);
     }
   }
+  return TRUE;
 }
 
 ?>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to