File: 03-dba-open-existing

package info (click to toggle)
phpwiki 1.3.12p3-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 16,956 kB
  • ctags: 21,608
  • sloc: php: 82,335; xml: 3,840; sh: 1,522; sql: 1,198; perl: 625; makefile: 562; awk: 28
file content (29 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/sh /usr/share/dpatch/dpatch-run
## dba-open-existing by  <debian@mattb.net.nz>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix a bug in BDB 4.1 when the dbfile already exists

@DPATCH@

--- phpwiki-1.3.12p3.orig/lib/WikiDB/backend/dba.php
+++ phpwiki-1.3.12p3/lib/WikiDB/backend/dba.php
@@ -18,7 +18,17 @@
         // FIXME: error checking.
         $db = new DbaDatabase($dbfile, false, $dba_handler);
         $db->set_timeout($timeout);
-        if (!$db->open('c')) {
+	
+	// Workaround for BDB 4.1 bugs
+	if (file_exists($dbfile))
+	{
+		$mode = 'w';
+	}
+	else
+	{
+		$mode = 'c';
+	}
+        if (!$db->open($mode)) {
             trigger_error(sprintf(_("%s: Can't open dba database"), $dbfile), E_USER_ERROR);
             global $request;
             $request->finish(fmt("%s: Can't open dba database", $dbfile));