Commit c09fe068 authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Fixed SQL errors with IN().

parent 75866590
......@@ -18,7 +18,7 @@ function xmlsitemap_menu_xmlsitemap_index_links($limit) {
// Set the global user variable to the anonymous user.
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 :menus ORDER BY ml.mlid DESC";
$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 (:menus) ORDER BY ml.mlid DESC";
$mlids = db_query_range($sql, 0, $limit, array(':menus' => $menus));
foreach ($mlids as $mlid) {
......@@ -42,8 +42,8 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) {
// Set the global user variable to the anonymous user.
xmlsitemap_switch_user(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";
$args = array_merge(array($offset), $menus);
$sql = "SELECT ml.mlid FROM {menu_links} ml WHERE ml.mlid > :mlid AND ml.menu_name IN (:menus) ORDER BY ml.mlid";
$args = array(':mlid' => $offset, ':menus' => $menus);
$mlids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args));
foreach ($mlids as $mlid) {
......@@ -64,7 +64,7 @@ function xmlsitemap_menu_xmlsitemap_links($offset = 0, $limit = 0) {
function xmlsitemap_menu_xmlsitemap_links_batch_info() {
$menus = xmlsitemap_menu_get_menus();
return array(
'max' => $menus ? db_query("SELECT COUNT(ml.mlid) FROM {menu_links} ml WHERE ml.menu_name IN (" . db_placeholders($menus, 'varchar') . ")", $menus)->fetchField() : 0,
'max' => $menus ? db_query("SELECT COUNT(ml.mlid) FROM {menu_links} ml WHERE ml.menu_name IN (:menus)", array(':menus' => $menus))->fetchField() : 0,
);
}
......
......@@ -15,7 +15,7 @@ function xmlsitemap_node_cron() {
*/
function xmlsitemap_node_xmlsitemap_index_links($limit) {
if ($types = xmlsitemap_node_get_types()) {
$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 AND n.type IN :types ORDER BY n.nid DESC", 0, $limit, array(':types' => $types));
$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 AND n.type IN (:types) ORDER BY n.nid DESC", 0, $limit, array(':types' => $types));
foreach ($nids as $nid) {
$node = node_load($nid, NULL, TRUE);
$link = xmlsitemap_node_create_link($node);
......@@ -199,13 +199,15 @@ function xmlsitemap_node_form_alter(&$form, $form_state, $form_id) {
function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) {
$links = array();
$sql = "SELECT n.nid FROM {node} n WHERE n.nid > :offset ORDER BY n.nid";
$args = array(':offset' => $offset);
$nids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args));
if ($types = xmlsitemap_node_get_types()) {
$sql = "SELECT n.nid FROM {node} n WHERE n.nid > :offset AND type IN (:types) ORDER BY n.nid";
$args = array(':offset' => $offset, ':types' => $types);
$nids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args));
foreach ($nids as $nid) {
$node = node_load($nid, NULL, TRUE);
$links[] = xmlsitemap_node_create_link($node);
foreach ($nids as $nid) {
$node = node_load($nid, NULL, TRUE);
$links[] = xmlsitemap_node_create_link($node);
}
}
return $links;
......@@ -215,8 +217,9 @@ function xmlsitemap_node_xmlsitemap_links($offset = 0, $limit = 0) {
* Implements hook_xmlsitemap_links_batch_info().
*/
function xmlsitemap_node_xmlsitemap_links_batch_info() {
$types = xmlsitemap_node_get_types();
return array(
'max' => db_query("SELECT COUNT(n.nid) FROM {node} n")->fetchField(),
'max' => $types ? db_query("SELECT COUNT(n.nid) FROM {node} n WHERE type IN (:types)", array(':types' => $types))->fetchField() : 0,
);
}
......
......@@ -15,7 +15,7 @@ function xmlsitemap_taxonomy_cron() {
*/
function xmlsitemap_taxonomy_xmlsitemap_index_links($limit) {
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));
foreach ($tids as $tid) {
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid);
$link = xmlsitemap_taxonomy_create_link($term);
......@@ -31,8 +31,8 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) {
$links = array();
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";
$args = array_merge(array($offset), $vids);
$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);
$tids = ($limit ? db_query_range($sql, 0, $limit, $args) : db_query($sql, $args));
foreach ($tids as $tid) {
......@@ -50,7 +50,7 @@ function xmlsitemap_taxonomy_xmlsitemap_links($offset = 0, $limit = 0) {
function xmlsitemap_taxonomy_xmlsitemap_links_batch_info() {
$vids = xmlsitemap_taxonomy_get_vids();
return array(
'max' => $vids ? db_query("SELECT COUNT(t.tid) FROM {term_data} t WHERE t.vid IN (" . db_placeholders($vids) . ")", $vids)->fetchField() : 0,
'max' => $vids ? db_query("SELECT COUNT(t.tid) FROM {term_data} t WHERE t.vid IN (:vids)", array(':vids' => $vids))->fetchField() : 0,
);
}
......
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