Fixed a session_regenerate_id error leaving session files in /tmp folder.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 26 Jan 2012 22:22:50 +0000 (23:22 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 26 Jan 2012 22:22:50 +0000 (23:22 +0100)
includes/lang/gettext.php
includes/lang/language.php
includes/session.inc

index b5ab6130acec097f64f1d9b0a881337b27b67804..3023e9363020ebd4d8fdd2558198af73d5513cf1 100644 (file)
@@ -320,7 +320,10 @@ class gettext_php_support extends gettext_native_support
             $this->_jobs[] = array($domain, $path); 
             return;
         }
-
+        // Don't fill the domains with false data
+               if (strpos($domain, $this->_lang_code) === false)
+               return;
         $err = $this->_load_domain($domain, $path);
         if ($err != 0) 
         {
@@ -474,7 +477,7 @@ class gettext_php_support_parser
      */
     function _parse_line($line, $nbr)
     {
-        $line = str_replace("\\\"", "'", $line);
+        $line = str_replace("\\\"", "'", $line); // Should be inside preg_match, but I couldn't find the solution. This works.
         if (preg_match('/^\s*?#/', $line)) { return; }
         if (preg_match('/^\s*?msgid \"(.*?)(?!<\\\)\"/', $line, $m)) {
             $this->_store_key();
@@ -562,8 +565,8 @@ function set_ext_domain($path='') {
        }
 
        $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang';
-       // ignore change when extension does not provide translation structure
-       if (file_exists($lang_path))
+       // ignore change when extension does not provide translation structure and test for valid session.
+       if (file_exists($lang_path) && isset($_SESSION['get_text']))
                $_SESSION['get_text']->add_domain($_SESSION['language']->code,
                        $lang_path, $path ? '' : $_SESSION['language']->version);
 }
index ea428fca07b5463e3cfc310142b05ad98a9610ec..1d6d7d83fb9a7c66e0d6133fb6981e8fac7a564a 100644 (file)
@@ -88,6 +88,8 @@ if (!function_exists("_"))
 {
        function _($text) 
        {
+               if (!isset($_SESSION['get_text'])) // Don't allow using session if not is net.
+                       return $text;
                $retVal = $_SESSION['get_text']->gettext($text);
                if ($retVal == "")
                        return $text;
index 6407e6e0e0a7b69acdb3ab20f2490264388d0a6c..990a51c01a1403f6d9a333888f2021b1e9078544 100644 (file)
@@ -75,17 +75,20 @@ class SessionManager
                $_SESSION['OBSOLETE'] = true;
                $_SESSION['EXPIRES'] = time() + 10;
 
-               // Create new session without destroying the old one
-               session_regenerate_id(false);
-
+               // Create new session destroying the old one if posiible
+               if (phpversion() >= "5.1.0")
+                       session_regenerate_id(true);
+               else    
+                       session_regenerate_id();
                // Grab current session ID and close both sessions to allow other scripts to use them
                $newSession = session_id();
                session_write_close();
-
                // Set session ID to the new one, and start it back up again
+
                session_id($newSession);
                session_start();
-
+               
                // Now we unset the obsolete and expiration values for the session we want to keep
                unset($_SESSION['OBSOLETE']);
                unset($_SESSION['EXPIRES']);
@@ -296,6 +299,8 @@ ini_set('session.gc_maxlifetime', 36000); // 10hrs
 
 $Session_manager = new SessionManager();
 $Session_manager->sessionStart('FA'.md5(dirname(__FILE__)));
+//session_name('FA'.md5(dirname(__FILE__)));
+//session_start();
 
 // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
 header("Cache-control: private");