the file url_rewrite.php which has the function cache_url() has a problem when it works. Here is the code:
function cache_url() {
global $refresh;
// Read cache is part of the built in OSC cache fucntion
if (($refresh == true) || !read_cache($url_array, 'url.cache')) {
// Adds the categories to the URL array
$categories_query = tep_db_query("select categories_id, categories_name from " . TABLE_CATEGORIES_DESCRIPTION);
while ($categories = tep_db_fetch_array($categories_query)) {
$url_array[$this->encrypt_url($categories['categories_name'])] = array('key' => 'categories_id', 'value' => $categories['categories_id']);
}
// Adds the manufacturers to the URL array
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS);
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$url_array[$this->encrypt_url($manufacturers['manufacturers_name'])] = array('key' => 'manufacturers_id', 'value' => $manufacturers['manufacturers_id']);
}
// Adds the products to the URL array
$products_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION);
while ($products = tep_db_fetch_array($products_query)) {
$url_array[$this->encrypt_url($products['products_name'])] = array('key' => 'products_id', 'value' => $products['products_id']);
}
// Write cache is part of the built in OSC cache fucntion
write_cache($url_array, 'url.cache');
}
return $url_array;
}
Follow the logic: if $refresh were true , or read_cache($url_array, 'url.cache') return false, the code will regenerate a new cache. The problem is that on my local test server (using Windows XP OS), the read_cache($url_array, 'url.cache') always return false because the folder /tmp/ does not exist in Windows OS system, so the code always regenerate a new cache when I add a new product or new category. But on the running server (using Linux), the read_cache($url_array, 'url.cache') always return true, so that the code does not regenerate new cache. That means url_rewrite does not work with new products just added. The $refresh variable always is false.
I think I have to find a way to control the value of $refresh variable is that when I add a new product or new category its value is true to make the code regenerate new cache, then is false when regenerate task is done. .... But I dont know how to do it :(