Skip to content
Snippets Groups Projects
Commit 59f40d26 authored by Damien McKenna's avatar Damien McKenna
Browse files

Issue #3446813 by ivnish, doxigo, damienmckenna: Warning: Undefined array key...

Issue #3446813 by ivnish, doxigo, damienmckenna: Warning: Undefined array key "#row" in views_rss_core_preprocess_views_view_rss().
parent 09104e5a
No related branches found
No related tags found
No related merge requests found
Pipeline #284364 passed with warnings
......@@ -16,6 +16,8 @@ Advanced Views RSS Feed 8.x-2.x-dev, 202x-xx-xx
#3419023 by DamienMcKenna: Tighten up output, remove unnecessary whitespace.
#3451387 by Project Update Bot, DamienMcKenna: Automated Drupal 11 compatibility
fixes.
#3446813 by ivnish, doxigo, damienmckenna: Warning: Undefined array key "#row"
in views_rss_core_preprocess_views_view_rss().
Advanced Views RSS Feed 8.x-2.2, 2023-09-24
......
......@@ -313,11 +313,14 @@ function views_rss_core_preprocess_views_view_rss(&$variables) {
if (count($view->result) > 0) {
$max_pub_date = NULL;
foreach ($variables['rows'] as $row) {
foreach ($row['#row']->elements as $element) {
if (isset($row['#row']) && is_object($row['#row']) && property_exists($row['#row'], 'elements')) {
$elements = $row['#row']->elements;
if (is_array($elements) || is_object($elements)) {
foreach ($elements as $element) {
if ($element['key'] === 'pubDate') {
// This string cannot be parsed if there is a dash present.
// Unfortunately the default date output format for Drupal includes a
// dash, so remove it.
// Unfortunately the default date output format for Drupal
// includes a dash, so remove it.
$this_pub_date = (string) $element['value'];
$this_pub_date = str_replace(' - ', ' ', $this_pub_date);
$this_pub_date = strtotime($this_pub_date);
......@@ -328,6 +331,18 @@ function views_rss_core_preprocess_views_view_rss(&$variables) {
}
}
}
// Ensure that the max value is neither the default NULL value nor a
// zero which would result in the date showing as January 1st, 1970.
if (!empty($max_pub_date)) {
$variables['channel_elements']['pubDate'] = [
'#type' => 'html_tag',
'#tag' => 'pubDate',
// Convert the date value to RFC-822 format.
'#value' => views_rss_format_date($max_pub_date),
];
}
}
}
// Ensure that the max value is neither the default NULL value nor a zero
// which would result in the date showing as January 1st, 1970.
if (!empty($max_pub_date)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment