Commit 4b267dd3 authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Fixed PHP notices if links have undefined language code.

parent 9309c488
......@@ -258,7 +258,6 @@ function xmlsitemap_rebuild_form_submit($form, &$form_state) {
variable_set('xmlsitemap_rebuild_needed', TRUE);
module_load_include('inc', 'xmlsitemap');
$batch = xmlsitemap_rebuild_batch($form_state['values']['entities'], $form_state['values']['callbacks'], $form_state['values']['save_custom']);
batch_set($batch);
$form_state['redirect'] = 'admin/config/search/xmlsitemap';
......
......@@ -269,6 +269,7 @@ function xmlsitemap_generate_chunk($handle, &$status, $chunk, $language) {
while ($link = $links->fetchAssoc()) {
$url_options['language'] = ($link['language'] != LANGUAGE_NONE ? xmlsitemap_language_load($link['language']) : $language);
// @todo $url_options['langauge'] could be NULL if language was not found.
$link['alias'] = xmlsitemap_get_path_alias($link['loc'], $url_options['language']->language);
$link_url = url($link['alias'], $url_options);
......@@ -352,7 +353,6 @@ function xmlsitemap_rebuild_batch(array $entities, array $callbacks, $save_custo
'file' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.inc',
);
// Purge any links first.
$batch['operations'][] = array('xmlsitemap_rebuild_batch_clear', array($entities, (bool) $save_custom));
......@@ -378,12 +378,14 @@ function xmlsitemap_rebuild_batch_clear(array $entities, $save_custom, &$context
if (!empty($entities)) {
$query = db_delete('xmlsitemap');
$query->condition('type', $entities);
// If we want to save the custom data, make sure to exclude any links
// that are not using default inclusion or priority.
if ($save_custom) {
$query->condition('status_override', 0);
$query->condition('priority_override', 0);
}
$query->execute();
}
......
......@@ -934,7 +934,7 @@ function xmlsitemap_language_load($language = LANGUAGE_NONE) {
$languages[LANGUAGE_NONE] = NULL;
}
return $languages[$language];
return isset($languages[$language]) ? $languages[$language] : NULL;
}
function xmlsitemap_get_link_type_enabled_bundles($entity_type) {
......
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