My son progess:

Lilypie Second Birthday tickers

Monday, January 25, 2010

Syntax error or cache memory error..??



Last saturday I received text from Toroy to mention that one of our website produced an error message:
user warning: Unknown table 'term_node_6' in field list query: SELECT DISTINCT(node.nid), node.title AS node_title, bla..bla..bla..

So, I thought it was such a normal linking error from database and I give it a try to recover but I still couldn't found any error from it, so strange.

Normally, this kind of error definitely came from database which is some of tables have been removed without updating in the website. Since it happened in weekend I don't have much time to concentrate at that problem until I return back at office today and give it one more try, voila! It working like a charm..

After investigating all the problems occur, I was thinking to give a try to dump all the caches by creating custom Drupal script since there was no error at all because Drupal are known as running on full database.
So sometimes cache slip could be a reason too, here's the Drupal based clear cache script:

// only allow site administrators to visit this page:
if (!user_access('administer site configuration')) {
  drupal_not_found();
}
elseif ($user->roles[6]) {
  drupal_clear_css_cache();
  $tables = array(
    'cache',
    'cache_content',
    'cache_filter',
    'cache_menu',
    'cache_page',
    'cache_views',
  );
  foreach ($tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  drupal_set_message('Cache cleared.');
  drupal_goto();
}
else {
  drupal_clear_css_cache();
  $tables = array(
    'cache',
    'cache_content',
    'cache_filter',
    'cache_menu',
    'cache_page',
    'cache_views',
  );
  foreach ($tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  drupal_set_message('Cache cleared.');
  drupal_goto();
}
?>


and named it as "clear-cache.php" so it will be "http://www.yourwebsite.com/clear-cache.php"
run that script, voila! It dump all the caches which sometimes so "irritating" from developer point of view.. :)

No comments:

Post a Comment

Related Posts with Thumbnails