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