]> git.mjollnir.org Git - s9y.git/commitdiff
Put dbCharset option into local config file.
authorgarvinhicking <garvinhicking>
Fri, 9 Jun 2006 09:32:30 +0000 (09:32 +0000)
committergarvinhicking <garvinhicking>
Fri, 9 Jun 2006 09:32:30 +0000 (09:32 +0000)
docs/NEWS
include/db/mysql.inc.php
include/db/mysqli.inc.php
include/functions_installer.inc.php
plugins/serendipity_event_statistics/serendipity_event_statistics.php
serendipity_config.inc.php

index 54d4139279043338012131013f05df2b3383fce2..72cf0b4882692093e758ace4d053c3275d2810ff 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -1,5 +1,11 @@
 # $Id$
 
+Version 1.1-alpha7()
+------------------------------------------------------------------------
+
+    * Move the DB charset option to serendipity_config_local.inc.php to
+      issue propper DB connections instantly. (garvinhicking)
+
 Version 1.1-alpha6()
 ------------------------------------------------------------------------
 
index 49393b31969a3cb23e254b9b076171d04c3506c6..539fc29e37eb3157752d81f27b9205a91b49353f 100644 (file)
@@ -271,7 +271,10 @@ function serendipity_db_connect() {
 function serendipity_db_reconnect() {
     global $serendipity;
 
-    if (defined('SQL_CHARSET') && $serendipity['dbNames']) {
+    if (isset($serendipity['dbCharset'])) {
+        mysql_query("SET NAMES " . $serendipity['dbCharset'], $serendipity['dbConn']);
+        define('SQL_CHARSET_INIT', true);
+    } elseif (defined('SQL_CHARSET') && $serendipity['dbNames'] && !defined('SQL_CHARSET_INIT')) {
         mysql_query("SET NAMES " . SQL_CHARSET, $serendipity['dbConn']);
     }
 }
index fd13abdb981d4e0f99bfb7696b72ee1f72138bba..bf2ba3a3b53270f8721af0f8dc34f1933567c4bd 100644 (file)
@@ -240,8 +240,11 @@ function serendipity_db_connect() {
 function serendipity_db_reconnect() {
     global $serendipity;
 
-    if (defined('SQL_CHARSET') && $serendipity['dbNames']) {
-        mysqli_query($serendipity['dbConn'], "SET NAMES " . SQL_CHARSET);
+    if (isset($serendipity['dbCharset'])) {
+        mysqli_query($serendipity['dbConn'], "SET NAMES " . $serendipity['dbCharset']);
+        define('SQL_CHARSET_INIT', true);
+    } elseif (defined('SQL_CHARSET') && $serendipity['dbNames'] && !defined('SQL_CHARSET_INIT')) {
+        mysqli_query($serendipity['dbConn'], "SET NAMES " . SQL_CHARSET, $serendipity['dbConn']);
     }
 }
 
index 01281ae30ed15236e1e8d7aa4d2ebc2432f97851..9eb610174d4fde99dbd697ca07a97c5b33e9d380 100644 (file)
@@ -107,6 +107,7 @@ function serendipity_updateLocalConfig($dbName, $dbPrefix, $dbHost, $dbUser, $db
     fwrite($configfp, "\t\$serendipity['dbPass']            = '" . addslashes($dbPass) . "';\n");
     fwrite($configfp, "\t\$serendipity['dbType']            = '" . addslashes($dbType) . "';\n");
     fwrite($configfp, "\t\$serendipity['dbPersistent']      = ". (serendipity_db_bool($dbPersistent) ? 'true' : 'false') .";\n");
+    fwrite($configfp, "\t\$serendipity['dbCharset']         = '" . addslashes(SQL_CHARSET) . "';\n");
 
     if (is_array($privateVariables) && count($privateVariables) > 0) {
         foreach($privateVariables AS $p_idx => $p_val) {
index 64960a28d87e491e7f199997a0f6bbeea8978d80..a766852067fa53db7a2a1cfcca46c1c99e507cb8 100644 (file)
@@ -110,6 +110,10 @@ class serendipity_event_statistics extends serendipity_event
                     if (!is_array($tableChecker)) {
                         $this->createTables();
                     }
+
+                    if ($this->get_config('db_indices_created', 'false') !== '1') {
+                        $this->updateTables();
+                    }
                     
                     //Unique visitors are beeing registered and counted here. Calling function below.
                     $sessionChecker = serendipity_db_query("SELECT count(sessID) FROM {$serendipity['dbPrefix']}visitors WHERE '".serendipity_db_escape_string(session_id())."' = sessID GROUP BY sessID", true);
@@ -914,6 +918,10 @@ class serendipity_event_statistics extends serendipity_event
         )";
         serendipity_db_schema_import($q);
         
+        $this->updateTables();
+    } //end of function createTables()
+
+    function updateTables() {
         //create indices
         $q   = "CREATE INDEX visitorses ON {$serendipity['dbPrefix']}visitors(sessID);";
         serendipity_db_schema_import($q);
@@ -921,10 +929,10 @@ class serendipity_event_statistics extends serendipity_event
         serendipity_db_schema_import($q);
         $q   = "CREATE INDEX visitortime ON {$serendipity['dbPrefix']}visitors(time);";
         serendipity_db_schema_import($q);
-        $q   = "CREATE INDEX visitortime ON {$serendipity['dbPrefix']}visitors_count(year, month, day);";
+        $q   = "CREATE INDEX visitortimeb ON {$serendipity['dbPrefix']}visitors_count(year, month, day);";
         serendipity_db_schema_import($q);
-
-    } //end of function createTables()
+        $this->set_config('db_indices_created', '1');
+    }
 
 
     function dropTables() {
index 99c6f071159374e85cc2e6b1f25dcb029fe3b73d..c779346539583222eac95e95a4e3c8132dbcf550 100644 (file)
@@ -27,7 +27,7 @@ if (IS_installed === true && !defined('IN_serendipity')) {
 include(S9Y_INCLUDE_PATH . 'include/compat.inc.php');
 
 // The version string
-$serendipity['version']         = '1.1-alpha6';
+$serendipity['version']         = '1.1-alpha7';
 
 // Setting this to 'false' will enable debugging output. All alpa/beta/cvs snapshot versions will emit debug information by default. To increase the debug level (to enable Smarty debugging), set this flag to 'debug'.
 $serendipity['production']      = (preg_match('@\-(alpha|beta|cvs)@', $serendipity['version']) ? false : true);