News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Difference between cache_get_data and cache_put_data?

Started by Biology Forums, June 22, 2018, 01:46:28 PM

Previous topic - Next topic

Biology Forums

Could someone help me understand the difference here?

Also, are both compatible in SMF 1 and 2?


Arantor

One puts data into the cache, one gets data from the cache. Clue is kind of in the name...

Should be compatible between the two.

Biology Forums

Thank you both. I just feel it's not working the way it should:

// Let's cache the results to load faster...
if (($temp = cache_get_data('latest_topics', 480)) == null)
{

$request = db_query("
SELECT $select_clause
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}messages AS ml ON (ml.ID_MSG = t.ID_LAST_MSG)
INNER JOIN {$db_prefix}messages AS mso ON (mso.ID_MSG = t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = ml.ID_BOARD)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = ml.ID_TOPIC AND lt.ID_MEMBER = " . $ID_MEMBER .")
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = " . $ID_MEMBER .")
WHERE t." . $query_this_board . "
AND t.ID_LAST_MSG >= " . $min_message ." ".$time_frame."
ORDER BY " . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') ."
LIMIT $_REQUEST[start], $modSettings[defaultMaxTopics]", __FILE__, __LINE__);

$context['topics'] = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// * NiceTooltips mod
$row['nice_tooltip_first_msg'] = NiceTooltip($row['first_body'], $row['first_subject'], $row['first_smileys'], $row['ID_FIRST_MSG']);

// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['ID_FIRST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['first_body']) > 128)
$row['first_body'] = $func['substr']($row['first_body'], 0, 128) . '...';
$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['ID_LAST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['last_body']) > 128)

$row['last_body'] = $func['substr']($row['last_body'], 0, 128) . '...';

// Censor the subject and message preview.
censorText($row['first_subject']);
censorText($row['first_body']);

// Don't censor them twice!
if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['last_subject'] = $row['first_subject'];
$row['last_body'] = $row['first_body'];
}
else
{
censorText($row['last_subject']);
censorText($row['last_body']);
}

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . '">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . implode('', $tmppages);
// Or skip a few?
else
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . $tmppages[0] . $tmppages[1] . '...' . $tmppages[count($tmppages) - 2] . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '&nbsp;<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt['190'] . '</a>';
$pages .= '';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($context['icon_sources'][$row['first_icon']]))
$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($context['icon_sources'][$row['last_icon']]))
$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$context['topics'][$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['id_msg_first'],
'member' => array(
'name' => $row['first_poster_name'],
'id' => $row['id_first_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'],
'link' => ($row['id_first_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name'],
),
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['first_subject'] . '</a>',
'tooltip' => $row['nice_tooltip_first_msg'],
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['last_poster_name'],
'id' => $row['id_last_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'],
'link' => ($row['id_last_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name'], ),
'time' => timeformat($row['last_poster_time']),
'timestamp' => forum_time(true, $row['last_poster_time']),
'subject' => $row['last_subject'],
'preview' => $row['last_body'],
'icon' => $row['last_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'
),
'is_new' => $row['is_new'] && !$user_info['is_guest'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '#msg' . $row['ID_MSG'] . '" rel="nofollow">' . $row['first_subject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'subject' => $row['first_subject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
)
);

determineTopicClass($context['topics'][$row['ID_TOPIC']]);
}

mysql_free_result($request);

if (!empty($modSettings['cache_enable']))
cache_put_data('latest_topics', $context['topics'], 480);
}
else
$context['topics'] = $temp;


It's suppose to cache the query for 480 seconds, but when I update the table, and click refresh, it has the new content. :-\

Arantor


Biology Forums

SMF tells me that it has detected APC.

It's on level 1 caching. Memcache settings are blank.

Arantor

So it has detected APC. Are you using APC?

If you are not using APC, it will do nothing since SMF 1 (which your code is using) does not have caching support unless actually *using* APC. There is no file cache in 1.1.x.

Biology Forums

I have it installed on my server, so I assume it's running.

I checked the APC logs and I found it cached. The storage info for cee42e7c4bdfebac7a541802a63cf370-SMF-latest_topicssmf

'a:40:{i:1842004;a:22:{s:2:"id";s:7:"1842004";s:10:"first_post";a:11:{s:2:"id";s:7:"4705966";s:6:"member";a:4:{s:4:"name";s:6:"ceemae";s:2:"id";s:6:"815754";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815754";s:4:"link";s:81:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815754"&gt;ceemae&lt;/a&gt;";}s:4:"time";s:8:"Just now";s:9:"timestamp";i:1529706116;s:7:"subject";s:22:"Muscle/Skeletal System";s:7:"preview";s:140:"Aerobic training ____.&#8203;a. makes skeletal muscles become rigid and stiff&amp;nbsp; b. &#8203;produces muscle fibers with little endurancec. prom...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842004.0";s:4:"link";s:89:"&lt;a href="https://biology-forums.com/index.php?topic=1842004.0"&gt;Muscle/Skeletal System&lt;/a&gt;";s:7:"tooltip";s:466:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Muscle/Skeletal System&lt;/div&gt;&lt;div class="tooltip_body"&gt;Aerobic training ____.&#8203;&lt;br /&gt;&lt;br /&gt;a. makes skeletal muscles become rigid and stiff&lt;br /&gt;&amp;nbsp; &lt;br /&gt;b. &#8203;produces muscle fibers with little endurance&lt;br /&gt;&lt;br /&gt;c. promotes synthesis of actin and myosin&lt;br /&gt;&lt;br /&gt;d. makes skeletal muscles more resistant to fatigue&lt;br /&gt;&lt;br /&gt;e. produces muscle fibers that fatigue quickly&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705966";s:6:"member";a:4:{s:4:"name";s:6:"ceemae";s:2:"id";s:6:"815754";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815754";s:4:"link";s:81:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815754"&gt;ceemae&lt;/a&gt;";}s:4:"time";s:8:"Just now";s:9:"timestamp";i:1529706116;s:7:"subject";s:22:"Muscle/Skeletal System";s:7:"preview";s:140:"Aerobic training ____.&#8203;a. makes skeletal muscles become rigid and stiff&amp;nbsp; b. &#8203;produces muscle fibers with little endurancec. prom...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:63:"https://biology-forums.com/index.php?topic=1842004.0#msg4705966";s:4:"link";s:115:"&lt;a href="https://biology-forums.com/index.php?topic=1842004.0#msg4705966" rel="nofollow"&gt;Muscle/Skeletal System&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1842004.msg4705966#new";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842004.0";s:4:"link";s:115:"&lt;a href="https://biology-forums.com/index.php?topic=1842004.0#msg4705966" rel="nofollow"&gt;Muscle/Skeletal System&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:7:"subject";s:22:"Muscle/Skeletal System";s:5:"pages";s:0:"";s:7:"replies";s:1:"0";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:1:"3";s:4:"name";s:15:"General Biology";s:4:"href";s:46:"https://biology-forums.com/index.php?board=3.0";s:4:"link";s:76:"&lt;a href="https://biology-forums.com/index.php?board=3.0"&gt;General Biology&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:56;}i:1842003;a:22:{s:2:"id";s:7:"1842003";s:10:"first_post";a:11:{s:2:"id";s:7:"4705965";s:6:"member";a:4:{s:4:"name";s:6:"ceemae";s:2:"id";s:6:"815754";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815754";s:4:"link";s:81:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815754"&gt;ceemae&lt;/a&gt;";}s:4:"time";s:13:"5 minutes ago";s:9:"timestamp";i:1529705809;s:7:"subject";s:15:"Skeletal system";s:7:"preview";s:139:"What is an autoimmune disorder that affects the skeletal system?&#8203;a. &#8203;osteoarthritisb. polioc. &#8203;rheumatoid arthritisd. Graves' di...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842003.0";s:4:"link";s:82:"&lt;a href="https://biology-forums.com/index.php?topic=1842003.0"&gt;Skeletal system&lt;/a&gt;";s:7:"tooltip";s:359:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Skeletal system&lt;/div&gt;&lt;div class="tooltip_body"&gt;What is an autoimmune disorder that affects the skeletal system?&#8203;&lt;br /&gt;&lt;br /&gt;a. &#8203;osteoarthritis&lt;br /&gt;&lt;br /&gt;b. polio&lt;br /&gt;&lt;br /&gt;c. &#8203;rheumatoid arthritis&lt;br /&gt;&lt;br /&gt;d. Graves' disease&lt;br /&gt;&lt;br /&gt;e.&#8203; Hashimoto's disease&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705965";s:6:"member";a:4:{s:4:"name";s:6:"ceemae";s:2:"id";s:6:"815754";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815754";s:4:"link";s:81:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815754"&gt;ceemae&lt;/a&gt;";}s:4:"time";s:13:"5 minutes ago";s:9:"timestamp";i:1529705809;s:7:"subject";s:15:"Skeletal system";s:7:"preview";s:139:"What is an autoimmune disorder that affects the skeletal system?&#8203;a. &#8203;osteoarthritisb. polioc. &#8203;rheumatoid arthritisd. Graves' di...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:63:"https://biology-forums.com/index.php?topic=1842003.0#msg4705965";s:4:"link";s:108:"&lt;a href="https://biology-forums.com/index.php?topic=1842003.0#msg4705965" rel="nofollow"&gt;Skeletal system&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1842003.msg4705965#new";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842003.0";s:4:"link";s:108:"&lt;a href="https://biology-forums.com/index.php?topic=1842003.0#msg4705965" rel="nofollow"&gt;Skeletal system&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:7:"subject";s:15:"Skeletal system";s:5:"pages";s:0:"";s:7:"replies";s:1:"0";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:1:"3";s:4:"name";s:15:"General Biology";s:4:"href";s:46:"https://biology-forums.com/index.php?board=3.0";s:4:"link";s:76:"&lt;a href="https://biology-forums.com/index.php?board=3.0"&gt;General Biology&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:111;}i:1842002;a:22:{s:2:"id";s:7:"1842002";s:10:"first_post";a:11:{s:2:"id";s:7:"4705962";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695103;s:7:"subject";s:100:"According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...";s:7:"preview";s:131:"According to Hofstede\'s definition of culture a particular "category of people" may constitute a nation, an ethnic group, a gend...";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842002.0";s:4:"link";s:167:"&lt;a href="https://biology-forums.com/index.php?topic=1842002.0"&gt;According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...&lt;/a&gt;";s:7:"tooltip";s:388:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;According to Hofstede\'s definition of culture a particular "category of people" may constitute a nation, an ethnic group, a gender group, an organization, a family, or some other unit.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705964";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695103;s:7:"subject";s:100:"According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...";s:7:"preview";s:74:"Thank you for being such a great website leader! Your answer&amp;#039;s right.";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1842002.msg4705964#msg4705964";s:4:"link";s:202:"&lt;a href="https://biology-forums.com/index.php?topic=1842002.msg4705964#msg4705964" rel="nofollow"&gt;According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...&lt;/a&gt;";}s:6:"is_new";b:0;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1842002.msg4705964#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1842002.msg4705964new";s:4:"link";s:202:"&lt;a href="https://biology-forums.com/index.php?topic=1842002.msg4705964#msg4705964" rel="nofollow"&gt;According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:100:"According to Hofstede\'s definition of culture a particular "category of people" may constitute a ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:2:"12";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:166;}i:1842001;a:22:{s:2:"id";s:7:"1842001";s:10:"first_post";a:11:{s:2:"id";s:7:"4705959";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695085;s:7:"subject";s:101:"Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...";s:7:"preview";s:131:"Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human behavior that are confined to ...";s:4:"icon";s:4:"lamp";s:8:"icon_url";s:62:"https://biology-forums.com/Themes/default/images/post/lamp.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842001.0";s:4:"link";s:168:"&lt;a href="https://biology-forums.com/index.php?topic=1842001.0"&gt;Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...&lt;/a&gt;";s:7:"tooltip";s:346:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human behavior that are confined to a generation.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705961";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695085;s:7:"subject";s:101:"Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...";s:7:"preview";s:20:"Good timing, thanks!";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1842001.msg4705961#msg4705961";s:4:"link";s:203:"&lt;a href="https://biology-forums.com/index.php?topic=1842001.msg4705961#msg4705961" rel="nofollow"&gt;Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1842001.msg4705961#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1842001.msg4705961new";s:4:"link";s:203:"&lt;a href="https://biology-forums.com/index.php?topic=1842001.msg4705961#msg4705961" rel="nofollow"&gt;Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:4:"lamp";s:8:"icon_url";s:62:"https://biology-forums.com/Themes/default/images/post/lamp.gif";s:7:"subject";s:101:"Culture includes conscious and unconscious values, ideas, attitudes, and symbols that shape human ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:1:"6";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:221;}i:1842000;a:22:{s:2:"id";s:7:"1842000";s:10:"first_post";a:11:{s:2:"id";s:7:"4705956";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695075;s:7:"subject";s:106:"One reason cultural factors challenge global marketers is that many of these factors are hidden from view.";s:7:"preview";s:106:"One reason cultural factors challenge global marketers is that many of these factors are hidden from view.";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1842000.0";s:4:"link";s:173:"&lt;a href="https://biology-forums.com/index.php?topic=1842000.0"&gt;One reason cultural factors challenge global marketers is that many of these factors are hidden from view.&lt;/a&gt;";s:7:"tooltip";s:316:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;One reason cultural factors challenge global marketers is that many of these factors are hidden from view.&lt;/div&gt;&lt;div class="tooltip_body"&gt;One reason cultural factors challenge global marketers is that many of these factors are hidden from view.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705958";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695075;s:7:"subject";s:106:"One reason cultural factors challenge global marketers is that many of these factors are hidden from view.";s:7:"preview";s:45:"Marking this solved, moving on to the next...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1842000.msg4705958#msg4705958";s:4:"link";s:208:"&lt;a href="https://biology-forums.com/index.php?topic=1842000.msg4705958#msg4705958" rel="nofollow"&gt;One reason cultural factors challenge global marketers is that many of these factors are hidden from view.&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1842000.msg4705958#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1842000.msg4705958new";s:4:"link";s:208:"&lt;a href="https://biology-forums.com/index.php?topic=1842000.msg4705958#msg4705958" rel="nofollow"&gt;One reason cultural factors challenge global marketers is that many of these factors are hidden from view.&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:106:"One reason cultural factors challenge global marketers is that many of these factors are hidden from view.";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:276;}i:1841999;a:22:{s:2:"id";s:7:"1841999";s:10:"first_post";a:11:{s:2:"id";s:7:"4705953";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695065;s:7:"subject";s:103:"Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.";s:7:"preview";s:103:"Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841999.0";s:4:"link";s:170:"&lt;a href="https://biology-forums.com/index.php?topic=1841999.0"&gt;Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.&lt;/a&gt;";s:7:"tooltip";s:310:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.&lt;/div&gt;&lt;div class="tooltip_body"&gt;Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705955";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695065;s:7:"subject";s:103:"Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.";s:7:"preview";s:9:"Thank you";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841999.msg4705955#msg4705955";s:4:"link";s:205:"&lt;a href="https://biology-forums.com/index.php?topic=1841999.msg4705955#msg4705955" rel="nofollow"&gt;Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841999.msg4705955#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841999.msg4705955new";s:4:"link";s:205:"&lt;a href="https://biology-forums.com/index.php?topic=1841999.msg4705955#msg4705955" rel="nofollow"&gt;Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:103:"Historically, the lagoon in Venice provided Venetians with a safe haven from Germanic and Hun invaders.";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:331;}i:1841998;a:22:{s:2:"id";s:7:"1841998";s:10:"first_post";a:11:{s:2:"id";s:7:"4705950";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695038;s:7:"subject";s:102:"Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...";s:7:"preview";s:131:"Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool found that consumers in Italy...";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841998.0";s:4:"link";s:169:"&lt;a href="https://biology-forums.com/index.php?topic=1841998.0"&gt;Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...&lt;/a&gt;";s:7:"tooltip";s:611:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool found that consumers in Italy, France, and Germany had trouble pronouncing the name. These are examples which show the importance of ________ in global marketing.&lt;br /&gt;A) syntax and morphology&lt;br /&gt;B) phonology and morphology&lt;br /&gt;C) syntax and semantics&lt;br /&gt;D) semantics and phonology&lt;br /&gt;E) semantics a&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705952";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695038;s:7:"subject";s:102:"Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...";s:7:"preview";s:74:"Thank you for being such a great website leader! Your answer&amp;#039;s right.";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841998.msg4705952#msg4705952";s:4:"link";s:204:"&lt;a href="https://biology-forums.com/index.php?topic=1841998.msg4705952#msg4705952" rel="nofollow"&gt;Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841998.msg4705952#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841998.msg4705952new";s:4:"link";s:204:"&lt;a href="https://biology-forums.com/index.php?topic=1841998.msg4705952#msg4705952" rel="nofollow"&gt;Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:102:"Colgate discovered that in Spanish colgate is a verb form that means "go hang yourself." Whirlpool ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:386;}i:1841997;a:22:{s:2:"id";s:7:"1841997";s:10:"first_post";a:11:{s:2:"id";s:7:"4705947";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695026;s:7:"subject";s:99:"In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...";s:7:"preview";s:131:"In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation results in zhi xiao which is the...";s:4:"icon";s:8:"question";s:8:"icon_url";s:66:"https://biology-forums.com/Themes/default/images/post/question.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841997.0";s:4:"link";s:166:"&lt;a href="https://biology-forums.com/index.php?topic=1841997.0"&gt;In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...&lt;/a&gt;";s:7:"tooltip";s:604:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation results in zhi xiao which is the Chinese term for "illegal pyramid marketing schemes." To counteract the negative connotation, Dell\'s sales representatives began using the phrase zhi xiao ding gou, which translates as:&lt;br /&gt;A) direct orders.&lt;br /&gt;B) direct marketing.&lt;br /&gt;C) pyramid orders.&lt;br /&gt;D) pyram&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705949";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695026;s:7:"subject";s:99:"In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...";s:7:"preview";s:59:"Really saved me for my test lol. This was a good refresher.";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841997.msg4705949#msg4705949";s:4:"link";s:201:"&lt;a href="https://biology-forums.com/index.php?topic=1841997.msg4705949#msg4705949" rel="nofollow"&gt;In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841997.msg4705949#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841997.msg4705949new";s:4:"link";s:201:"&lt;a href="https://biology-forums.com/index.php?topic=1841997.msg4705949#msg4705949" rel="nofollow"&gt;In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:8:"question";s:8:"icon_url";s:66:"https://biology-forums.com/Themes/default/images/post/question.gif";s:7:"subject";s:99:"In China, Dell had to find a meaningful interpretation of "direct sales." A literal translation ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"2";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:441;}i:1841996;a:22:{s:2:"id";s:7:"1841996";s:10:"first_post";a:11:{s:2:"id";s:7:"4705943";s:6:"member";a:4:{s:4:"name";s:5:"derro";s:2:"id";s:6:"815703";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815703";s:4:"link";s:80:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815703"&gt;derro&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695007;s:7:"subject";s:102:"Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...";s:7:"preview";s:131:"Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they used the phrase "light beer" ...";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841996.0";s:4:"link";s:169:"&lt;a href="https://biology-forums.com/index.php?topic=1841996.0"&gt;Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...&lt;/a&gt;";s:7:"tooltip";s:519:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they used the phrase "light beer" which was misinterpreted as:&lt;br /&gt;A) being low in calories.&lt;br /&gt;B) having reduced alcohol levels.&lt;br /&gt;C) having light color.&lt;br /&gt;D) having less quality.&lt;br /&gt;E) having less quantity.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705946";s:6:"member";a:4:{s:4:"name";s:9:"proshendo";s:2:"id";s:6:"815706";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815706";s:4:"link";s:84:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815706"&gt;proshendo&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529695007;s:7:"subject";s:102:"Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...";s:7:"preview";s:19:"You&amp;#039;re welcome";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841996.msg4705946#msg4705946";s:4:"link";s:204:"&lt;a href="https://biology-forums.com/index.php?topic=1841996.msg4705946#msg4705946" rel="nofollow"&gt;Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841996.msg4705946#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841996.msg4705946new";s:4:"link";s:204:"&lt;a href="https://biology-forums.com/index.php?topic=1841996.msg4705946#msg4705946" rel="nofollow"&gt;Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:102:"Anheuser-Busch and Miller Brewing both experienced market failures in the United Kingdom when they ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"3";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:496;}i:1841995;a:22:{s:2:"id";s:7:"1841995";s:10:"first_post";a:11:{s:2:"id";s:7:"4705939";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529694996;s:7:"subject";s:103:"Linguists have divided the study of languages into four main areas. The system of word formation is ...";s:7:"preview";s:131:"Linguists have divided the study of languages into four main areas. The system of word formation is referred to as:A) syntax.B) ...";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841995.0";s:4:"link";s:170:"&lt;a href="https://biology-forums.com/index.php?topic=1841995.0"&gt;Linguists have divided the study of languages into four main areas. The system of word formation is ...&lt;/a&gt;";s:7:"tooltip";s:415:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;Linguists have divided the study of languages into four main areas. The system of word formation is ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;Linguists have divided the study of languages into four main areas. The system of word formation is referred to as:&lt;br /&gt;A) syntax.&lt;br /&gt;B) phonology.&lt;br /&gt;C) morphology.&lt;br /&gt;D) semantics.&lt;br /&gt;E) semiotics.&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705942";s:6:"member";a:4:{s:4:"name";s:7:"freshco";s:2:"id";s:6:"815705";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815705";s:4:"link";s:82:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815705"&gt;freshco&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529694996;s:7:"subject";s:103:"Linguists have divided the study of languages into four main areas. The system of word formation is ...";s:7:"preview";s:75:" Sure. But make sure you mark the topic solved, it hides it from other eyes";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841995.msg4705942#msg4705942";s:4:"link";s:205:"&lt;a href="https://biology-forums.com/index.php?topic=1841995.msg4705942#msg4705942" rel="nofollow"&gt;Linguists have divided the study of languages into four main areas. The system of word formation is ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841995.msg4705942#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841995.msg4705942new";s:4:"link";s:205:"&lt;a href="https://biology-forums.com/index.php?topic=1841995.msg4705942#msg4705942" rel="nofollow"&gt;Linguists have divided the study of languages into four main areas. The system of word formation is ...&lt;/a&gt;";s:9:"is_sticky";b:0;s:9:"is_locked";b:0;s:7:"is_poll";b:0;s:6:"is_hot";b:0;s:11:"is_very_hot";b:0;s:12:"is_posted_in";b:0;s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:7:"subject";s:103:"Linguists have divided the study of languages into four main areas. The system of word formation is ...";s:5:"pages";s:0:"";s:7:"replies";s:1:"3";s:5:"views";s:1:"1";s:5:"board";a:4:{s:2:"id";s:2:"82";s:4:"name";s:9:"Marketing";s:4:"href";s:47:"https://biology-forums.com/index.php?board=82.0";s:4:"link";s:71:"&lt;a href="https://biology-forums.com/index.php?board=82.0"&gt;Marketing&lt;/a&gt;";}s:5:"class";s:0:"";s:14:"extended_class";R:551;}i:1841994;a:22:{s:2:"id";s:7:"1841994";s:10:"first_post";a:11:{s:2:"id";s:7:"4705936";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529694976;s:7:"subject";s:100:"As cultural differences become less relevant and disposable incomes become high, a trend towards ...";s:7:"preview";s:131:"As cultural differences become less relevant and disposable incomes become high, a trend towards greater consumption of the foll...";s:4:"icon";s:6:"accept";s:8:"icon_url";s:64:"https://biology-forums.com/Themes/default/images/post/accept.gif";s:4:"href";s:52:"https://biology-forums.com/index.php?topic=1841994.0";s:4:"link";s:167:"&lt;a href="https://biology-forums.com/index.php?topic=1841994.0"&gt;As cultural differences become less relevant and disposable incomes become high, a trend towards ...&lt;/a&gt;";s:7:"tooltip";s:507:"&lt;div class="tooltip_container"&gt;&lt;div class="tooltip_caption"&gt;As cultural differences become less relevant and disposable incomes become high, a trend towards ...&lt;/div&gt;&lt;div class="tooltip_body"&gt;As cultural differences become less relevant and disposable incomes become high, a trend towards greater consumption of the following type of foods is predicted.&lt;br /&gt;A) French artistic foods&lt;br /&gt;B) American fast foods&lt;br /&gt;C) Chinese retail foods&lt;br /&gt;D) Indian spicy foods&lt;br /&gt;E) Mexican spicy foods&lt;/div&gt;&lt;/div&gt;";}s:9:"last_post";a:10:{s:2:"id";s:7:"4705938";s:6:"member";a:4:{s:4:"name";s:8:"logiol22";s:2:"id";s:6:"815704";s:4:"href";s:60:"https://biology-forums.com/index.php?action=profile;u=815704";s:4:"link";s:83:"&lt;a href="https://biology-forums.com/index.php?action=profile;u=815704"&gt;logiol22&lt;/a&gt;";}s:4:"time";s:11:"3 hours ago";s:9:"timestamp";i:1529694976;s:7:"subject";s:100:"As cultural differences become less relevant and disposable incomes become high, a trend towards ...";s:7:"preview";s:135:"I&amp;#39;ve been struggling with this concept and going into a mild panic attack due to having an exam on this in the morning. Really w...";s:4:"icon";s:2:"xx";s:8:"icon_url";s:60:"https://biology-forums.com/Themes/default/images/post/xx.gif";s:4:"href";s:72:"https://biology-forums.com/index.php?topic=1841994.msg4705938#msg4705938";s:4:"link";s:202:"&lt;a href="https://biology-forums.com/index.php?topic=1841994.msg4705938#msg4705938" rel="nofollow"&gt;As cultural differences become less relevant and disposable incomes become high, a trend towards ...&lt;/a&gt;";}s:6:"is_new";b:1;s:8:"new_href";s:65:"https://biology-forums.com/index.php?topic=1841994.msg4705938#new";s:4:"href";s:64:"https://biology-forums.com/index.php?topic=1841994.msg4705938new";s:4:"link";s:202:"&lt;a href="https://biology-forums.com/index.php?topic=1841994.msg4705938#msg4705938" rel="nofollow"&gt;As cultural differences become less relevant and disposable incomes become high, a trend towards ...

However, how come it renews after each refresh? That's what's bugging me.

Arantor

Hmm. I did initially wonder if you had something broken, as the indentation was mangled, but once I'd normalised it, I had to look again.

I see the comparison to null only has two equals signs, try using three. Comparisons to null need to be type-safe comparisons because of the way PHP does type juggling.

vbgamer45

Hmm Arantor i think then SMF need some  updates on that as 2.1 and 2.0.x still have a bunch of calls only using two ==

if (($temp = cache_get_data('posting_smileys', 480)) == null)
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

Under most circumstances it shouldn't matter and it should get it right anyway. But there are circumstances where it will get it wrong - this *shouldn't* be one of them, but I want to eliminate things.

Biology Forums

#11
You're definitely right about the triple ===. I made the change you suggested, so that it looks like this:

// Let's cache the results to load faster...
if (($temp = cache_get_data('latest_topics_list', 480)) === null)
{

$request = db_query("
SELECT $select_clause
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}messages AS ml ON (ml.ID_MSG = t.ID_LAST_MSG)
INNER JOIN {$db_prefix}messages AS mso ON (mso.ID_MSG = t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = ml.ID_BOARD)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = ml.ID_TOPIC AND lt.ID_MEMBER = " . $ID_MEMBER .")
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = " . $ID_MEMBER .")
WHERE t." . $query_this_board . "
AND t.ID_LAST_MSG >= " . $min_message ." ".$time_frame."
ORDER BY " . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') ."
LIMIT $_REQUEST[start], $modSettings[defaultMaxTopics]", __FILE__, __LINE__);

$context['topics'] = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// * NiceTooltips mod
$row['nice_tooltip_first_msg'] = NiceTooltip($row['first_body'], $row['first_subject'], $row['first_smileys'], $row['ID_FIRST_MSG']);

// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['ID_FIRST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['first_body']) > 128)
$row['first_body'] = $func['substr']($row['first_body'], 0, 128) . '...';
$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['ID_LAST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['last_body']) > 128)

$row['last_body'] = $func['substr']($row['last_body'], 0, 128) . '...';

// Censor the subject and message preview.
censorText($row['first_subject']);
censorText($row['first_body']);

// Don't censor them twice!
if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['last_subject'] = $row['first_subject'];
$row['last_body'] = $row['first_body'];
}
else
{
censorText($row['last_subject']);
censorText($row['last_body']);
}

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . '">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . implode('', $tmppages);
// Or skip a few?
else
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . $tmppages[0] . $tmppages[1] . '...' . $tmppages[count($tmppages) - 2] . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '&nbsp;<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt['190'] . '</a>';
$pages .= '';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($context['icon_sources'][$row['first_icon']]))
$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($context['icon_sources'][$row['last_icon']]))
$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$context['topics'][$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['id_msg_first'],
'member' => array(
'name' => $row['first_poster_name'],
'id' => $row['id_first_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'],
'link' => ($row['id_first_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name'],
),
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['first_subject'] . '</a>',
'tooltip' => $row['nice_tooltip_first_msg'],
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['last_poster_name'],
'id' => $row['id_last_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'],
'link' => ($row['id_last_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name'], ),
'time' => timeformat($row['last_poster_time']),
'timestamp' => forum_time(true, $row['last_poster_time']),
'subject' => $row['last_subject'],
'preview' => $row['last_body'],
'icon' => $row['last_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'
),
'is_new' => $row['is_new'] && !$user_info['is_guest'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '#msg' . $row['ID_MSG'] . '" rel="nofollow">' . $row['first_subject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'subject' => $row['first_subject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
)
);

determineTopicClass($context['topics'][$row['ID_TOPIC']]);
}

mysql_free_result($request);

if (!empty($modSettings['cache_enable']))
cache_put_data('latest_topics_list', $context['topics'], 480);
}
else
$context['topics'] = $temp;


However, I sometimes get the following message. I also checked the logs, and it's there.

:-\ What's going on here?

Arantor

Well, here it's pretty straightforward, you don't put anything into the array to be cached in the first place...

Biology Forums

I updated my post a few times while you were responding. Currently I have everything cached, including the array. Should I only cache $request?

Arantor

Eh? You can't cache the actual request object.

Cache only the array that gets built at the end of it.

Biology Forums

I don't see how this helps with performance. Isn't the SQL query the one that uses up memory and CPU?

BTW, is this what you're referring to?

if (($temp = cache_get_data('latest_topics', 480)) === null)
{

// And build the array.
$context['topics'][$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['id_msg_first'],
'member' => array(
'name' => $row['first_poster_name'],
'id' => $row['id_first_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'],
'link' => ($row['id_first_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name'],
),
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['first_subject'] . '</a>',
'tooltip' => $row['nice_tooltip_first_msg'],
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['last_poster_name'],
'id' => $row['id_last_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'],
'link' => ($row['id_last_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name'], ),
'time' => timeformat($row['last_poster_time']),
'timestamp' => forum_time(true, $row['last_poster_time']),
'subject' => $row['last_subject'],
'preview' => $row['last_body'],
'icon' => $row['last_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'
),
'is_new' => $row['is_new'] && !$user_info['is_guest'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '#msg' . $row['ID_MSG'] . '" rel="nofollow">' . $row['first_subject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'subject' => $row['first_subject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
)
);

determineTopicClass($context['topics'][$row['ID_TOPIC']]);

if (!empty($modSettings['cache_enable']))
cache_put_data('latest_topics', $context['topics'][$row['ID_TOPIC']], 480);
}
else
$context['topics'][$row['ID_TOPIC']] = $temp;

vbgamer45

Your original was ok just need tweaks
Remove

else
$context['topics'] = $temp;


Change


if (($temp = cache_get_data('latest_topics_list', 480)) === null)

To


if (($context['topics'] = cache_get_data('latest_topics_list', 480)) === null)
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

-sigh- NO.

You do the query, you fetch all the data from it, you process it into an array and then you save the array into the cache. Like everywhere else in SMF.

You can't save the query directly because in reality all you actually get back when you run db_query() (or $smcFunc['db_query']) is a reference that tells PHP where in memory the data actually is when it came from MySQL. Saving that value means nothing because the time you come to retrieve it from the cache, it won't be in memory any more.

So you have to fetch all the rows into something, and if you're doing that, you might as well put them into the array you're actually going to use next time, i.e. $context['topics']. The actual mechanics under the hood are a lot more complicated than this involving when the data is sent from MySQL to PHP (because it doesn't have to be sent all in one go though it usually is) but whatever, you still can't save the actual query itself.

Maybe if you don't understand how it works, you should leave it alone.

@vbgamer: Not sure that would make a difference - if the cache got something, it would be put into $temp and later into $context['topics'], and if it didn't, $context['topics'] would be populated anyway.

Biology Forums

@vbgamer: I still see topics being updated before 480 seconds... (see attachment)

The way I understood it before was if the query had been cached before (with 480 seconds, in my case), caching it would prevent it from being activated again to save CPU and memory. I looked at some examples that SMF uses in Subs.php, and I found that it incorporates the SQL part.

In Subs.php:
if (($postgroups = cache_get_data('updateStats:postgroups', 360)) == null)
{
// Fetch the postgroups!
$request = db_query("
SELECT ID_GROUP, minPosts
FROM {$db_prefix}membergroups
WHERE minPosts != -1", __FILE__, __LINE__);
$postgroups = array();
while ($row = mysql_fetch_assoc($request))
$postgroups[$row['ID_GROUP']] = $row['minPosts'];
mysql_free_result($request);

// Sort them this way because if it's done with MySQL it causes a filesort :(.
arsort($postgroups);

cache_put_data('updateStats:postgroups', $postgroups, 360);
}

// Oh great, they've screwed their post groups.
if (empty($postgroups))
return;


Could you explain this?

Arantor

Yes, it incorporates the SQL part - but it *also* incorporates the processing AFTER the SQL part, you know, after it's actually got all the data and put it into an array so PHP can actually use it.

I'm still not sure what your attachment means to show - though if it's legitimately returning an empty list, that would certainly fail on the == (not ===) comparison to null and assume it needs to refetch it.

Biology Forums

When $context['topics'] is empty, that's what it's programmed to show.

if (empty($context['topics']))
echo 'No messages';


I'm not sure why the darn thing isn't working the way I want it to work since I did exactly what @vbgamer said.

// Let's cache the results to load faster...
if (($context['topics'] = cache_get_data('latest_topics', 25)) === null)
{

$request = db_query("
SELECT $select_clause
FROM {$db_prefix}topics AS t
INNER JOIN {$db_prefix}messages AS ml ON (ml.ID_MSG = t.ID_LAST_MSG)
INNER JOIN {$db_prefix}messages AS mso ON (mso.ID_MSG = t.ID_FIRST_MSG)
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = ml.ID_BOARD)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = ml.ID_TOPIC AND lt.ID_MEMBER = " . $ID_MEMBER .")
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = " . $ID_MEMBER .")
WHERE t." . $query_this_board . "
AND t.ID_LAST_MSG >= " . $min_message ." ".$time_frame."
ORDER BY " . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') ."
LIMIT $_REQUEST[start], $modSettings[defaultMaxTopics]", __FILE__, __LINE__);

$context['topics'] = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// * NiceTooltips mod
$row['nice_tooltip_first_msg'] = NiceTooltip($row['first_body'], $row['first_subject'], $row['first_smileys'], $row['ID_FIRST_MSG']);

// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['ID_FIRST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['first_body']) > 128)
$row['first_body'] = $func['substr']($row['first_body'], 0, 128) . '...';
$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['ID_LAST_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['last_body']) > 128)

$row['last_body'] = $func['substr']($row['last_body'], 0, 128) . '...';

// Censor the subject and message preview.
censorText($row['first_subject']);
censorText($row['first_body']);

// Don't censor them twice!
if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['last_subject'] = $row['first_subject'];
$row['last_body'] = $row['first_body'];
}
else
{
censorText($row['last_subject']);
censorText($row['last_body']);
}

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . '">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . implode('', $tmppages);
// Or skip a few?
else
$pages = '<img style="vertical-align: middle;" src="'.$settings['default_theme_url'].'/images/page-small.png"> ' . $tmppages[0] . $tmppages[1] . '...' . $tmppages[count($tmppages) - 2] . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '&nbsp;<a style="margin: 0 1px;" href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt['190'] . '</a>';
$pages .= '';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($context['icon_sources'][$row['first_icon']]))
$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($context['icon_sources'][$row['last_icon']]))
$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$context['topics'][$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['id_msg_first'],
'member' => array(
'name' => $row['first_poster_name'],
'id' => $row['id_first_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'],
'link' => ($row['id_first_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name'],
),
'time' => timeformat($row['first_poster_time']),
'timestamp' => forum_time(true, $row['first_poster_time']),
'subject' => $row['first_subject'],
'preview' => $row['first_body'],
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['first_subject'] . '</a>',
'tooltip' => $row['nice_tooltip_first_msg'],
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['last_poster_name'],
'id' => $row['id_last_member'],
'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'],
'link' => ($row['id_last_member'] != 0) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name'], ),
'time' => timeformat($row['last_poster_time']),
'timestamp' => forum_time(true, $row['last_poster_time']),
'subject' => $row['last_subject'],
'preview' => $row['last_body'],
'icon' => $row['last_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#msg' . $row['ID_LAST_MSG'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'
),
'is_new' => $row['is_new'] && !$user_info['is_guest'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_MSG']) . '#msg' . $row['ID_MSG'] . '" rel="nofollow">' . $row['first_subject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['first_icon'],
'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
'subject' => $row['first_subject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
)
);

determineTopicClass($context['topics'][$row['ID_TOPIC']]);
}

mysql_free_result($request);

if (!empty($modSettings['cache_enable']))
cache_put_data('latest_topics', $context['topics'], 25);
}


When I delete the cache from APC it works for that amount of time, set to 25 secs, then the message thereafter appears.

Arantor

And as I pointed out, what vbgamer suggested would have made no difference.

So, here's the $64,000 question: how about you var_dump *exactly* what is being cached just before it is cached? I rather suspect what is getting put into the cache is not the value you think it is.

Biology Forums

Thanks for the idea, it dumped exactly what the array creates, and it's huge. Here's a truncated version of it of the dump looks like. This is *without* the caching.

[1842378]=>
  array(22) {
    ["id"]=>
    string(7) "1842378"
    ["first_post"]=>
    array(11) {
      ["id"]=>
      string(7) "4707234"
      ["member"]=>
      array(4) {
        ["name"]=>
        string(5) "derro"
        ["id"]=>
        string(6) "815703"
        ["href"]=>
        string(60) "https://biology-forums.com/index.php?action=profile;u=815703"
        ["link"]=>
        string(80) "derro"
      }
      ["time"]=>
      string(11) "An hour ago"
      ["timestamp"]=>
      int(1529773707)
      ["subject"]=>
      string(95) "Products that belong to the category of "game changers" are considered as ________ innovations."
      ["preview"]=>
      string(131) "Products that belong to the category of "game changers" are considered as ________ innovations.A) new productB) line extensionsC..."
      ["icon"]=>
      string(6) "accept"
      ["icon_url"]=>
      string(64) "https://biology-forums.com/Themes/default/images/post/accept.gif"
      ["href"]=>
      string(52) "https://biology-forums.com/index.php?topic=1842378.0"
      ["link"]=>
      string(162) "Products that belong to the category of "game changers" are considered as ________ innovations."
      ["tooltip"]=>
      string(410) "
Products that belong to the category of "game changers" are considered as ________ innovations.
Products that belong to the category of "game changers" are considered as ________ innovations.
A) new product
B) line extensions
C) continuous
D) dynamically continuous
E) discontinuous
"
    }
    ["last_post"]=>
    array(10) {
      ["id"]=>
      string(7) "4707240"
      ["member"]=>
      array(4) {
        ["name"]=>
        string(9) "proshendo"
        ["id"]=>
        string(6) "815706"
        ["href"]=>
        string(60) "https://biology-forums.com/index.php?action=profile;u=815706"
        ["link"]=>
        string(84) "proshendo"
      }
      ["time"]=>
      string(11) "An hour ago"
      ["timestamp"]=>
      int(1529773707)
      ["subject"]=>
      string(95) "Products that belong to the category of "game changers" are considered as ________ innovations."
      ["preview"]=>
      string(15) "Ma pleasure... "
      ["icon"]=>
      string(2) "xx"
      ["icon_url"]=>
      string(60) "https://biology-forums.com/Themes/default/images/post/xx.gif"
      ["href"]=>
      string(72) "https://biology-forums.com/index.php?topic=1842378.msg4707240#msg4707240"
      ["link"]=>
      string(197) "Products that belong to the category of "game changers" are considered as ________ innovations."
    }
    ["is_new"]=>
    bool(true)
    ["new_href"]=>
    string(65) "https://biology-forums.com/index.php?topic=1842378.msg4707240#new"
    ["href"]=>
    string(64) "https://biology-forums.com/index.php?topic=1842378.msg4707240new"
    ["link"]=>
    string(197) "Products that belong to the category of "game changers" are considered as ________ innovations."
    ["is_sticky"]=>
    bool(false)
    ["is_locked"]=>
    bool(false)
    ["is_poll"]=>
    bool(false)
    ["is_hot"]=>
    bool(false)
    ["is_very_hot"]=>
    bool(false)
    ["is_posted_in"]=>
    bool(false)
    ["icon"]=>
    string(6) "accept"
    ["icon_url"]=>
    string(64) "https://biology-forums.com/Themes/default/images/post/accept.gif"
    ["subject"]=>
    string(95) "Products that belong to the category of "game changers" are considered as ________ innovations."
    ["pages"]=>
    string(0) ""
    ["replies"]=>
    string(1) "3"
    ["views"]=>
    string(1) "0"
    ["board"]=>
    array(4) {
      ["id"]=>
      string(2) "82"
      ["name"]=>
      string(9) "Marketing"
      ["href"]=>
      string(47) "https://biology-forums.com/index.php?board=82.0"
      ["link"]=>
      string(71) "Marketing"
    }
    ["class"]=>
    &string(0) ""
    ["extended_class"]=>
    &string(0) ""
  }


On the contrary, when "No Messages" appears, it dumps nothing, as suspected.

Arantor

So that's the array that's getting put into the cache_put_data() call, right?

Next question: what's the value of $modSettings['cache_enable'] ?


Arantor

OK, so you've verified what the cache puts in when it does so, and you've checked it actually hits APC.

Now, let's try another interesting test. Move the $temp = cache_get_data(...) outside of the if so it runs every time (and change the if to if($temp === null) or whatever it's currently called, I gave up trying to follow what you've been doing to it)... then before the if starts, var_dump what you get out of the function.

GigaWatt

So this is what debugging in PHP looks like, huh :). Not that different from software debugging.

Can break points be added?

@Study Force: Sorry for asking and kind of ruining the topic :-\.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Arantor

Breakpoints? On a development server, sure, XDebug has all that, just need an IDE that can point to it - Eclipse for example.

If you're not on a development server, debug by spitting out all the variables is the way to do it.

Of course it's not that different from software debugging... it's EXACTLY software debugging, seeing how PHP is Turing complete and therefore qualifies as a proper language.

GigaWatt

Hmmm... thanks for the info ;).

It's kind of hard when you're tweaking stuff and something goes wrong and you have no idea what actually did go wrong :D.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Biology Forums

I did as you said:

$temp = cache_get_data('latest_topics', 480);

var_dump($temp);

// Let's cache the results to load faster...
if ($temp === null)
{

$request = db_query("
SELECT $select_clause
FROM {$db_prefix}topics AS t ...


I get bool(false) when I var_dump $temp.

@GigaWatt: It's fine.

Arantor

Interesting.

The cache routines, assuming unmodified, return null on cache miss, so it looks like you're trying to cache a value that can't be cached, or that you're caching false...


Advertisement: