Changeset:
        3cf9451777a6
        
https://sourceforge.net/p/mrbs/hg-code/ci/3cf9451777a662ed8e6b89fc4ee881b4d2f583e0
Author:
        Campbell Morrison <[email protected]>
Date:
        Mon Sep 26 17:19:05 2016 +0100
Log message:

Merged with latest changes from default branch

diffstat:

 web/dbsys.inc              |   4 ++++
 web/edit_entry_handler.php |  20 +++++++++++++++++++-
 web/lib/MRBS/DB.php        |   1 +
 3 files changed, 24 insertions(+), 1 deletions(-)

diffs (63 lines):

diff -r 95fcee4c20b8 -r 3cf9451777a6 web/dbsys.inc
--- a/web/dbsys.inc     Mon Sep 26 13:50:26 2016 +0100
+++ b/web/dbsys.inc     Mon Sep 26 17:19:05 2016 +0100
@@ -86,6 +86,10 @@
 {
   return DB::default_db()->commit();
 }
+function sql_rollback()
+{
+  return DB::default_db()->rollback();
+}
 function sql_mutex_lock($name)
 {
   return DB::default_db()->mutex_lock($name);
diff -r 95fcee4c20b8 -r 3cf9451777a6 web/edit_entry_handler.php
--- a/web/edit_entry_handler.php        Mon Sep 26 13:50:26 2016 +0100
+++ b/web/edit_entry_handler.php        Mon Sep 26 17:19:05 2016 +0100
@@ -699,15 +699,33 @@
 $just_check = $ajax && function_exists('json_encode') && !$commit;
 $this_id = (isset($id)) ? $id : NULL;
 $send_mail = ($no_mail) ? FALSE : $need_to_send_mail;
+
+// Wrap the editing process in a transaction, because if deleting the old 
booking should fail for
+// some reason then we'll potentially be left with two overlapping bookings.  
A deletion could fail
+// if, for example, the database user hasn't been granted DELETE rights.
+sql_begin();
+$transaction_ok = true;
+
 $result = mrbsMakeBookings($bookings, $this_id, $just_check, $skip, 
$original_room_id, $send_mail, $edit_type);
 
 // If we weren't just checking and this was a succesful booking and
 // we were editing an existing booking, then delete the old booking
 if (!$just_check && $result['valid_booking'] && isset($id))
 {
-  mrbsDelEntry($user, $id, ($edit_type == "series"), 1);
+  $transaction_ok = mrbsDelEntry($user, $id, ($edit_type == "series"), 1);
 }
 
+if ($transaction_ok)
+{
+  sql_commit();
+}
+else
+{
+  sql_rollback();
+  trigger_error('Edit failed.', E_USER_WARNING);
+}
+
+
 // If this is an Ajax request, output the result and finish
 if ($ajax && function_exists('json_encode'))
 {
diff -r 95fcee4c20b8 -r 3cf9451777a6 web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php       Mon Sep 26 13:50:26 2016 +0100
+++ b/web/lib/MRBS/DB.php       Mon Sep 26 17:19:05 2016 +0100
@@ -109,6 +109,7 @@
     }
     catch (PDOException $e)
     {
+      trigger_error($e->getMessage(), E_USER_WARNING);
       return $ret;
     }
   

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

Reply via email to