Skip to content
Permalink
Browse files

Fix bug with Comcode page cache being emptied in DB but not at runtim…

…e; may cause internal processing issues (although maybe not in practice on v10)
  • Loading branch information...
chrisgraham committed May 21, 2019
1 parent 165bb50 commit 42ad9ed496b64a522380970bbe9c79fc197b3ea8
Showing with 17 additions and 4 deletions.
  1. +1 −0 adminzone/pages/modules/admin_zones.php
  2. +2 −0 sources/caches3.php
  3. +2 −0 sources/lang3.php
  4. +1 −0 sources/lang_compile.php
  5. +9 −4 sources/site.php
  6. +2 −0 sources/zones3.php
@@ -558,6 +558,7 @@ public function __editor()
delete_lang($cache['string_index']);
}
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => is_null($redirect) ? $id : $redirect, 'the_page' => $for));
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
}
}
@@ -544,6 +544,8 @@ function erase_cached_templates($preserve_some = false, $only_templates = null,
*/
function erase_comcode_page_cache()
{
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
if (!multi_lang_content()) {
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages');
return;
@@ -624,6 +624,7 @@ function _comcode_lang_string($lang_code)
} elseif (array_key_exists(0, $comcode_page)) {
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $lang_code, 'the_zone' => '!'));
delete_lang($comcode_page[0]['string_index']);
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
}
} else {
$comcode_page = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('*'), array('the_page' => $lang_code, 'the_zone' => '!'), '', 1);
@@ -633,6 +634,7 @@ function _comcode_lang_string($lang_code)
return $ret;
} elseif (array_key_exists(0, $comcode_page)) {
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $lang_code, 'the_zone' => '!'));
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
}
}
@@ -57,6 +57,7 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro
foreach ($comcode_lang_strings as $comcode_lang_string) {
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', $comcode_lang_string);
delete_lang($comcode_lang_string['string_index']);
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
}
}
}
@@ -180,6 +180,9 @@ function init__site()
}
}
}
global $COMCODE_PAGE_RUNTIME_CACHE;
$COMCODE_PAGE_RUNTIME_CACHE = array();
}
/**
@@ -1642,7 +1645,7 @@ function load_comcode_page_from_cache($codename, $zone, $theme)
*/
function _load_comcodes_page_from_cache($pages)
{
static $cache = array();
global $COMCODE_PAGE_RUNTIME_CACHE;
$ret = array();
@@ -1652,8 +1655,8 @@ function _load_comcodes_page_from_cache($pages)
$sql .= ' WHERE 1=0';
foreach ($pages as $page) {
$sz = serialize($page);
if (isset($cache[$sz])) {
$ret[] = $cache[$sz];
if (isset($COMCODE_PAGE_RUNTIME_CACHE[$sz])) {
$ret[] = $COMCODE_PAGE_RUNTIME_CACHE[$sz];
} else {
list($codename, $zone, $theme) = $page;
@@ -1667,7 +1670,7 @@ function _load_comcodes_page_from_cache($pages)
$_ret = $GLOBALS['SITE_DB']->query($sql, null, null, false, false, array('string_index' => 'LONG_TRANS__COMCODE', 'cc_page_title' => '?SHORT_TRANS'));
foreach ($_ret as $_page) {
$sz = serialize(array($_page['the_page'], $_page['the_zone'], $_page['the_theme']));
$cache[$sz] = $_page;
$COMCODE_PAGE_RUNTIME_CACHE[$sz] = $_page;
$ret[] = $_page;
}
}
@@ -1762,6 +1765,7 @@ function load_comcode_page($string, $zone, $codename, $file_base = null, $being_
delete_lang($comcode_page[0]['string_index']);
}
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $codename, 'the_zone' => $zone));
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
}
}
$theme = $GLOBALS['FORUM_DRIVER']->get_theme();
@@ -1803,6 +1807,7 @@ function load_comcode_page($string, $zone, $codename, $file_base = null, $being_
$GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_edit_date' => $mtime), array('the_page' => $codename, 'the_zone' => $zone), '', 1);
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $codename));
delete_lang($comcode_page_row['string_index']);
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
$db_set = null;
$comcode_page_row = null;
@@ -564,6 +564,7 @@ function save_comcode_page($zone, $new_file, $lang, $text, $validated, $parent_p
foreach ($caches as $cache) {
delete_lang($cache['string_index']);
}
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
// Log
log_it('COMCODE_PAGE_EDIT', $new_file, $zone);
@@ -705,6 +706,7 @@ function delete_cms_page($zone, $page, $type = null, $use_afm = false)
require_code('attachments3');
delete_comcode_attachments('comcode_page', $zone . ':' . $page);
$GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
$GLOBALS['COMCODE_PAGE_RUNTIME_CACHE'] = array();
$GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
erase_persistent_cache();
decache('main_comcode_page_children');

0 comments on commit 42ad9ed

Please sign in to comment.
You can’t perform that action at this time.