]> git.mjollnir.org Git - s9y.git/commitdiff
* Patch #1697590: Proper directory name of SQLite DB-error messages,
authorgarvinhicking <garvinhicking>
Tue, 10 Apr 2007 13:23:34 +0000 (13:23 +0000)
committergarvinhicking <garvinhicking>
Tue, 10 Apr 2007 13:23:34 +0000 (13:23 +0000)
      thanks to Thijs Kinkhorst

docs/NEWS
include/db/sqlite.inc.php

index 33ab2183de8a9b466402439424b79bf9c690d8b1..ee0cd8fea5b20c437b29391635de6f55addf801f 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.2 ()
 ------------------------------------------------------------------------
 
+    * Patch #1697590: Proper directory name of SQLite DB-error messages,
+      thanks to Thijs Kinkhorst
+
     * Enabled setting cache-control headers by default.
     
     * Fix wrong next/previous page links when using wrapper.php indexFile
index ab043390628c7eddd8b6d4a6f7d6598126237cd6..827ca58224efa8f5a8388d08a8f2dd4837a98f3c 100644 (file)
@@ -56,6 +56,9 @@ function serendipity_db_connect()
     return $serendipity['dbConn'];
 }
 
+function serendipity_db_reconnect() {
+}
+
 /**
  * Returns a escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
  *
@@ -173,11 +176,11 @@ function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') {
     if (!is_array($search_ids)) {
         return false;
     }
-    
+
     foreach($search_ids AS $id) {
         $sql[] = $col . ' = ' . $id;
     }
-    
+
     $cond = '(' . implode($type, $sql) . ')';
     return $cond;
 }
@@ -221,7 +224,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
         fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE QUERY: ' . $sql . "\n\n");
         fclose($fp);
     }
-    
+
     if ($reportErr && !$expectError) {
         $res = sqlite_query($sql, $serendipity['dbConn']);
     } else {
@@ -257,9 +260,13 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
         $rows = array();
 
         while (($row = serendipity_db_sqlite_fetch_array($res, $type_map[$result_type]))) {
-            if (!empty($assocKey) && !empty($assocVal)) {
+            if (!empty($assocKey)) {
                 // You can fetch a key-associated array via the two function parameters assocKey and assocVal
-                $rows[$row[$assocKey]] = $row[$assocVal];
+                if (empty($assocVal)) {
+                    $rows[$row[$assocKey]] = $row;
+                } else {
+                    $rows[$row[$assocKey]] = $row[$assocVal];
+                }
             } else {
                 $rows[] = $row;
             }
@@ -298,13 +305,20 @@ function serendipity_db_probe($hash, &$errs)
         return false;
     }
 
-    $serendipity['dbConn'] = sqlite_open($serendipity['serendipityPath'] . $dbName . '.db');
+    if (defined('S9Y_DATA_PATH')) {
+        // Shared installations!
+        $dbfile = S9Y_DATA_PATH . $dbName . '.db';
+    } else {
+        $dbfile = $serendipity['serendipityPath'] . $dbName . '.db';
+    }
+
+    $serendipity['dbConn'] = sqlite_open($dbfile);
 
     if ($serendipity['dbConn']) {
         return true;
     }
 
-    $errs[] = "Unable to open \"{$serendipity['serendipityPath']}$dbName.db\" - check permissions (directory needs to be writeable for webserver)!";
+    $errs[] = "Unable to open \"$dbfile\" - check permissions (directory needs to be writeable for webserver)!";
     return false;
 }