Skip to content

Commit

Permalink
Fix Comcode cache re-populate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraham committed Mar 11, 2019
1 parent 08f67ef commit cbeacac
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions data_custom/functions.dat

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion forum/pages/modules/topicview.php
Expand Up @@ -768,7 +768,7 @@ public function run()
}
$more_url = build_url($map, get_module_zone('topics'));
if (isset($topic_info['first_post'])) {
$post_row = db_map_restrict($topic_info['row'], array('id', 'p_post'));
$post_row = db_map_restrict($topic_info['row'], array('id', 'p_post'), array('id' => 't_cache_first_post_id'));
$_postdetails = get_translated_tempcode('f_posts', $post_row, 'p_post', $GLOBALS['FORUM_DB']);
} else {
$_postdetails = new Tempcode();
Expand Down
2 changes: 1 addition & 1 deletion site/pages/modules/galleries.php
Expand Up @@ -903,7 +903,7 @@ public function do_gallery_flow_mode($rating_details, $comment_details, $cat, $r
continue;
}

$just_row = db_map_restrict($row, array('description')) + array('id' => $row['r_id']);
$just_row = db_map_restrict($row, array('id', 'description'), array('id' => 'r_id'));

$entry_title = get_translated_text($row['title']);
$entry_description = get_translated_tempcode($type . 's', $just_row, 'description');
Expand Down
2 changes: 1 addition & 1 deletion site/pages/modules/warnings.php
Expand Up @@ -464,7 +464,7 @@ public function get_form_fields($new = true, $explanation = '', $is_warning = 0,
$posts_by_member = $GLOBALS['FORUM_DB']->query_select('f_posts p JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics t ON t.id=p.p_topic_id', array('p.*', 't_cache_first_post_id', 't_cache_last_post_id', 't_cache_num_posts', 't_cache_first_title', 'p_cache_forum_id'), $where, $sup);
$spam_urls = array();
foreach ($posts_by_member as $post) {
$just_post_row = db_map_restrict($post, array('id', 'p_post'));
$just_post_row = db_map_restrict($post, array('id', 'p_post'), array('id' => 'p_id'));
$post_text = get_translated_tempcode('f_posts', $just_post_row, 'p_post', $GLOBALS['FORUM_DB']);
$matches = array();
$num_matches = preg_match_all('#<a\s[^<>]*href=["\']([^"\']*)["\']#', $post_text->evaluate(), $matches);
Expand Down
2 changes: 1 addition & 1 deletion sources/cns_forum_driver_helper.php
Expand Up @@ -384,7 +384,7 @@ function _helper_show_forum_topics($this_ref, $name, $limit, $start, &$max_rows,
$out[$i]['firstmemberid'] = $fp_rows[0]['p_poster'];
$out[$i]['firsttitle'] = $fp_rows[0]['p_title'];
if ($show_first_posts) {
$post_row = db_map_restrict($fp_rows[0], array('p_post')) + array('id' => $fp_rows[0]['p_id']);
$post_row = db_map_restrict($fp_rows[0], array('id', 'p_post'), array('id' => 'p_id'));
$out[$i]['firstpost_language_string'] = $fp_rows[0]['p_post'];
$out[$i]['firstpost'] = get_translated_tempcode('f_posts', $post_row, 'p_post', $this_ref->connection);
}
Expand Down
2 changes: 1 addition & 1 deletion sources/cns_forumview.php
Expand Up @@ -495,7 +495,7 @@ function cns_get_topic_array($topic_row, $member_id, $hot_topic_definition, $inv
$topic = array();

if (!is_null($topic_row['p_post'])) {
$post_row = db_map_restrict($topic_row, array('p_post')) + array('id' => $topic_row['t_cache_first_post_id']);
$post_row = db_map_restrict($topic_row, array('id', 'p_post'), array('id' => 't_cache_first_post_id'));
$topic['first_post'] = get_translated_tempcode('f_posts', $post_row, 'p_post', $GLOBALS['FORUM_DB']);
} else {
$topic['first_post'] = new Tempcode();
Expand Down
2 changes: 1 addition & 1 deletion sources/cns_forumview_pt.php
Expand Up @@ -95,7 +95,7 @@ function cns_get_private_topics($start = 0, $true_start = 0, $max = null, $sql_s
if (is_null($topic_row['p_post'])) {
$topic['first_post'] = new Tempcode();
} else {
$post_row = db_map_restrict($topic_row, array('p_post')) + array('id' => $topic_row['t_cache_first_post_id']);
$post_row = db_map_restrict($topic_row, array('id', 'p_post'), array('id' => 't_cache_first_post_id'));
$topic['first_post'] = get_translated_tempcode('f_posts', $post_row, 'p_post', $GLOBALS['FORUM_DB']);
}
$topic['first_post']->singular_bind('ATTACHMENT_DOWNLOADS', make_string_tempcode('?'));
Expand Down
2 changes: 1 addition & 1 deletion sources/cns_notifications.php
Expand Up @@ -204,7 +204,7 @@ function generate_notifications($member_id)
$notifications = new Tempcode();
$num_unread_pps = 0;
foreach ($unread_pps as $unread_pp) {
$just_post_row = db_map_restrict($unread_pp, array('id', 'p_post'));
$just_post_row = db_map_restrict($unread_pp, array('id', 'p_post'), array('id' => 'p_id'));

$by_id = (is_null($unread_pp['t_cache_first_member_id']) || !is_null($unread_pp['t_forum_id'])) ? $unread_pp['p_poster'] : $unread_pp['t_cache_first_member_id'];
$by = is_guest($by_id) ? do_lang('SYSTEM') : $GLOBALS['CNS_DRIVER']->get_username($by_id);
Expand Down
2 changes: 1 addition & 1 deletion sources/cns_posts2.php
Expand Up @@ -165,7 +165,7 @@ function render_post_box($row, $use_post_title = false, $give_context = true, $i
$post_url = build_url($map, get_module_zone('topicview'));
$post_url->attach('#post_' . strval($row['id']));
if ($text_summary === null) {
$just_post_row = db_map_restrict($row, array('id', 'p_post'));
$just_post_row = db_map_restrict($row, array('id', 'p_post'), array('id' => 'p_id'));
$post = get_translated_tempcode('f_posts', $just_post_row, 'p_post', $GLOBALS['FORUM_DB']);
} else {
$post = $text_summary;
Expand Down
10 changes: 8 additions & 2 deletions sources/database.php
Expand Up @@ -74,13 +74,19 @@ function init__database()
*
* @param array $row DB table row.
* @param array $fields List of fields to copy through.
* @param ?array $remap Remapping of fields, if we need to do some kind of substitution as well (usually this will be because the row came from a join and we had to rename fields) (null: none).
* @return array Map of fields.
*/
function db_map_restrict($row, $fields)
function db_map_restrict($row, $fields, $remap = null)
{
// TODO: Change null to array() in v11; remove these 3 lines
if ($remap === null) {
$remap = array();
}

$out = array();
foreach ($fields as $field) {
$out[$field] = $row[$field];
$out[$field] = $row[(array_key_exists($field, $remap) && array_key_exists($row, $remap[$field])) ? $remap[$field] : $field];
if (isset($row[$field . '__text_parsed'])) {
$out[$field . '__text_parsed'] = $row[$field . '__text_parsed'];
}
Expand Down
2 changes: 1 addition & 1 deletion sources/hooks/systems/rss/cns_forumview.php
Expand Up @@ -81,7 +81,7 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
}

$news_title = xmlentities($row['t_cache_first_title']);
$post_row = db_map_restrict($row, array('p_post')) + array('id' => $row['t_cache_first_post_id']);
$post_row = db_map_restrict($row, array('id', 'p_post'), array('id' => 't_cache_first_post_id'));
$_summary = get_translated_tempcode('f_posts', $post_row, 'p_post', $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
Expand Down
2 changes: 1 addition & 1 deletion sources/hooks/systems/rss/cns_private_topics.php
Expand Up @@ -74,7 +74,7 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
}

$news_title = xmlentities($row['t_cache_first_title']);
$post_row = db_map_restrict($row, array('p_post_first')) + array('id' => $row['t_cache_first_post_id']);
$post_row = db_map_restrict($row, array('id', 'p_post_first'), array('id' => 't_cache_first_post_id'));
$_summary = get_translated_tempcode('f_posts', $post_row, 'p_post_first', $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
Expand Down
2 changes: 1 addition & 1 deletion sources/hooks/systems/rss/cns_unread_topics.php
Expand Up @@ -84,7 +84,7 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
}

$news_title = xmlentities($row['t_cache_first_title']);
$post_row = db_map_restrict($row, array('p_post')) + array('id' => $row['t_cache_first_post_id']);
$post_row = db_map_restrict($row, array('id', 'p_post'), array('id' => 't_cache_first_post_id'));
$_summary = get_translated_tempcode('f_posts', $post_row, 'p_post', $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
Expand Down
2 changes: 1 addition & 1 deletion sources/notification_poller.php
Expand Up @@ -426,7 +426,7 @@ function pt_to_xml($row)
$url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, true);
$avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id);

$just_post_row = db_map_restrict($row, array('id', 'p_post'));
$just_post_row = db_map_restrict($row, array('id', 'p_post'), array('id' => 'p_id'));
$_message = get_translated_tempcode('f_posts', $just_post_row, 'p_post', $GLOBALS['FORUM_DB']);

$rendered = do_template('NOTIFICATION_PT_DESKTOP', array(
Expand Down

0 comments on commit cbeacac

Please sign in to comment.