From 214377b17736c51082098ce0aba924aeeeb41438 Mon Sep 17 00:00:00 2001 From: rich Date: Tue, 1 Aug 2006 14:50:47 +0000 Subject: [PATCH] Fix bug which occurs when creating a new page. We weren't catching the Failure "hd" exception thrown in some circumstances. --- scripts/edit.ml | 13 +++++++------ scripts/file.ml | 4 ++-- scripts/image.ml | 4 ++-- scripts/lib/cocanwiki_diff.ml | 4 ++-- scripts/page.ml | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/edit.ml b/scripts/edit.ml index 53ed01d..6ddbfc1 100644 --- a/scripts/edit.ml +++ b/scripts/edit.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: edit.ml,v 1.32 2006/07/31 09:49:42 rich Exp $ + * $Id: edit.ml,v 1.33 2006/08/01 14:50:47 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -384,15 +384,14 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = model_to_template !model template in - (* Try to save the page. Returns a boolean indicating if the - * page was saved successfully. + (* Try to save the page. Only returns if there were errors in + * the model. *) let try_save () = let model = build_internal_model () in let no_errors = [] = check_for_errors model in if no_errors then ( (* No errors, so we can save the page ... *) - let url, pageid = try save_page r dbh hostid ~user model @@ -423,8 +422,10 @@ let run r (q : cgi) dbh hostid {hostname = hostname} user = (* Fill out the conflict template. *) template_conflict#set "other_diff" other_diff; template_conflict#set "our_diff" our_diff; - template_conflict#set "old_version" (Int32.to_string old_version); - template_conflict#set "new_version" (Int32.to_string new_version); + template_conflict#set "old_version" + (Int32.to_string old_version); + template_conflict#set "new_version" + (Int32.to_string new_version); template_conflict#set "url" url; q#template template_conflict; diff --git a/scripts/file.ml b/scripts/file.ml index ae4f9ed..252e5fb 100644 --- a/scripts/file.ml +++ b/scripts/file.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: file.ml,v 1.15 2006/03/27 19:10:29 rich Exp $ + * $Id: file.ml,v 1.16 2006/08/01 14:50:47 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ let run r (q : cgi) dbh hostid {hostname = hostname} _ = and id = $version" ) with - Not_found | ExtList.List.Empty_list -> + Not_found | ExtList.List.Empty_list | Failure "hd" -> raise (HttpError cHTTP_NOT_FOUND) in let deleted = Option.get deleted in diff --git a/scripts/image.ml b/scripts/image.ml index 966c35b..36d1519 100644 --- a/scripts/image.ml +++ b/scripts/image.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: image.ml,v 1.16 2006/03/27 19:10:29 rich Exp $ + * $Id: image.ml,v 1.17 2006/08/01 14:50:47 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,7 +69,7 @@ let run r (q : cgi) dbh hostid {hostname = hostname} _ = Option.get data, Option.get mime_type, deleted ) with - Not_found | ExtList.List.Empty_list -> + Not_found | ExtList.List.Empty_list | Failure "hd" -> raise (HttpError cHTTP_NOT_FOUND) in let deleted = Option.get deleted in diff --git a/scripts/lib/cocanwiki_diff.ml b/scripts/lib/cocanwiki_diff.ml index 004960d..3b47d3e 100644 --- a/scripts/lib/cocanwiki_diff.ml +++ b/scripts/lib/cocanwiki_diff.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: cocanwiki_diff.ml,v 1.4 2006/03/27 16:43:44 rich Exp $ + * $Id: cocanwiki_diff.ml,v 1.5 2006/08/01 14:50:47 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,7 +121,7 @@ let get_diff dbh hostid page ?old_version ~version ()= order by 1 desc limit 1" ) with - Not_found | ExtList.List.Empty_list -> 0l in + Not_found | ExtList.List.Empty_list | Failure "hd" -> 0l in (* Get the two versions. *) let new_page = get_version_for_diff dbh version in diff --git a/scripts/page.ml b/scripts/page.ml index dcc0f5a..4a3b020 100644 --- a/scripts/page.ml +++ b/scripts/page.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: page.ml,v 1.48 2006/07/27 16:46:55 rich Exp $ + * $Id: page.ml,v 1.49 2006/08/01 14:50:47 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -176,7 +176,7 @@ let run r (q : cgi) dbh hostid ) in Some (List.assoc name !extensions) with - Not_found | ExtList.List.Empty_list -> None + Not_found | ExtList.List.Empty_list | Failure "hd" -> None in (* This code generates ordinary pages. *) -- 1.8.3.1