Commit ca3d2534 authored by Dave Reid's avatar Dave Reid

by Dave Reid: Drupal 7 port fixing round 1.

parent 42bc5d8e
...@@ -293,7 +293,7 @@ function xmlsitemap_add_form_type_summary(&$form, $type, $items) { ...@@ -293,7 +293,7 @@ function xmlsitemap_add_form_type_summary(&$form, $type, $items) {
'#value' => theme('table', $header, $rows), '#value' => theme('table', $header, $rows),
); );
$count = db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = '%s' AND access = 1 AND status = 1", $type['type'])); $count = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = '%s' AND access = 1 AND status = 1", $type['type'])->fetchField();
$form[$type['type']]['count'] = array( $form[$type['type']]['count'] = array(
'#type' => 'item', '#type' => 'item',
'#value' => format_plural($count, 'There is 1 @type link in the XML sitemap.', 'There are @count @type links in the XML sitemap.', array('@type' => drupal_strtolower($type['type']))), '#value' => format_plural($count, 'There is 1 @type link in the XML sitemap.', 'There are @count @type links in the XML sitemap.', array('@type' => drupal_strtolower($type['type']))),
......
...@@ -70,7 +70,7 @@ function hook_xmlsitemap_links_batch_info() { ...@@ -70,7 +70,7 @@ function hook_xmlsitemap_links_batch_info() {
return array( return array(
'current' => 0, 'current' => 0,
// This value is used to start selecting items (WHERE id > current). // This value is used to start selecting items (WHERE id > current).
'max' => db_result(db_query("SELECT COUNT(id) FROM {mymodule}")), 'max' => db_query("SELECT COUNT(id) FROM {mymodule}")->fetchField(),
// This should be the total number of items to process. // This should be the total number of items to process.
); );
} }
......
...@@ -118,8 +118,8 @@ function _xmlsitemap_get_optimal_memory_limit() { ...@@ -118,8 +118,8 @@ function _xmlsitemap_get_optimal_memory_limit() {
$optimal_limit += xmlsitemap_get_chunk_size() * 500; $optimal_limit += xmlsitemap_get_chunk_size() * 500;
// Add memory for storing the url aliases. // Add memory for storing the url aliases.
$aliases = db_result(db_query("SELECT COUNT(pid) FROM {url_alias} WHERE language = ''")); $aliases = db_query("SELECT COUNT(pid) FROM {url_alias} WHERE language = ''")->fetchField();
$aliases += db_result(db_query("SELECT COUNT(pid) as pid_count FROM {url_alias} WHERE language <> '' GROUP BY language ORDER BY pid_count DESC")); $aliases += db_query("SELECT COUNT(pid) as pid_count FROM {url_alias} WHERE language <> '' GROUP BY language ORDER BY pid_count DESC")->fetchField();
$optimal_limit += $aliases * 250; $optimal_limit += $aliases * 250;
} }
return $optimal_limit; return $optimal_limit;
......
...@@ -33,8 +33,8 @@ function xmlsitemap_requirements($phase) { ...@@ -33,8 +33,8 @@ function xmlsitemap_requirements($phase) {
} }
if ($phase == 'runtime') { if ($phase == 'runtime') {
$directory = file_create_path(xmlsitemap_var('path')); $directory = file_directory_path() . '/' . xmlsitemap_var('path');
if (!file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$requirements['xmlsitemap_directory'] = array( $requirements['xmlsitemap_directory'] = array(
'title' => $t('XML sitemap cache directory'), 'title' => $t('XML sitemap cache directory'),
'value' => $t('Not found or not writable'), 'value' => $t('Not found or not writable'),
...@@ -116,9 +116,6 @@ function xmlsitemap_check_status() { ...@@ -116,9 +116,6 @@ function xmlsitemap_check_status() {
* Implements hook_install(). * Implements hook_install().
*/ */
function xmlsitemap_install() { function xmlsitemap_install() {
// Add tables.
drupal_install_schema('xmlsitemap');
// Set this module's weight to 1 so xmlsitemap_cron() runs after all other // Set this module's weight to 1 so xmlsitemap_cron() runs after all other
// xmlsitemap_x_cron() runs. // xmlsitemap_x_cron() runs.
db_query("UPDATE {system} SET weight = 1 WHERE type = 'module' AND name = 'xmlsitemap'"); db_query("UPDATE {system} SET weight = 1 WHERE type = 'module' AND name = 'xmlsitemap'");
...@@ -127,12 +124,12 @@ function xmlsitemap_install() { ...@@ -127,12 +124,12 @@ function xmlsitemap_install() {
drupal_load('module', 'xmlsitemap'); drupal_load('module', 'xmlsitemap');
// Add files directory. // Add files directory.
$path = file_create_path(xmlsitemap_var('path')); $path = file_directory_path() . '/' . xmlsitemap_var('path');
file_check_directory($path, FILE_CREATE_DIRECTORY); file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Insert the homepage link into the {xmlsitemap} table so we do not show an // Insert the homepage link into the {xmlsitemap} table so we do not show an
// empty sitemap after install. // empty sitemap after install.
db_query("INSERT INTO {xmlsitemap} (type, id, loc, priority, changefreq) VALUES ('frontpage', 0, '', %f, %d)", xmlsitemap_var('frontpage_priority'), xmlsitemap_var('frontpage_changefreq')); db_query("INSERT INTO {xmlsitemap} (type, id, loc, priority, changefreq) VALUES ('frontpage', 0, '', :priority, :changefreq)", array(':priority' => xmlsitemap_var('frontpage_priority'), 'changefreq' => xmlsitemap_var('frontpage_changefreq')));
// @todo Does the sitemap show up on first install or is it a 404 page? // @todo Does the sitemap show up on first install or is it a 404 page?
} }
...@@ -148,9 +145,6 @@ function xmlsitemap_enable() { ...@@ -148,9 +145,6 @@ function xmlsitemap_enable() {
* Implements hook_uninstall(). * Implements hook_uninstall().
*/ */
function xmlsitemap_uninstall() { function xmlsitemap_uninstall() {
// Remove tables.
drupal_uninstall_schema('xmlsitemap');
// Remove variables. // Remove variables.
drupal_load('module', 'xmlsitemap'); drupal_load('module', 'xmlsitemap');
$variables = array_keys(xmlsitemap_variables()); $variables = array_keys(xmlsitemap_variables());
......
...@@ -127,18 +127,6 @@ function xmlsitemap_menu() { ...@@ -127,18 +127,6 @@ function xmlsitemap_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'xmlsitemap.pages.inc', 'file' => 'xmlsitemap.pages.inc',
); );
<<<<<<< xmlsitemap.module
$chunk_count = variable_get('xmlsitemap_chunk_count', 0);
for ($chunk = 0; $chunk < $chunk_count; ++$chunk) {
$items["sitemap$chunk.xml"] = array(
'title' => 'Site map !number',
'title arguments' => array('!number' => $chunk),
'page callback' => '_xmlsitemap_output',
'page arguments' => array((string)$chunk),
'type' => MENU_CALLBACK,
'access arguments' => $access_content
);
=======
return $items; return $items;
} }
...@@ -150,7 +138,6 @@ function xmlsitemap_cron() { ...@@ -150,7 +138,6 @@ function xmlsitemap_cron() {
if (!xmlsitemap_var('regenerate_needed') if (!xmlsitemap_var('regenerate_needed')
|| (REQUEST_TIME - xmlsitemap_var('generated_last')) < xmlsitemap_var('minimum_lifetime')) { || (REQUEST_TIME - xmlsitemap_var('generated_last')) < xmlsitemap_var('minimum_lifetime')) {
return; return;
>>>>>>> 1.20.2.45.2.122
} }
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap');
...@@ -273,7 +260,7 @@ function xmlsitemap_get_chunk_count($reset = FALSE) { ...@@ -273,7 +260,7 @@ function xmlsitemap_get_chunk_count($reset = FALSE) {
function xmlsitemap_get_link_count($reset = FALSE) { function xmlsitemap_get_link_count($reset = FALSE) {
static $count; static $count;
if (!isset($count) || $reset) { if (!isset($count) || $reset) {
$count = db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE access = 1 AND status = 1")); $count = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE access = 1 AND status = 1")->fetchField();
} }
return $count; return $count;
} }
...@@ -370,7 +357,7 @@ function _xmlsitemap_check_changed_links(array $conditions = array(), array $upd ...@@ -370,7 +357,7 @@ function _xmlsitemap_check_changed_links(array $conditions = array(), array $upd
$args = _xmlsitemap_build_conditions($conditions); $args = _xmlsitemap_build_conditions($conditions);
$sql = "SELECT 1 FROM {xmlsitemap} WHERE ". implode(' AND ', $conditions); $sql = "SELECT 1 FROM {xmlsitemap} WHERE ". implode(' AND ', $conditions);
$changed = db_result(db_query_range($sql, $args, 0, 1)); $changed = db_query_range($sql, $args, 0, 1)->fetchField();
if ($changed && $flag) { if ($changed && $flag) {
variable_set('xmlsitemap_regenerate_needed', TRUE); variable_set('xmlsitemap_regenerate_needed', TRUE);
...@@ -672,49 +659,19 @@ function xmlsitemap_variables() { ...@@ -672,49 +659,19 @@ function xmlsitemap_variables() {
} }
/** /**
<<<<<<< xmlsitemap.module
* Determine the frequency of updates to a link.
* @param $interval: The number of seconds since last change
* @return A string representing the update frequency according to the
* sitemaps.org protocol
*/
function _xmlsitemap_frequency($interval) {
$frequencies = array(
'always' => 3600,
'hourly' => 86400,
'daily' => 604800,
'weekly' => 2419200,
'monthly' => 29030400,
'yearly' => 100000000,
'never' => 0,
);
$frequency = 'never';
if (array_key_exists($interval, $frequencies)) {
$frequency = $interval;
=======
* Internal implementation of variable_get(). * Internal implementation of variable_get().
*/ */
function xmlsitemap_var($name, $default = NULL) { function xmlsitemap_var($name, $default = NULL) {
static $defaults = NULL; static $defaults = NULL;
if (!isset($defaults)) { if (!isset($defaults)) {
$defaults = xmlsitemap_variables(); $defaults = xmlsitemap_variables();
>>>>>>> 1.20.2.45.2.122
} }
<<<<<<< xmlsitemap.module
elseif (is_numeric($interval)) {
foreach ($frequencies as $frequency => $value) {
if ($interval < $value) {
break;
}
}
=======
$name = 'xmlsitemap_'. $name; $name = 'xmlsitemap_'. $name;
// @todo Remove when stable. // @todo Remove when stable.
if (!isset($defaults[$name])) { if (!isset($defaults[$name])) {
trigger_error(t('Default variable for %variable not found.', array('%variable' => $name))); trigger_error(t('Default variable for %variable not found.', array('%variable' => $name)));
>>>>>>> 1.20.2.45.2.122
} }
return variable_get($name, isset($default) || !isset($defaults[$name]) ? $default : $defaults[$name]); return variable_get($name, isset($default) || !isset($defaults[$name]) ? $default : $defaults[$name]);
......
...@@ -183,7 +183,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -183,7 +183,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
$args[] = ($field == 'variables' && is_array($value)) ? serialize($value) : $value; $args[] = ($field == 'variables' && is_array($value)) ? serialize($value) : $value;
} }
return db_result(db_query_range("SELECT 1 FROM {watchdog} WHERE " . implode(' AND ', $conditions), $args, 0, 1)); return db_query_range("SELECT 1 FROM {watchdog} WHERE " . implode(' AND ', $conditions), $args, 0, 1)->fetchField();
} }
protected function assertWatchdogMessage(array $conditions, $message = 'Watchdog message found.') { protected function assertWatchdogMessage(array $conditions, $message = 'Watchdog message found.') {
...@@ -335,12 +335,12 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper { ...@@ -335,12 +335,12 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper {
variable_set('xmlsitemap_chunk_size', 4); variable_set('xmlsitemap_chunk_size', 4);
// Make the total number of links just equal to the chunk size. // Make the total number of links just equal to the chunk size.
$count = db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap}")); $count = db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField();
for ($i = $count; $i < 4; $i++) { for ($i = $count; $i < 4; $i++) {
$this->addSitemapLink(); $this->addSitemapLink();
$this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1); $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1);
} }
$this->assertEqual(db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap}")), 4); $this->assertEqual(db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 4);
// Add a disabled link, should not change the chunk count. // Add a disabled link, should not change the chunk count.
$this->addSitemapLink(array('status' => FALSE)); $this->addSitemapLink(array('status' => FALSE));
...@@ -357,7 +357,7 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper { ...@@ -357,7 +357,7 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper {
// Delete all links. The chunk count should be 1 not 0. // Delete all links. The chunk count should be 1 not 0.
db_query("DELETE FROM {xmlsitemap}"); db_query("DELETE FROM {xmlsitemap}");
$this->assertEqual(db_result(db_query("SELECT COUNT(id) FROM {xmlsitemap}")), 0); $this->assertEqual(db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 0);
$this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1); $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1);
} }
...@@ -444,7 +444,7 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper { ...@@ -444,7 +444,7 @@ class XMLSitemapUnitTest extends XMLSitemapTestHelper {
$this->assertEqual($user->uid, $original_user->uid); $this->assertEqual($user->uid, $original_user->uid);
// Attempt to switch to an invalid user ID. // Attempt to switch to an invalid user ID.
$invalid_uid = db_result(db_query("SELECT MAX(uid) FROM {users}")) + 100; $invalid_uid = db_query("SELECT MAX(uid) FROM {users}")->fetchField() + 100;
$this->assertEqual(xmlsitemap_switch_user($invalid_uid), FALSE); $this->assertEqual(xmlsitemap_switch_user($invalid_uid), FALSE);
$this->assertEqual($user->uid, $original_user->uid); $this->assertEqual($user->uid, $original_user->uid);
$this->assertEqual(xmlsitemap_restore_user(), FALSE); $this->assertEqual(xmlsitemap_restore_user(), FALSE);
...@@ -697,7 +697,7 @@ class XMLSitemapFunctionalTest extends XMLSitemapTestHelper { ...@@ -697,7 +697,7 @@ class XMLSitemapFunctionalTest extends XMLSitemapTestHelper {
$this->assertNoXMLSitemapProblems(); $this->assertNoXMLSitemapProblems();
// Test anonymous users access to sitemap.xml. // Test anonymous users access to sitemap.xml.
$anon_permissions = db_result(db_query("SELECT perm FROM {permission} WHERE rid = %d", DRUPAL_ANONYMOUS_RID)); $anon_permissions = db_query("SELECT perm FROM {permission} WHERE rid = %d", DRUPAL_ANONYMOUS_RID)->fetchField();
db_query("UPDATE {permission} SET perm = '' WHERE rid = %d", DRUPAL_ANONYMOUS_RID); db_query("UPDATE {permission} SET perm = '' WHERE rid = %d", DRUPAL_ANONYMOUS_RID);
$this->assertXMLSitemapProblems(t('In order to allow search engines to view the XML sitemap, the anonymous user role must have the access content permission.')); $this->assertXMLSitemapProblems(t('In order to allow search engines to view the XML sitemap, the anonymous user role must have the access content permission.'));
db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $anon_permissions, DRUPAL_ANONYMOUS_RID); db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $anon_permissions, DRUPAL_ANONYMOUS_RID);
......
...@@ -38,7 +38,7 @@ function xmlsitemap_custom_edit_link_form($form_state, $link = array()) { ...@@ -38,7 +38,7 @@ function xmlsitemap_custom_edit_link_form($form_state, $link = array()) {
module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin');
$link += array( $link += array(
'id' => (int) db_result(db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")) + 1, 'id' => db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")->fetchField() + 1,
'loc' => '', 'loc' => '',
'priority' => 0.5, 'priority' => 0.5,
'lastmod' => 0, 'lastmod' => 0,
...@@ -121,7 +121,7 @@ function xmlsitemap_custom_edit_link_form_validate(&$form, &$form_state) { ...@@ -121,7 +121,7 @@ function xmlsitemap_custom_edit_link_form_validate(&$form, &$form_state) {
$menu_item['access'] = FALSE; $menu_item['access'] = FALSE;
} }
if (db_result(db_query_range("SELECT 1 FROM {xmlsitemap} WHERE type <> 'custom' AND loc = '%s' AND status = 1 AND access = 1 AND language IN ('%s', '')", $link['loc'], $link['language'], 0, 1))) { if (db_query_range("SELECT 1 FROM {xmlsitemap} WHERE type <> 'custom' AND loc = '%s' AND status = 1 AND access = 1 AND language IN ('%s', '')", $link['loc'], $link['language'], 0, 1)->fetchField()) {
form_set_error('loc', t('There is already an existing link in the sitemap with the path %link.', array('%link' => $link['loc']))); form_set_error('loc', t('There is already an existing link in the sitemap with the path %link.', array('%link' => $link['loc'])));
} }
elseif (empty($menu_item['access']) && !is_readable('./' . $link['loc'])) { elseif (empty($menu_item['access']) && !is_readable('./' . $link['loc'])) {
......
...@@ -8,3 +8,4 @@ files[] = xmlsitemap_custom.module ...@@ -8,3 +8,4 @@ files[] = xmlsitemap_custom.module
files[] = xmlsitemap_custom.admin.inc files[] = xmlsitemap_custom.admin.inc
files[] = xmlsitemap_custom.install files[] = xmlsitemap_custom.install
files[] = xmlsitemap_custom.test files[] = xmlsitemap_custom.test
configure = admin/config/search/xmlsitemap/custom
...@@ -12,9 +12,9 @@ function xmlsitemap_menu_cron() { ...@@ -12,9 +12,9 @@ function xmlsitemap_menu_cron() {
xmlsitemap_switch_user(0); xmlsitemap_switch_user(0);
$sql = "SELECT ml.mlid FROM {menu_links} ml LEFT JOIN {xmlsitemap} x ON x.type = 'menu' AND ml.mlid = x.id WHERE x.id IS NULL AND ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ")"; $sql = "SELECT ml.mlid FROM {menu_links} ml LEFT JOIN {xmlsitemap} x ON x.type = 'menu' AND ml.mlid = x.id WHERE x.id IS NULL AND ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ")";
$query = db_query_range($sql, $menus, 0, xmlsitemap_var('batch_limit')); $mlids = db_query_range($sql, $menus, 0, xmlsitemap_var('batch_limit'));
while ($mlid = db_result($query)) { foreach ($mlids as $mlid) {
$menu_item = xmlsitemap_menu_menu_link_load($mlid); $menu_item = xmlsitemap_menu_menu_link_load($mlid);
$link = xmlsitemap_menu_create_link($menu_item); $link = xmlsitemap_menu_create_link($menu_item);
xmlsitemap_save_link($link); xmlsitemap_save_link($link);
...@@ -37,9 +37,9 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -37,9 +37,9 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) {
$sql = "SELECT ml.mlid FROM {menu_links} ml WHERE ml.mlid > %d AND ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ") ORDER BY ml.mlid"; $sql = "SELECT ml.mlid FROM {menu_links} ml WHERE ml.mlid > %d AND ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ") ORDER BY ml.mlid";
$args = array_merge(array($offset), $menus); $args = array_merge(array($offset), $menus);
$query = ($limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args)); $mlids = ($limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args));
while ($mlid = db_result($query)) { foreach ($mlids as $mlid) {
$menu_item = xmlsitemap_menu_menu_link_load($mlid); $menu_item = xmlsitemap_menu_menu_link_load($mlid);
$links[] = xmlsitemap_menu_create_link($menu_item); $links[] = xmlsitemap_menu_create_link($menu_item);
} }
...@@ -57,7 +57,7 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -57,7 +57,7 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) {
function xmlsitemap_menu_xmlsitemap_links_batch_info() { function xmlsitemap_menu_xmlsitemap_links_batch_info() {
$menus = xmlsitemap_menu_get_menus(); $menus = xmlsitemap_menu_get_menus();
return array( return array(
'max' => $menus ? db_result(db_query("SELECT COUNT(ml.mlid) FROM {menu_links} ml WHERE ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ")", $menus)) : 0, 'max' => $menus ? db_query("SELECT COUNT(ml.mlid) FROM {menu_links} ml WHERE ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ")", $menus)->fetchField() : 0,
); );
} }
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
*/ */
function xmlsitemap_node_cron() { function xmlsitemap_node_cron() {
// Start with the most recently changed nodes first. // Start with the most recently changed nodes first.
$query = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {xmlsitemap} x ON x.type = 'node' AND n.nid = x.id WHERE x.id IS NULL ORDER BY n.changed DESC", 0, xmlsitemap_var('batch_limit')); $nids = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {xmlsitemap} x ON x.type = 'node' AND n.nid = x.id WHERE x.id IS NULL ORDER BY n.changed DESC", 0, xmlsitemap_var('batch_limit'));
while ($nid = db_result($query)) { foreach ($nids as $nid) {
$node = node_load($nid, NULL, TRUE); $node = node_load($nid, NULL, TRUE);
$link = xmlsitemap_node_create_link($node); $link = xmlsitemap_node_create_link($node);
xmlsitemap_save_link($link); xmlsitemap_save_link($link);
...@@ -208,9 +208,9 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -208,9 +208,9 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) {
$links = array(); $links = array();
$sql = "SELECT n.nid FROM {node} n WHERE n.nid > %d ORDER BY n.nid"; $sql = "SELECT n.nid FROM {node} n WHERE n.nid > %d ORDER BY n.nid";
$query = ($limit ? db_query_range($sql, $offset, 0, $limit) : db_query($sql, $offset)); $nids = ($limit ? db_query_range($sql, $offset, 0, $limit) : db_query($sql, $offset));
while ($nid = db_result($query)) { foreach ($nids as $nid) {
$node = node_load($nid, NULL, TRUE); $node = node_load($nid, NULL, TRUE);
$links[] = xmlsitemap_node_create_link($node); $links[] = xmlsitemap_node_create_link($node);
} }
...@@ -221,21 +221,10 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -221,21 +221,10 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) {
/** /**
* Implements hook_xmlsitemap_links_batch_info(). * Implements hook_xmlsitemap_links_batch_info().
*/ */
<<<<<<< xmlsitemap_node.module
function _xmlsitemap_node_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
$type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : trim($form_state['values']['type']);
$priority = $form_state['values']['xmlsitemap_node_type_priority'];
$old_priority = $form_state['values']['xmlsitemap_old_priority'];
if ($op == t('Save content type') && $priority != $old_priority || $op == t('Reset to defaults') && $old_priority != 0.1) {
xmlsitemap_update_sitemap();
}
=======
function xmlsitemap_node_xmlsitemap_links_batch_info() { function xmlsitemap_node_xmlsitemap_links_batch_info() {
return array( return array(
'max' => db_result(db_query("SELECT COUNT(n.nid) FROM {node} n")), 'max' => db_query("SELECT COUNT(n.nid) FROM {node} n")->fetchField(),
); );
>>>>>>> 1.19.2.20.2.73
} }
/** /**
...@@ -294,11 +283,7 @@ function xmlsitemap_node_get_timestamps($node) { ...@@ -294,11 +283,7 @@ function xmlsitemap_node_get_timestamps($node) {
static $timestamps = array(); static $timestamps = array();
if (!isset($timestamps[$node->nid])) { if (!isset($timestamps[$node->nid])) {
$timestamps[$node->nid] = array(); $timestamps[$node->nid] = db_query("SELECT c.timestamp FROM {comments} c WHERE c.nid = %d AND c.status = %d UNION ALL SELECT nr.timestamp FROM {node_revisions} nr WHERE nr.nid = %d", $node->nid, COMMENT_PUBLISHED, $node->nid)->fetchCol();
$query = db_query("SELECT c.timestamp FROM {comments} c WHERE c.nid = %d AND c.status = %d UNION ALL SELECT nr.timestamp FROM {node_revisions} nr WHERE nr.nid = %d", $node->nid, COMMENT_PUBLISHED, $node->nid);
while ($timestamp = db_result($query)) {
$timestamps[$node->nid][] = (int) $timestamp;
}
} }
return $timestamps[$node->nid]; return $timestamps[$node->nid];
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
*/ */
function xmlsitemap_taxonomy_cron() { function xmlsitemap_taxonomy_cron() {
if ($vids = xmlsitemap_taxonomy_get_vids()) { if ($vids = xmlsitemap_taxonomy_get_vids()) {
$query = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN (" . db_placeholders($vids) . ")", $vids, 0, xmlsitemap_var('batch_limit')); $tids = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN (" . db_placeholders($vids) . ")", $vids, 0, xmlsitemap_var('batch_limit'));
while ($tid = db_result($query)) { foreach ($tids as $tid) {
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid); $term = xmlsitemap_taxonomy_taxonomy_term_load($tid);
$link = xmlsitemap_taxonomy_create_link($term); $link = xmlsitemap_taxonomy_create_link($term);
xmlsitemap_save_link($link); xmlsitemap_save_link($link);
...@@ -26,9 +26,9 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -26,9 +26,9 @@ 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 > %d AND t.vid IN (" . db_placeholders($vids) . ") ORDER BY t.tid"; $sql = "SELECT t.tid FROM {term_data} t WHERE t.tid > %d AND t.vid IN (" . db_placeholders($vids) . ") ORDER BY t.tid";
$args = array_merge(array($offset), $vids); $args = array_merge(array($offset), $vids);
$query = ($limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args)); $tids = ($limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args));
while ($tid = db_result($query)) { foreach ($tids as $tid) {
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid); $term = xmlsitemap_taxonomy_taxonomy_term_load($tid);
$links[] = xmlsitemap_taxonomy_create_link($term); $links[] = xmlsitemap_taxonomy_create_link($term);
} }
...@@ -43,7 +43,7 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) { ...@@ -43,7 +43,7 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) {
function xmlsitemap_taxonomy_xmlsitemap_links_batch_info() { function xmlsitemap_taxonomy_xmlsitemap_links_batch_info() {
$vids = xmlsitemap_taxonomy_get_vids(); $vids = xmlsitemap_taxonomy_get_vids();
return array( return array(
'max' => $vids ? db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t WHERE t.vid IN (" . db_placeholders($vids) . ")", $vids)) : 0, 'max' => $vids ? db_query("SELECT COUNT(t.tid) FROM {term_data} t WHERE t.vid IN (" . db_placeholders($vids) . ")", $vids)->fetchField() : 0,
); );
} }
...@@ -276,7 +276,7 @@ function xmlsitemap_taxonomy_get_term_depth($tid) { ...@@ -276,7 +276,7 @@ function xmlsitemap_taxonomy_get_term_depth($tid) {
static $depths = array(); static $depths = array();
if (!isset($depths[$tid])) { if (!isset($depths[$tid])) {
if ($parent = db_result(db_query("SELECT parent FROM {term_hierarchy} WHERE tid = %d", $tid))) { if ($parent = db_query("SELECT parent FROM {term_hierarchy} WHERE tid = %d", $tid)->fetchField()) {
// If the term has a parent, the term's depth is the parent's depth + 1. // If the term has a parent, the term's depth is the parent's depth + 1.
if (!isset($depths[$parent])) { if (!isset($depths[$parent])) {
$depths[$parent] = xmlsitemap_taxonomy_get_term_depth($parent); $depths[$parent] = xmlsitemap_taxonomy_get_term_depth($parent);
...@@ -294,7 +294,7 @@ function xmlsitemap_taxonomy_get_term_depth($tid) { ...@@ -294,7 +294,7 @@ function xmlsitemap_taxonomy_get_term_depth($tid) {
function xmlsitemap_taxonomy_get_node_count($term) { function xmlsitemap_taxonomy_get_node_count($term) {
// @todo Use db_rewrite_sql() w/ switch user. // @todo Use db_rewrite_sql() w/ switch user.
return db_result(db_query_range("SELECT COUNT(tn.nid) FROM {term_node} tn LEFT JOIN {node n} USING (nid) WHERE tn.tid = %d AND n.status = 1", $term->tid, 0, 1)); return db_query_range("SELECT COUNT(tn.nid) FROM {term_node} tn LEFT JOIN {node n} USING (nid) WHERE tn.tid = %d AND n.status = 1", $term->tid, 0, 1)->fetchField();
} }
/** /**
......
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