[geeklog-hg] geeklog: Removed session variables for topic tree and will just ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Jul 1 11:33:48 EDT 2013


changeset 9151:0902e5b80b98
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0902e5b80b98
user: Tom <websitemaster at cogeco.net>
date: Sat Jun 29 16:59:44 2013 -0400
description:
Removed session variables for topic tree and will just use cache since it is easier and faster. Caching of what's new block is disabled if config option is set to 0

diffstat:

 public_html/docs/english/config.html  |   5 +--
 public_html/docs/japanese/config.html |   2 +-
 public_html/lib-common.php            |  41 +++++-----------------------------
 sql/mssql_tableanddata.php            |   4 +--
 sql/mysql_tableanddata.php            |   6 +----
 sql/pgsql_tableanddata.php            |   6 +----
 sql/updates/mssql_2.0.0_to_2.0.1.php  |   9 -------
 sql/updates/mysql_2.0.0_to_2.0.1.php  |   9 -------
 sql/updates/pgsql_2.0.0_to_2.0.1.php  |   9 -------
 system/lib-topic.php                  |  18 +-------------
 10 files changed, 15 insertions(+), 94 deletions(-)

diffs (283 lines):

diff -r 2b06962f3e8a -r 0902e5b80b98 public_html/docs/english/config.html
--- a/public_html/docs/english/config.html	Sat Jun 29 11:13:23 2013 -0400
+++ b/public_html/docs/english/config.html	Sat Jun 29 16:59:44 2013 -0400
@@ -597,8 +597,7 @@
   should improve performance of the web site.  In some cases, caching could 
   slow performance down.  For example, if the disk access is slow on the web 
   server or if the web server is accessing Windows shared drives, setting this 
-  option to FALSE may improve performance. This option also controls if Instance 
-  Caching is enabled since that is also part of the Caching Template Library</td></tr>  
+  option to FALSE may improve performance.</td></tr>  
 </table>
 
 <h3><a name="theme_advanced">Theme: Advanced Settings</a></h3>
@@ -751,7 +750,7 @@
 <tr>
   <td valign="top"><a name="desc_whatsnew_cache_time">whatsnew_cache_time</a></td>
   <td valign="top">3600</td>
-  <td valign="top">If Caching is enabled the What's New Block will be Cached for no longer than this many seconds.</td></tr>    
+  <td valign="top">The What's New Block will be cached for no longer than this many seconds. If 0 caching is disabled.</td></tr>    
 </table>
 
 
diff -r 2b06962f3e8a -r 0902e5b80b98 public_html/docs/japanese/config.html
--- a/public_html/docs/japanese/config.html	Sat Jun 29 11:13:23 2013 -0400
+++ b/public_html/docs/japanese/config.html	Sat Jun 29 16:59:44 2013 -0400
@@ -669,7 +669,7 @@
 <tr>
   <td valign="top"><a name="desc_whatsnew_cache_time">whatsnew_cache_time</a></td>
   <td valign="top">3600</td>
-  <td valign="top">If Caching is enabled the What's New Block will be Cached for no longer than this many seconds.</td></tr>      
+  <td valign="top">The What's New Block will be cached for no longer than this many seconds. If 0 caching is disabled.</td></tr>   
 </table>
 
 
diff -r 2b06962f3e8a -r 0902e5b80b98 public_html/lib-common.php
--- a/public_html/lib-common.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/public_html/lib-common.php	Sat Jun 29 16:59:44 2013 -0400
@@ -500,21 +500,13 @@
 *
 */
 
-// Figure out if we need to update topic tree or retrieve it from the session/cache
+// Figure out if we need to update topic tree or retrieve it from the cache
 // For anonymous users topic tree data can be shared
 // Retrieve when last topic update happened
 $last_topic_update = DB_getItem($_TABLES['vars'], 'value', "name='last_topic_update'");
 // Figure out how old stored topic tree is
-if ($_CONF['cache_templates']) {
-    $cacheInstance = 'topic_tree__' . CACHE_security_hash();
-    $topic_tree_date = date("Y-m-d H:i:s", CACHE_get_instance_update($cacheInstance, true));
-} else {
-    if (COM_isAnonUser()) { 
-        $topic_tree_date = DB_getItem($_TABLES['vars'], 'value', "name='anon_topic_tree_date'");
-    } else {
-        $topic_tree_date = SESS_getVariable('topic_tree_date');      
-    }
-}
+$cacheInstance = 'topic_tree__' . CACHE_security_hash();
+$topic_tree_date = date("Y-m-d H:i:s", CACHE_get_instance_update($cacheInstance, true));
 // See if Topic Tree has changed for users, if so rebuild tree   
 if ($last_topic_update > $topic_tree_date || empty($last_topic_update)) {
     $_TOPICS = TOPIC_buildTree(TOPIC_ROOT, true);
@@ -524,23 +516,9 @@
     }
 
     // Save updated topic tree and date
-    if ($_CONF['cache_templates']) {
-        CACHE_create_instance($cacheInstance, serialize($_TOPICS), true);
-    } else {
-        if (COM_isAnonUser()) {
-            DB_query("UPDATE {$_TABLES['vars']} SET value='$last_topic_update' WHERE name='anon_topic_tree_date'");
-            DB_query("UPDATE {$_TABLES['vars']} SET value='" . serialize($_TOPICS) . "' WHERE name='anon_topic_tree'");
-        } else {
-            SESS_setVariable('topic_tree_date', $last_topic_update);
-            SESS_setVariable('topic_tree', serialize($_TOPICS));            
-        }
-    }
+    CACHE_create_instance($cacheInstance, serialize($_TOPICS), true);
 } else {
-    if ($_CONF['cache_templates']) {
-        $serialized_topic_tree = CACHE_check_instance($cacheInstance, true);
-    } else {
-        $serialized_topic_tree = DB_getItem($_TABLES['vars'], 'value', "name='anon_topic_tree'");
-    }
+    $serialized_topic_tree = CACHE_check_instance($cacheInstance, true);
     $_TOPICS = unserialize($serialized_topic_tree);
 }    
 
@@ -5174,12 +5152,7 @@
 {
     global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $_USER;
 
-    if ($_CONF['cache_templates']) {
-        if (COM_isAnonUser()) {
-            $uid = 1;
-        } else {
-            $uid = $_USER['uid'];
-        }
+    if ($_CONF['whatsnew_cache_time'] > 0) {
 
         $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme'];
         $retval = CACHE_check_instance($cacheInstance, 0);
@@ -5438,7 +5411,7 @@
     }
 
     $retval .= COM_endBlock( COM_getBlockTemplate( 'whats_new_block', 'footer', $position ));
-    if ($_CONF['cache_templates']) { CACHE_create_instance($cacheInstance, $retval, 0); }
+    if ($_CONF['whatsnew_cache_time'] > 0) { CACHE_create_instance($cacheInstance, $retval, 0); }
 
     return $retval;
 }
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/mssql_tableanddata.php
--- a/sql/mssql_tableanddata.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/mssql_tableanddata.php	Sat Jun 29 16:59:44 2013 -0400
@@ -264,8 +264,6 @@
     [md5_sess_id] [varchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, 
     [whos_online] [tinyint] NOT NULL, 
     [topic] [varchar] (20) NOT NULL, 
-    [topic_tree_date] [datetime] NULL,
-    [topic_tree] [text] NULL
 ) ON [PRIMARY]
 ";
 
@@ -504,7 +502,7 @@
 $_SQL[] = "
 CREATE TABLE [dbo].[{$_TABLES['vars']}] (
     [name] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
-    [value] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
+    [value] [varchar] (128) NULL
 ) ON [PRIMARY]
 ";
 
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/mysql_tableanddata.php
--- a/sql/mysql_tableanddata.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/mysql_tableanddata.php	Sat Jun 29 16:59:44 2013 -0400
@@ -260,8 +260,6 @@
   md5_sess_id varchar(128) default NULL,
   whos_online tinyint(1) NOT NULL default '1',
   topic varchar(20) NOT NULL default '',
-  topic_tree_date datetime DEFAULT NULL,
-  topic_tree text DEFAULT NULL,
   PRIMARY KEY  (sess_id),
   KEY sess_id (sess_id),
   KEY start_time (start_time),
@@ -545,7 +543,7 @@
 $_SQL[] = "
 CREATE TABLE {$_TABLES['vars']} (
   name varchar(20) NOT NULL default '',
-  value text default NULL,
+  value varchar(128) default NULL,
   PRIMARY KEY  (name)
 ) ENGINE=MyISAM
 ";
@@ -833,8 +831,6 @@
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_scheduled_run','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_article_publish','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','') ";
-$_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_version','0.0.0') ";
 
 $_DATA[] = "INSERT INTO {$_TABLES['trackbackcodes']} (code, name) VALUES (0,'Trackback Enabled') ";
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/pgsql_tableanddata.php
--- a/sql/pgsql_tableanddata.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/pgsql_tableanddata.php	Sat Jun 29 16:59:44 2013 -0400
@@ -259,8 +259,6 @@
   md5_sess_id varchar(128) default NULL,
   whos_online smallint NOT NULL default '1',
   topic varchar(20) NOT NULL default '',
-  topic_tree_date timestamp DEFAULT NULL,
-  topic_tree text DEFAULT NULL,
   PRIMARY KEY (sess_id)
 );
   CREATE INDEX {$_TABLES['sessions']}_start_time ON {$_TABLES['sessions']} (start_time);
@@ -544,7 +542,7 @@
 $_SQL[] = "
 CREATE TABLE {$_TABLES['vars']} (
   name varchar(20) NOT NULL default '',
-  value text default NULL,
+  value varchar(128) default NULL,
   PRIMARY KEY (name)
 )
 ";
@@ -851,8 +849,6 @@
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_scheduled_run','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_article_publish','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','') ";
-$_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_version','0.0.0') ";
 
 $_DATA[] = "INSERT INTO {$_TABLES['trackbackcodes']} (code, name) VALUES (0,'Trackback Enabled') ";
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/updates/mssql_2.0.0_to_2.0.1.php
--- a/sql/updates/mssql_2.0.0_to_2.0.1.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/updates/mssql_2.0.0_to_2.0.1.php	Sat Jun 29 16:59:44 2013 -0400
@@ -3,17 +3,8 @@
 // Delete anonymous user comment settings since all 3 are now config options
 $_SQL[] = "DELETE FROM {$_TABLES['usercomment']} WHERE uid = 1";
 
-// Update Session Table
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree_date datetime DEFAULT NULL AFTER topic";
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree text DEFAULT NULL AFTER topic_tree_date";
-
-// Alter Session table structure
-$_SQL[] = "ALTER TABLE {$_TABLES['vars']} CHANGE `value` `value` TEXT DEFAULT NULL"; 
-
 // New Geeklog variable for Topics
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";
 
 /**
  * Add new config options
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/updates/mysql_2.0.0_to_2.0.1.php
--- a/sql/updates/mysql_2.0.0_to_2.0.1.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/updates/mysql_2.0.0_to_2.0.1.php	Sat Jun 29 16:59:44 2013 -0400
@@ -3,17 +3,8 @@
 // Delete anonymous user comment settings since all 3 are now config options
 $_SQL[] = "DELETE FROM {$_TABLES['usercomment']} WHERE uid = 1";
 
-// Update Session Table
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree_date datetime DEFAULT NULL AFTER topic";
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree text DEFAULT NULL AFTER topic_tree_date";
-
-// Alter Session table structure
-$_SQL[] = "ALTER TABLE {$_TABLES['vars']} CHANGE `value` `value` TEXT DEFAULT NULL"; 
-
 // New Geeklog variable for Topics
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";
 
 /**
  * Add new config options
diff -r 2b06962f3e8a -r 0902e5b80b98 sql/updates/pgsql_2.0.0_to_2.0.1.php
--- a/sql/updates/pgsql_2.0.0_to_2.0.1.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/sql/updates/pgsql_2.0.0_to_2.0.1.php	Sat Jun 29 16:59:44 2013 -0400
@@ -3,17 +3,8 @@
 // Delete anonymous user comment settings since all 3 are now config options
 $_SQL[] = "DELETE FROM {$_TABLES['usercomment']} WHERE uid = 1";
 
-// Update Session Table
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree_date datetime DEFAULT NULL AFTER topic";
-$_SQL[] = "ALTER TABLE {$_TABLES['sessions']} ADD topic_tree text DEFAULT NULL AFTER topic_tree_date";
-
-// Alter Session table structure
-$_SQL[] = "ALTER TABLE {$_TABLES['vars']} CHANGE `value` `value` TEXT DEFAULT NULL"; 
-
 // New Geeklog variable for Topics
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";;
 
 /**
  * Add new config options
diff -r 2b06962f3e8a -r 0902e5b80b98 system/lib-topic.php
--- a/system/lib-topic.php	Sat Jun 29 11:13:23 2013 -0400
+++ b/system/lib-topic.php	Sat Jun 29 16:59:44 2013 -0400
@@ -1843,22 +1843,8 @@
     
     // Wipe out user's session variable for last_topic_update (if it exists) since their 
     // security may have changed and the topic tree should be updated again
-    if ($_CONF['cache_templates']) {
-        $cacheInstance = 'topic_tree__' . CACHE_security_hash();
-        CACHE_remove_instance($cacheInstance);
-    } else {
-        // See if user (other than anonymous) has a session
-        if ($uid > 1) {
-            $session_id = SESS_getSessionIdFromUserId($uid);
-            
-            if (!empty($session_id)) {
-                SESS_setVariable('topic_tree_date', '', $session_id);
-            }
-        } else {
-            // Delete topic tree array date in vars table    
-            DB_query("UPDATE {$_TABLES['vars']} SET value='' WHERE name='anon_topic_tree_date'");
-        }
-    }
+    $cacheInstance = 'topic_tree__' . CACHE_security_hash();
+    CACHE_remove_instance($cacheInstance);
 }
 
 ?>



More information about the geeklog-cvs mailing list