Commit f54ee273 authored by Dave Reid's avatar Dave Reid

by Dave Reid: Synced API changes from Drupal 6.x-2.x branch.

parent a46d41b3
...@@ -409,28 +409,40 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla ...@@ -409,28 +409,40 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla
} }
/** /**
* Load a specific sitemap link. * Load sitemap links from the database.
* *
* @param $conditions * @param $conditions
* An array of values to match keyed by field. * An array of conditions on the {xmlsitemap} table in the form
* 'field' => $value.
* @return * @return
* An array representing the first sitemap link matching the conditions found. * An array of sitemap link arrays.
*
* @todo Convert to use $type and $id as parameters.
*/ */
function xmlsitemap_load_link(array $conditions) { function xmlsitemap_link_load_multiple(array $conditions = array()) {
$query = db_select('xmlsitemap', 'x'); $query = db_select('xmlsitemap', 'x');
$query->fields('x'); $query->fields('x');
foreach ($conditions as $field => $value) { foreach ($conditions as $field => $value) {
$query->condition($field, $value); $query->condition($field, $value);
} }
$query->range(0, 1);
$link = $query->execute()->fetchAssoc();
// Allow other modules to respond after loading the link. $links = $query->execute()->fetchAllAssoc();
//module_invoke_all('xmlsitemap_load_link', $link, $conditions, $args);
return $link; return $links;
}
/**
* Load a specific sitemap link from the database.
*
* @param $entity_type
* A string with the entity type.
* @param $entity_id
* An integer with the entity ID.
* @return
* A sitemap link (array) or FALSE if the conditions were not found.
*/
function xmlsitemap_link_load($entity_type, $entity_id) {
$link = xmlsitemap_link_load_multiple(array('type' => $entity_type, 'id' => $entity_id));
return $link ? reset($link) : FALSE;
} }
/** /**
...@@ -516,17 +528,36 @@ function xmlsitemap_update_links($updates = array(), $conditions = array()) { ...@@ -516,17 +528,36 @@ function xmlsitemap_update_links($updates = array(), $conditions = array()) {
} }
/** /**
* Delete one or more sitemap links. * Delete a specific sitemap link from the database.
* *
* If a visible sitemap link was deleted, this will automatically set the * If a visible sitemap link was deleted, this will automatically set the
* regenerate needed flag. * regenerate needed flag.
* *
* @param $entity_type
* A string with the entity type.
* @param $entity_id
* An integer with the entity ID.
* @return
* The number of links that were deleted.
*/
function xmlsitemap_link_delete($entity_type, $entity_id) {
$conditions = array('type' => $entity_type, 'id' => $entity_id);
return xmlsitemap_link_delete_multiple($conditions);
}
/**
* Delete multiple sitemap links from the database.
*
* If visible sitemap links were deleted, this will automatically set the
* regenerate needed flag.
*
* @param $conditions * @param $conditions
* An array of values to match keyed by field. * An array of conditions on the {xmlsitemap} table in the form
* 'field' => $value.
* @return * @return
* The number of links that were deleted. * The number of links that were deleted.
*/ */
function xmlsitemap_delete_link(array $conditions) { function xmlsitemap_link_delete_multiple(array $conditions) {
if (!variable_get('xmlsitemap_regenerate_needed', TRUE)) { if (!variable_get('xmlsitemap_regenerate_needed', TRUE)) {
_xmlsitemap_check_changed_links($conditions, array(), TRUE); _xmlsitemap_check_changed_links($conditions, array(), TRUE);
} }
...@@ -535,7 +566,6 @@ function xmlsitemap_delete_link(array $conditions) { ...@@ -535,7 +566,6 @@ function xmlsitemap_delete_link(array $conditions) {
foreach ($conditions as $field => $value) { foreach ($conditions as $field => $value) {
$query->condition($field, $value); $query->condition($field, $value);
} }
return $query->execute(); return $query->execute();
} }
...@@ -861,3 +891,27 @@ function xmlsitemap_language_load($language = LANGUAGE_NONE) { ...@@ -861,3 +891,27 @@ function xmlsitemap_language_load($language = LANGUAGE_NONE) {
return $languages[$language]; return $languages[$language];
} }
function xmlsitemap_get_link_type_indexed_status($entity_type, $bundle = '') {
$info = xmlsitemap_get_link_info($entity_type);
$status = array();
$indexed = db_select('xmlsitemap');
$indexed->condition('type', $entity_type);
$indexed->condition('subtype', $bundle);
$visible = $indexed;
$visible->condition('status', 1);
$visible->condition('access', 1);
$status['indexed'] = $indexed->countQuery()->execute();
$status['visible'] = $visible->countQuery()->execute();
$total = db_select($info['base table']);
$total->addField($info['object keys']['id']);
if (!empty($info['object keys']['bundle'])) {
$total->condition($info['object keys']['bundle'], $bundle);
}
$status['total'] = $total->countQuery()->execute();
return $status;
}
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
*/ */
class XMLSitemapTestHelper extends DrupalWebTestCase { class XMLSitemapTestHelper extends DrupalWebTestCase {
protected $admin_user; protected $admin_user;
protected $seen_ids = array();
function setUp() { function setUp() {
// Call parent::setUp() allowing test cases to pass further modules. // Call parent::setUp() allowing test cases to pass further modules.
...@@ -30,7 +31,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -30,7 +31,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
// Capture any (remaining) watchdog errors. // Capture any (remaining) watchdog errors.
$this->assertNoWatchdogErrors(); $this->assertNoWatchdogErrors();
// Reset the watchdog seen IDs for the next test run. // Reset the watchdog seen IDs for the next test run.
$this->getWatchdogMessages(array(), TRUE); $this->seen_ids = array();
parent::tearDown(); parent::tearDown();
} }
...@@ -178,12 +179,10 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -178,12 +179,10 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
* *
* @todo Add unit tests for this function. * @todo Add unit tests for this function.
*/ */
protected function getWatchdogMessages(array $conditions = array(), $reset = FALSE) { protected function getWatchdogMessages(array $conditions = array(), $exclude_seen = TRUE) {
static $seen_ids = array();
static $levels; static $levels;
if (!module_exists('dblog') || $reset) { if (!module_exists('dblog')) {
$seen_ids = array();
return; return;
} }
if (!isset($levels)) { if (!isset($levels)) {
...@@ -198,8 +197,8 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -198,8 +197,8 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
} }
$query->condition($field, $value); $query->condition($field, $value);
} }
if ($seen_ids) { if ($exclude_seen && $this->seen_ids) {
$query->condition('wid', $seen_ids, 'NOT IN'); $query->condition('wid', $this->seen_ids, 'NOT IN');
} }
$query->orderBy('timestamp', 'ASC'); $query->orderBy('timestamp', 'ASC');
$messages = $query->execute()->fetchAllAssoc('wid'); $messages = $query->execute()->fetchAllAssoc('wid');
...@@ -209,10 +208,10 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -209,10 +208,10 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
if (!is_array($message->variables)) { if (!is_array($message->variables)) {
$message->variables = array(); $message->variables = array();
} }
$message->text = $message->timestamp . ' - ' . $levels[$message->severity] . ' - ' . t($message->message, $message->variables); $message->text = $message->timestamp . ' - ' . $levels[$message->severity] . ' - ' . $message->type . ' - ' . t($message->message, $message->variables);
} }
$seen_ids = array_merge($seen_ids, array_keys($messages)); $this->seen_ids = array_merge($this->seen_ids, array_keys($messages));
return $messages; return $messages;
} }
...@@ -228,11 +227,11 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -228,11 +227,11 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
* Check that there were no watchdog errors or worse. * Check that there were no watchdog errors or worse.
*/ */
protected function assertNoWatchdogErrors() { protected function assertNoWatchdogErrors() {
$messages = $this->getWatchdogMessages(); $messages = $this->getWatchdogMessages(array(), FALSE);
$verbose = array(); $verbose = array();
foreach ($messages as $message) { foreach ($messages as $message) {
if (in_array($message->severity, array(WATCHDOG_EMERG, WATCHDOG_ALERT, WATCHDOG_CRITICAL, WATCHDOG_ERROR, WATCHDOG_WARNING))) { if (in_array($message->severity, array(WATCHDOG_EMERG, WATCHDOG_ALERT, WATCHDOG_CRITICAL, WATCHDOG_ERROR, WATCHDOG_WARNING)) && !in_array($message->wid, $this->seen_ids)) {
$this->fail($message->text); $this->fail($message->text);
} }
$verbose[] = $message->text; $verbose[] = $message->text;
......
...@@ -191,7 +191,7 @@ function xmlsitemap_custom_delete_link_form($form, &$form_state, array $link) { ...@@ -191,7 +191,7 @@ function xmlsitemap_custom_delete_link_form($form, &$form_state, array $link) {
function xmlsitemap_custom_delete_link_form_submit($form, &$form_state) { function xmlsitemap_custom_delete_link_form_submit($form, &$form_state) {
$link = $form_state['values']['link']; $link = $form_state['values']['link'];
xmlsitemap_delete_link(array('type' => 'custom', 'id' => $link['id'])); xmlsitemap_link_delete('custom', $link['id']);
drupal_set_message(t('The custom link for %loc has been deleted.', array('%loc' => $link['loc']))); drupal_set_message(t('The custom link for %loc has been deleted.', array('%loc' => $link['loc'])));
watchdog('xmlsitemap', 'The custom link for %loc has been deleted.', array('%loc' => $link['loc']), WATCHDOG_NOTICE); watchdog('xmlsitemap', 'The custom link for %loc has been deleted.', array('%loc' => $link['loc']), WATCHDOG_NOTICE);
$form_state['redirect'] = 'admin/config/search/xmlsitemap/custom'; $form_state['redirect'] = 'admin/config/search/xmlsitemap/custom';
......
...@@ -11,5 +11,5 @@ ...@@ -11,5 +11,5 @@
*/ */
function xmlsitemap_custom_uninstall() { function xmlsitemap_custom_uninstall() {
drupal_load('module', 'xmlsitemap'); drupal_load('module', 'xmlsitemap');
xmlsitemap_delete_link(array('type' => 'custom')); xmlsitemap_link_delete_multiple(array('type' => 'custom'));
} }
...@@ -45,10 +45,10 @@ function xmlsitemap_custom_menu() { ...@@ -45,10 +45,10 @@ function xmlsitemap_custom_menu() {
* @param $id * @param $id
* The sitemap link ID of the custom link to load. * The sitemap link ID of the custom link to load.
* *
* @see xmlsitemap_load_link() * @see xmlsitemap_link_load()
*/ */
function xmlsitemap_custom_load($id) { function xmlsitemap_custom_load($id) {
return xmlsitemap_load_link(array('type' => 'custom', 'id' => $id)); return xmlsitemap_link_load('custom', $id);
} }
/** /**
...@@ -57,7 +57,7 @@ function xmlsitemap_custom_load($id) { ...@@ -57,7 +57,7 @@ function xmlsitemap_custom_load($id) {
function xmlsitemap_custom_xmlsitemap_link_info() { function xmlsitemap_custom_xmlsitemap_link_info() {
return array( return array(
'custom' => array( 'custom' => array(
'purge' => FALSE, 'label' => t('Custom links'),
), ),
); );
} }
...@@ -54,7 +54,9 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper { ...@@ -54,7 +54,9 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper {
$edit['loc'] = ' public-files '; $edit['loc'] = ' public-files ';
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertText('The custom link for system/files was saved'); $this->assertText('The custom link for system/files was saved');
$link = $this->assertSitemapLink(array('type' => 'custom', 'loc' => 'system/files')); $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => 'system/files'));
$this->assertEqual(count($links), 1, t('Custom link saved in the database.'));
$link = reset($links);
$this->assertSitemapLinkValues($link, array('priority' => 0.5, 'changefreq' => 0, 'access' => 1, 'status' => 1)); $this->assertSitemapLinkValues($link, array('priority' => 0.5, 'changefreq' => 0, 'access' => 1, 'status' => 1));
$this->clickLink('Edit'); $this->clickLink('Edit');
...@@ -64,7 +66,7 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper { ...@@ -64,7 +66,7 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper {
); );
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertText('The custom link for system/files was saved'); $this->assertText('The custom link for system/files was saved');
$link = $this->assertSitemapLink(array('type' => 'custom', 'id' => $link['id'])); $link = $this->assertSitemapLink('custom', $link['id']);
$this->assertSitemapLinkValues($link, array('priority' => 0.1, 'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS, 'access' => 1, 'status' => 1)); $this->assertSitemapLinkValues($link, array('priority' => 0.1, 'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS, 'access' => 1, 'status' => 1));
$this->clickLink('Delete'); $this->clickLink('Delete');
...@@ -93,12 +95,14 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper { ...@@ -93,12 +95,14 @@ class XMLSitemapCustomFunctionalTest extends XMLSitemapTestHelper {
$edit['loc'] = 'misc/drupal.js'; $edit['loc'] = 'misc/drupal.js';
$this->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save')); $this->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
$this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); $this->assertText('The custom link for ' . $edit['loc'] . ' was saved');
$link = $this->assertSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => $edit['loc']));
$this->assertEqual(count($links), 1, t('Custom link saved in the database.'));
// Test a valid folder. // Test a valid folder.
$edit['loc'] = 'misc'; $edit['loc'] = 'misc';
$this->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save')); $this->drupalPost('admin/config/search/xmlsitemap/custom/add', $edit, t('Save'));
$this->assertText('The custom link for ' . $edit['loc'] . ' was saved'); $this->assertText('The custom link for ' . $edit['loc'] . ' was saved');
$link = $this->assertSitemapLink(array('type' => 'custom', 'loc' => $edit['loc'])); $links = xmlsitemap_link_load_multiple(array('type' => 'custom', 'loc' => $edit['loc']));
$this->assertEqual(count($links), 1, t('Custom link saved in the database.'));
} }
} }
...@@ -24,6 +24,7 @@ class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper { ...@@ -24,6 +24,7 @@ class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper {
// Add predefined language and reset the locale cache. // Add predefined language and reset the locale cache.
require_once DRUPAL_ROOT . '/includes/locale.inc'; require_once DRUPAL_ROOT . '/includes/locale.inc';
locale_add_language('fr', NULL, NULL, LANGUAGE_LTR, '', 'fr'); locale_add_language('fr', NULL, NULL, LANGUAGE_LTR, '', 'fr');
drupal_language_initialize();
variable_set('xmlsitemap_languages', array('en', 'fr')); variable_set('xmlsitemap_languages', array('en', 'fr'));
variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH); variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
...@@ -119,11 +120,11 @@ class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase { ...@@ -119,11 +120,11 @@ class XMLSitemapI18nNodeTest extends XMLSitemapI18nWebTestCase {
$node = $this->drupalCreateNode(array()); $node = $this->drupalCreateNode(array());
$this->drupalPost('node/' . $node->nid . '/edit', array('language' => 'en'), t('Save')); $this->drupalPost('node/' . $node->nid . '/edit', array('language' => 'en'), t('Save'));
$node = node_load($node->nid, NULL, TRUE); $link = $this->assertSitemapLink('node', $node->nid);
$this->assertIdentical($node->xmlsitemap['language'], 'en'); $this->assertIdentical($link['language'], 'en');
$this->drupalPost('node/' . $node->nid . '/edit', array('language' => 'fr'), t('Save')); $this->drupalPost('node/' . $node->nid . '/edit', array('language' => 'fr'), t('Save'));
$node = node_load($node->nid, NULL, TRUE); $link = $this->assertSitemapLink('node', $node->nid);
$this->assertIdentical($node->xmlsitemap['language'], 'fr'); $this->assertIdentical($link['language'], 'fr');
} }
} }
...@@ -88,7 +88,7 @@ function xmlsitemap_menu_xmlsitemap_link_info() { ...@@ -88,7 +88,7 @@ function xmlsitemap_menu_xmlsitemap_link_info() {
*/ */
function xmlsitemap_menu_menu_link_load($mlid) { function xmlsitemap_menu_menu_link_load($mlid) {
$menu_item = menu_link_load($mlid); $menu_item = menu_link_load($mlid);
if ($data = xmlsitemap_load_link(array('type' => 'menu', 'id' => $mlid))) { if ($data = xmlsitemap_link_load('menu', $mlid)) {
$menu_item['xmlsitemap'] = $data; $menu_item['xmlsitemap'] = $data;
} }
return $menu_item; return $menu_item;
...@@ -186,7 +186,7 @@ function xmlsitemap_menu_form_menu_delete_menu_confirm_alter(&$form, $form_state ...@@ -186,7 +186,7 @@ function xmlsitemap_menu_form_menu_delete_menu_confirm_alter(&$form, $form_state
*/ */
function xmlsitemap_menu_form_menu_delete_menu_confirm_submit($form, $form_state) { function xmlsitemap_menu_form_menu_delete_menu_confirm_submit($form, $form_state) {
$menu = $form['#menu']['menu_name']; $menu = $form['#menu']['menu_name'];
xmlsitemap_delete_link(array('type' => 'menu', 'subtype' => $menu)); xmlsitemap_link_delete_multiple(array('type' => 'menu', 'subtype' => $menu));
variable_del('xmlsitemap_menu_status_' . $menu); variable_del('xmlsitemap_menu_status_' . $menu);
variable_del('xmlsitemap_menu_priority_ ' . $menu); variable_del('xmlsitemap_menu_priority_ ' . $menu);
} }
...@@ -245,7 +245,7 @@ function xmlsitemap_menu_item_update(array $menu_item) { ...@@ -245,7 +245,7 @@ function xmlsitemap_menu_item_update(array $menu_item) {
} }
function xmlsitemap_menu_item_delete(array $menu_item) { function xmlsitemap_menu_item_delete(array $menu_item) {
xmlsitemap_delete_link(array('type' => 'menu', 'id' => $menu_item['mlid'])); xmlsitemap_link_delete('menu', $menu_item['mlid']);
} }
/** /**
......
...@@ -43,7 +43,7 @@ function xmlsitemap_node_node_update($node) { ...@@ -43,7 +43,7 @@ function xmlsitemap_node_node_update($node) {
* Implements hook_node_delete(). * Implements hook_node_delete().
*/ */
function xmlsitemap_node_node_delete($node) { function xmlsitemap_node_node_delete($node) {
xmlsitemap_delete_link(array('type' => 'node', 'id' => $node->nid)); xmlsitemap_link_delete('node', $node->nid);
} }
/** /**
...@@ -82,7 +82,7 @@ function xmlsitemap_node_comment_delete(stdClass $comment) { ...@@ -82,7 +82,7 @@ function xmlsitemap_node_comment_delete(stdClass $comment) {
function xmlsitemap_node_node_type_delete($info) { function xmlsitemap_node_node_type_delete($info) {
variable_del('xmlsitemap_node_status_' . $info->type); variable_del('xmlsitemap_node_status_' . $info->type);
variable_del('xmlsitemap_node_priority_' . $info->type); variable_del('xmlsitemap_node_priority_' . $info->type);
//xmlsitemap_delete_link(array('type' => 'node', 'subtype' => $info->type)); //xmlsitemap_link_delete_multiple(array('type' => 'node', 'subtype' => $info->type));
} }
/** /**
...@@ -188,7 +188,7 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -188,7 +188,7 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) {
if ($types = xmlsitemap_node_get_types()) { if ($types = xmlsitemap_node_get_types()) {
$sql = "SELECT n.nid FROM {node} n WHERE n.nid > :offset AND n.type IN (:types) ORDER BY n.nid"; $sql = "SELECT n.nid FROM {node} n WHERE n.nid > :offset AND n.type IN (:types) ORDER BY n.nid";
$args = array(':offset' => $offset, ':types' => $types); $args = array(':offset' => $offset, ':types' => $types);
$nids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args)); $nids = ($limit ? db_query_range($sql, 0, $limit, $args)->fetchCol() : db_query($sql, $args)->fetchCol());
$nodes = node_load_multiple($nids); $nodes = node_load_multiple($nids);
foreach ($nodes as $node) { foreach ($nodes as $node) {
...@@ -281,7 +281,7 @@ function xmlsitemap_node_get_timestamps($node) { ...@@ -281,7 +281,7 @@ function xmlsitemap_node_get_timestamps($node) {
function xmlsitemap_node_create_link(&$node) { function xmlsitemap_node_create_link(&$node) {
if (!isset($node->xmlsitemap) || !is_array($node->xmlsitemap)) { if (!isset($node->xmlsitemap) || !is_array($node->xmlsitemap)) {
$node->xmlsitemap = array(); $node->xmlsitemap = array();
if ($node->nid && $link = xmlsitemap_load_link(array('type' => 'node', 'id' => $node->nid))) { if ($node->nid && $link = xmlsitemap_link_load('node', $node->nid)) {
$node->xmlsitemap = $link; $node->xmlsitemap = $link;
} }
} }
...@@ -331,22 +331,3 @@ function xmlsitemap_node_variables() { ...@@ -331,22 +331,3 @@ function xmlsitemap_node_variables() {
} }
return $defaults; return $defaults;
} }
///**
// * Internal implementation of variable_get().
// */
//function xmlsitemap_node_var($name, $default = NULL) {
// static $defaults;
// if (!isset($defaults)) {
// $defaults = xmlsitemap_node_variables();
// }
//
// $name = 'xmlsitemap_node_'. $name;
//
// // @todo Remove when stable.
// if (!isset($defaults[$name])) {
// trigger_error(t('Default variable for %variable not found.', array('%variable' => $name)));
// }
//
// return variable_get($name, isset($default) || !isset($defaults[$name]) ? $default : $defaults[$name]);
//}
...@@ -25,17 +25,17 @@ class XMLSitemapNodeTestHelper extends XMLSitemapTestHelper { ...@@ -25,17 +25,17 @@ class XMLSitemapNodeTestHelper extends XMLSitemapTestHelper {
//} //}
protected function assertNodeSitemapLinkVisible(stdClass $node) { protected function assertNodeSitemapLinkVisible(stdClass $node) {
$link = xmlsitemap_load_link(array('type' => 'node', 'id' => $node->nid)); $link = xmlsitemap_link_load('node', $node->nid);
return $this->assertSitemapLinkVisible($link); return $this->assertSitemapLinkVisible($link);
} }
protected function assertNodeSitemapLinkNotVisible(stdClass $node) { protected function assertNodeSitemapLinkNotVisible(stdClass $node) {
$link = xmlsitemap_load_link(array('type' => 'node', 'id' => $node->nid)); $link = xmlsitemap_link_load('node', $node->nid);
return $this->assertSitemapLinkNotVisible($link); return $this->assertSitemapLinkNotVisible($link);
} }
protected function assertNodeSitemapLinkValues(stdClass $node, array $values) { protected function assertNodeSitemapLinkValues(stdClass $node, array $values) {
$link = xmlsitemap_load_link(array('type' => 'node', 'id' => $node->nid)); $link = xmlsitemap_link_load('node', $node->nid);
if (!$link) { if (!$link) {
$this->fail(t('Could not load sitemap link for node @nid.', array('@nid' => $node->nid))); $this->fail(t('Could not load sitemap link for node @nid.', array('@nid' => $node->nid)));
} }
......
...@@ -15,9 +15,9 @@ function xmlsitemap_taxonomy_cron() { ...@@ -15,9 +15,9 @@ function xmlsitemap_taxonomy_cron() {
*/ */
function xmlsitemap_taxonomy_xmlsitemap_index_links($limit) { function xmlsitemap_taxonomy_xmlsitemap_index_links($limit) {
if ($vids = xmlsitemap_taxonomy_get_vids()) { if ($vids = xmlsitemap_taxonomy_get_vids()) {
$tids = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy_term' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN (:vids) ORDER BY t.tid DESC", 0, $limit, array(':vids' => $vids)); $tids = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy_term' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN (:vids) ORDER BY t.tid DESC", 0, $limit, array(':vids' => $vids))->fetchCol();
foreach ($tids as $tid) { $terms = taxonomy_term_load_multiple($tids);
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid); foreach ($terms as $term) {
$link = xmlsitemap_taxonomy_create_link($term); $link = xmlsitemap_taxonomy_create_link($term);
xmlsitemap_save_link($link); xmlsitemap_save_link($link);
} }
...@@ -33,10 +33,10 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -33,10 +33,10 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) {
if ($vids = xmlsitemap_taxonomy_get_vids()) { if ($vids = xmlsitemap_taxonomy_get_vids()) {
$sql = "SELECT t.tid FROM {term_data} t WHERE t.tid > :tid AND t.vid IN (:vids) ORDER BY t.tid"; $sql = "SELECT t.tid FROM {term_data} t WHERE t.tid > :tid AND t.vid IN (:vids) ORDER BY t.tid";
$args = array(':tid' => $offset, ':vids' => $vids); $args = array(':tid' => $offset, ':vids' => $vids);
$tids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args)); $tids = ($limit ? db_query_range($sql, 0, $limit, $args)->fetchCol() : db_query($sql, $args)->fetchCol());
$terms = taxonomy_term_load_multiple($tids);
foreach ($tids as $tid) { foreach ($terms as $term) {
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid);
$links[] = xmlsitemap_taxonomy_create_link($term); $links[] = xmlsitemap_taxonomy_create_link($term);
} }
} }
...@@ -69,21 +69,6 @@ function xmlsitemap_taxonomy_xmlsitemap_link_info() { ...@@ -69,21 +69,6 @@ function xmlsitemap_taxonomy_xmlsitemap_link_info() {
); );
} }