Commit c55eebdf authored by Dave Reid's avatar Dave Reid

Issue #1147212 by neclimdul, Dave Reid: Fixed excessive cache_get() calls and...

Issue #1147212 by neclimdul, Dave Reid: Fixed excessive cache_get() calls and PHP notices if entity_info_cache_clear() is not called prior to entity_get_info().
parent 1eb0b167
......@@ -908,48 +908,52 @@ function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
if ($reset) {
$link_info = NULL;
entity_info_cache_clear();
}
elseif ($cached = cache_get('xmlsitemap:link_info:' . $language->language)) {
$link_info = $cached->data;
cache_clear_all('xmlsitemap:link_info:', 'cache', TRUE);
}
if (!isset($link_info)) {
$link_info = entity_get_info();
foreach ($link_info as $key => $info) {
if (empty($info['uri callback']) || !isset($info['xmlsitemap'])) {
// Remove any non URL-able or XML sitemap un-supported entites.
unset($link_info[$key]);
}
foreach ($info['bundles'] as $bundle_key => $bundle) {
if (!isset($bundle['xmlsitemap'])) {
// Remove any un-supported entity bundles.
//unset($link_info[$key]['bundles'][$bundle_key]);
}
}
$cid = 'xmlsitemap:link_info:' . $language->language;
if ($cache = cache_get($cid)) {
$link_info = $cache->data;
}
$link_info = array_merge($link_info, module_invoke_all('xmlsitemap_link_info'));
foreach ($link_info as $key => &$info) {
$info += array(
'type' => $key,
'base table' => FALSE,
'bundles' => array(),
'xmlsitemap' => array(),
);
if (!isset($info['xmlsitemap']['rebuild callback']) && !empty($info['base table']) && !empty($info['entity keys']['id']) && !empty($info['xmlsitemap']['process callback'])) {
$info['xmlsitemap']['rebuild callback'] = 'xmlsitemap_rebuild_batch_fetch';
else {
entity_info_cache_clear();
$link_info = entity_get_info();
foreach ($link_info as $key => $info) {
if (empty($info['uri callback']) || !isset($info['xmlsitemap'])) {
// Remove any non URL-able or XML sitemap un-supported entites.
unset($link_info[$key]);
}
foreach ($info['bundles'] as $bundle_key => $bundle) {
if (!isset($bundle['xmlsitemap'])) {
// Remove any un-supported entity bundles.
//unset($link_info[$key]['bundles'][$bundle_key]);
}
}
}
foreach ($info['bundles'] as $bundle => &$bundle_info) {
$bundle_info += array(
$link_info = array_merge($link_info, module_invoke_all('xmlsitemap_link_info'));
foreach ($link_info as $key => &$info) {
$info += array(
'type' => $key,
'base table' => FALSE,
'bundles' => array(),
'xmlsitemap' => array(),
);
$bundle_info['xmlsitemap'] += xmlsitemap_link_bundle_load($key, $bundle, FALSE);
if (!isset($info['xmlsitemap']['rebuild callback']) && !empty($info['base table']) && !empty($info['entity keys']['id']) && !empty($info['xmlsitemap']['process callback'])) {
$info['xmlsitemap']['rebuild callback'] = 'xmlsitemap_rebuild_batch_fetch';
}
foreach ($info['bundles'] as $bundle => &$bundle_info) {
$bundle_info += array(
'xmlsitemap' => array(),
);
$bundle_info['xmlsitemap'] += xmlsitemap_link_bundle_load($key, $bundle, FALSE);
}
}
drupal_alter('xmlsitemap_link_info', $link_info);
ksort($link_info);
// Cache by language since this info contains translated strings.
cache_set($cid, $link_info);
}
drupal_alter('xmlsitemap_link_info', $link_info);
ksort($link_info);
// Cache by language since this info contains translated strings.
cache_set('xmlsitemap:link_info:' . $language->language, $link_info);
}
if (isset($type)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment