Commit 93b0246c authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Updated for no more $ret in D7.

parent e820e5b9
......@@ -117,7 +117,11 @@ function xmlsitemap_check_status() {
function xmlsitemap_install() {
// Set this module's weight to 1 so xmlsitemap_cron() runs after all other
// xmlsitemap_x_cron() runs.
db_query("UPDATE {system} SET weight = 1 WHERE type = 'module' AND name = 'xmlsitemap'");
db_update('system')
->fields(array('weight' => 1))
->condition('type', 'module')
->condition('name', 'xmlsitemap')
->execute();
// Load the module so we can use xmlsitemap_var().
drupal_load('module', 'xmlsitemap');
......
......@@ -12,7 +12,11 @@
function xmlsitemap_engines_install() {
// Set this module's weight to 1 so xmlsitemap_engines_cron() runs after
// the sitemap has been generated in xmlsitemap_cron().
db_query("UPDATE {system} SET weight = 2 WHERE type = 'module' AND name = 'xmlsitemap_engines'");
db_update('system')
->fields(array('weight' => 2))
->condition('type', 'module')
->condition('name', 'xmlsitemap_engines')
->execute();
}
/**
......@@ -31,7 +35,6 @@ function xmlsitemap_engines_uninstall() {
*/
function xmlsitemap_engines_update_1() {
variable_set('xmlsitemap_engines_submit', array_filter(variable_get('xmlsitemap_engines_submit', array())));
return array();
}
/**
......@@ -40,16 +43,17 @@ function xmlsitemap_engines_update_1() {
function xmlsitemap_engines_update_2() {
variable_set('xmlsitemap_engines_engines', variable_get('xmlsitemap_engines_submit', array()));
variable_del('xmlsitemap_engines_submit');
return array();
}
/**
* Increase the module weight so it always runs after sitemap generation.
*/
function xmlsitemap_engines_update_3() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 2 WHERE type = 'module' AND name = 'xmlsitemap_engines'");
return $ret;
db_update('system')
->fields(array('weight' => 2))
->condition('type', 'module')
->condition('name', 'xmlsitemap_engines')
->execute();
}
/**
......@@ -62,5 +66,4 @@ function xmlsitemap_engines_update_4() {
$engines[$index] = 'bing';
}
variable_set('xmlsitemap_engines_engines', $engines);
return array();
}
......@@ -22,55 +22,48 @@ function xmlsitemap_menu_uninstall() {
function xmlsitemap_menu_update_1() {
$value = xmlsitemap_menu_var('menus');
variable_set('xmlsitemap_menu_menus', array_filter($value));
return array();
}
function xmlsitemap_menu_update_2() {
$ret = array();
$field = array(
'description' => 'The {menu_links}.menu_name of this menu link.',
'type' => 'varchar',
'length' => 32,
'default' => NULL,
);
db_add_field($ret, 'xmlsitemap', 'menu_name', $field);
db_add_index($ret, 'xmlsitemap', 'menu_name', array('menu_name'));
$ret[] = update_sql("UPDATE {xmlsitemap} SET menu_name = (SELECT menu_name FROM {menu_links} WHERE mlid = {xmlsitemap}.id) WHERE type = 'menu'");
return $ret;
db_add_field('xmlsitemap', 'menu_name', $field);
db_add_index('xmlsitemap', 'menu_name', array('menu_name'));
db_query("UPDATE {xmlsitemap} SET menu_name = (SELECT menu_name FROM {menu_links} WHERE mlid = {xmlsitemap}.id) WHERE type = 'menu'");
}
function xmlsitemap_menu_update_3() {
$ret = array();
$menus = variable_get('xmlsitemap_menu_menus', array());
foreach ($menus as $menu) {
variable_set('xmlsitemap_menu_status_' . $menu, TRUE);
}
variable_del('xmlsitemap_menu_menus');
return $ret;
}
function xmlsitemap_menu_update_4() {
return array();
}
function xmlsitemap_menu_update_5() {
return array();
}
// Skip to 6 since I was stupid and had xmlsitemap_menu_update_5() in xmlsitemap_node.install
function xmlsitemap_menu_update_6() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE type = 'module' AND name = 'xmlsitemap_menu'");
return $ret;
db_update('system')
->fields(array('weight' => 0))
->condition('type', 'module')
->condition('name', 'xmlsitemap_menu')
->execute();
}
function xmlsitemap_menu_update_7() {
$ret = array();
$menus = array_keys(menu_get_menus());
foreach ($menus as $menu) {
if (variable_get('xmlsitemap_menu_priority_' . $menu, 'default') === 'default') {
variable_set('xmlsitemap_menu_priority_' . $menu, 0.5);
}
}
return $ret;
}
......@@ -20,47 +20,43 @@ function xmlsitemap_node_uninstall() {
// @todo Remove these update functions before alpha.
function xmlsitemap_node_update_1() {
$ret = array();
$field = array(
'description' => "The {node_type}.type of this link's node.",
'type' => 'varchar',
'length' => 32,
);
db_add_field($ret, 'xmlsitemap', 'node_type', $field);
db_add_index($ret, 'xmlsitemap', 'node_type', array('node_type'));
$ret[] = update_sql("UPDATE {xmlsitemap} SET node_type = (SELECT type FROM {node} WHERE nid = {xmlsitemap}.id) WHERE type = 'node'");
return $ret;
db_add_field('xmlsitemap', 'node_type', $field);
db_add_index('xmlsitemap', 'node_type', array('node_type'));
db_query("UPDATE {xmlsitemap} SET node_type = (SELECT type FROM {node} WHERE nid = {xmlsitemap}.id) WHERE type = 'node'");
}
function xmlsitemap_node_update_2() {
$ret = array();
$node_types = array_keys(node_get_types('names'));
foreach ($node_types as $node_type) {
if (variable_get('xmlsitemap_node_priority_' . $node_type, 'default') === 'default') {
variable_set('xmlsitemap_node_priority_' . $node_type, 0.5);
}
}
return $ret;
}
function xmlsitemap_node_update_3() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE type = 'module' AND name = 'xmlsitemap_node'");
return $ret;
db_update('system')
->fields(array('weight' => 0))
->condition('type', 'module')
->condition('name', 'xmlsitemap_node')
->execute();
}
function xmlsitemap_node_update_4() {
return array();
}
/**
* Update node languages.
*
* @after xmlsitemap_update_16()
* Must run after the {xmlsitemap}.language field has been added.
*/
function xmlsitemap_node_update_5() {
$ret = array();
if (db_column_exists('xmlsitemap', 'language')) {
$ret[] = update_sql("UPDATE {xmlsitemap} SET language = (SELECT {node}.language FROM {node} WHERE {node}.nid = {xmlsitemap}.id) WHERE {xmlsitemap}.type = 'node'");
}
else {
// Set the abort flag so this update runs again when the {xmlsitemap}.language field exists.
$ret['#abort'] = array('success' => FALSE, 'query' => 'The {xmlsitemap}.language field does not yet exist. Please re-run the update script.');
}
return $ret;
db_query("UPDATE {xmlsitemap} SET language = (SELECT {node}.language FROM {node} WHERE {node}.nid = {xmlsitemap}.id) WHERE {xmlsitemap}.type = 'node'");
}
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