[geeklog-hg] geeklog: Fixed issue where cached articles would not display on ...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Sep 20 10:41:55 EDT 2015
changeset 9622:aa78e8bebcdb
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/aa78e8bebcdb
user: Tom
date: Sun Sep 20 10:40:14 2015 -0400
description:
Fixed issue where cached articles would not display on the website after a period of time (bug #0001806)
diffstat:
system/lib-story.php | 92 ++++++++++++++++++++++++++++++---------------------
1 files changed, 54 insertions(+), 38 deletions(-)
diffs (117 lines):
diff -r ca097f881197 -r aa78e8bebcdb system/lib-story.php
--- a/system/lib-story.php Fri Sep 18 10:19:32 2015 -0400
+++ b/system/lib-story.php Sun Sep 20 10:40:14 2015 -0400
@@ -96,6 +96,57 @@
'archivearticle' => 'archivestorytext.thtml',
'archivebodytext' => 'archivestorybodytext.thtml'
));
+
+ // begin instance caching...
+ $cache_time = $story->DisplayElements('cache_time');
+ $current_article_tid = $story->DisplayElements('tid');
+ $retval = false; // If stays false will rebuild article and not used cache (checks done below)
+
+ if ($cache_time > 0 OR $cache_time == -1) {
+ $hash = CACHE_security_hash();
+ $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme'];
+
+ if ($_CONF['cache_templates']) {
+ $retval = $article->check_instance($cacheInstance, $article_filevar);
+ } else {
+ $retval = CACHE_check_instance($cacheInstance);
+ }
+
+ if ($retval AND $cache_time == -1) {
+ // Cache file found so use it since no time limit set to recreate
+
+ } elseif ($retval AND $cache_time > 0) {
+ $lu = CACHE_get_instance_update($cacheInstance);
+ $now = time();
+ if (($now - $lu) < $cache_time ) {
+ // Cache file found so use it since under time limit set to recreate
+
+ } else {
+ // generate article and create cache file
+ // Cache time is not built into template caching so need to delete it manually and reset $retval
+ if ($_CONF['cache_templates']) {
+ // Need to close and recreate template class since issues arise when theme templates are cached
+ unset($article); // Close template class
+ CACHE_remove_instance($cacheInstance);
+ $article = COM_newTemplate($_CONF['path_layout']);
+ $article->set_file( array(
+ 'article' => $storytpl,
+ 'bodytext' => 'storybodytext.thtml',
+ 'featuredarticle' => 'featuredstorytext.thtml',
+ 'featuredbodytext' => 'featuredstorybodytext.thtml',
+ 'archivearticle' => 'archivestorytext.thtml',
+ 'archivebodytext' => 'archivestorybodytext.thtml'
+ ));
+ } else { // theme templates are not cache so can go ahead and delete story cache
+ CACHE_remove_instance($cacheInstance);
+ }
+ $retval = false;
+ }
+ } else {
+ // Need to reset especially if caching is disabled for a certain story but template caching has been enabled for the theme
+ $retval = false;
+ }
+ }
$articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story='
. $story->getSid());
@@ -164,44 +215,9 @@
$bodytext = COM_highlightQuery($bodytext, $query );
}
- // begin instance caching...
- $cache_time = $story->DisplayElements('cache_time');
- $current_article_tid = $story->DisplayElements('tid');
- $retval = false; // If stays false will rebuild article and not used cache (checks done below)
- if ($cache_time > 0 OR $cache_time == -1) {
- $hash = CACHE_security_hash();
- $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme'];
-
- if ($_CONF['cache_templates']) {
- $retval = $article->check_instance($cacheInstance, $article_filevar);
- } else {
- $retval = CACHE_check_instance($cacheInstance);
- }
-
- if ($retval AND $cache_time == -1) {
- // Cache file found so use it since no time limit set to recreate
-
- } elseif ($retval AND $cache_time > 0) {
- $lu = CACHE_get_instance_update($cacheInstance);
- $now = time();
- if (($now - $lu) < $cache_time ) {
- // Cache file found so use it since under time limit set to recreate
-
- } else {
- // generate article and create cache file
- // Cache time is not built into template caching so need to delete it manually and reset $retval
- CACHE_remove_instance($cacheInstance);
- $retval = false;
- }
- } else {
- // Need to reset especially if caching is disabled for a certain story but tempalte caching has been enabled for the theme
- $retval = false;
- }
- }
-
- if ($index == 'p' || !empty($query) || !$retval) {
- // end of instance cache
+ // Create article only if preview, or query not empty, or if no cache version or cache version is not required
+ if ($index == 'p' || !empty($query) || !$retval) {
$article->set_var('article_filevar','');
$article->set_var( 'site_name', $_CONF['site_name'] );
@@ -345,7 +361,7 @@
}
$article_array = explode( '[page_break]', $bodytext );
$page_break_count = count($article_array);
- if ($story_page > $page_break_count) { // Can't have page count greate than actual number of pages
+ if ($story_page > $page_break_count) { // Can't have page count greater than actual number of pages
$story_page = $page_break_count;
}
$page_selector = COM_printPageNavigation(
More information about the geeklog-cvs
mailing list