Skip to content

Commit

Permalink
Issue backdrop-contrib#42: Prevent broken settings page by any arbitr…
Browse files Browse the repository at this point in the history
…ary entity.
  • Loading branch information
Jen Lampton committed May 23, 2018
1 parent 119d4f0 commit ca323ee
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
7 changes: 2 additions & 5 deletions xmlsitemap.module
Expand Up @@ -895,11 +895,8 @@ function xmlsitemap_get_link_info($type = NULL, $reset = FALSE) {
}
else {
entity_info_cache_clear();
$link_info = array_merge(entity_get_info(), module_invoke_all('xmlsitemap_link_info'));
// Remove the entity types we know we don't want to support.
// @todo maybe
unset($link_info['file']);
unset($link_info['comment']);
// Only include the entity types we know we want to support.
$link_info = module_invoke_all('xmlsitemap_link_info');
foreach ($link_info as $key => &$info) {
$info += array(
'type' => $key,
Expand Down
4 changes: 3 additions & 1 deletion xmlsitemap.xmlsitemap.inc
Expand Up @@ -218,14 +218,16 @@ class XMLSitemapIndexWriter extends XMLSitemapWriter {
* Implements hook_xmlsitemap_link_info().
*/
function xmlsitemap_xmlsitemap_link_info() {
return array(
$info = array(
'frontpage' => array(
'label' => t('Frontpage'),
'xmlsitemap' => array(
'settings callback' => 'xmlsitemap_link_frontpage_settings',
),
),
);

return $info;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions xmlsitemap_node/xmlsitemap_node.module
Expand Up @@ -25,6 +25,19 @@ function xmlsitemap_node_entity_info_alter(array &$entity_info) {
);
}

/**
* Implements hook_xmlsitemap_link_info().
*/
function xmlsitemap_node_xmlsitemap_link_info() {
$info = array();
$entity_info = entity_get_info();
if (isset($entity_info['node'])) {
$info['node'] = $entity_info['node'];
}

return $info;
}

/**
* Implements hook_cron().
*
Expand Down
15 changes: 14 additions & 1 deletion xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
Expand Up @@ -24,6 +24,20 @@ function xmlsitemap_taxonomy_entity_info_alter(&$entity_info) {
);
}

/**
* Implements hook_xmlsitemap_link_info().
*/
function xmlsitemap_taxonomy_xmlsitemap_link_info() {
$info = array();
$entity_info = entity_get_info();
if (isset($entity_info['taxonomy_term'])) {
$info['taxonomy_term'] = $entity_info['taxonomy_term'];
}

return $info;
}


/**
* Implements hook_xmlsitemap_link_info_alter().
*/
Expand Down Expand Up @@ -244,4 +258,3 @@ function xmlsitemap_taxonomy_get_node_count($term) {
// @todo Use db_rewrite_sql() w/ switch user.
return db_query_range("SELECT COUNT(ti.nid) FROM {taxonomy_index} ti LEFT JOIN {node n} USING (nid) WHERE ti.tid = :tid AND n.status = 1", 0, 1, array(':tid' => $term->tid))->fetchField();
}

13 changes: 13 additions & 0 deletions xmlsitemap_user/xmlsitemap_user.module
Expand Up @@ -24,6 +24,19 @@ function xmlsitemap_user_entity_info_alter(&$entity_info) {
);
}

/**
* Implements hook_xmlsitemap_link_info().
*/
function xmlsitemap_user_xmlsitemap_link_info() {
$info = array();
$entity_info = entity_get_info();
if (isset($entity_info['user'])) {
$info['user'] = $entity_info['user'];
}

return $info;
}

/**
* Implements hook_cron().
*
Expand Down

0 comments on commit ca323ee

Please sign in to comment.