Commit 1a4b427d authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3306799 by DamienMcKenna: Pubdate values use the wrong format.

parent a1e01b4b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Views RSS 8.x-2.x-dev, 2022-xx-xx
#3303702 by DamienMcKenna: Fix site slogan option on channel description.
#3305462 by DamienMcKenna: Test coverage for the channel output.
#3306603 by DamienMcKenna: Test coverage for channel link.
#3306799 by DamienMcKenna: Pubdate values use the wrong format.


Views RSS 8.x-2.0-rc1, 2022-04-29
+5 −3
Original line number Diff line number Diff line
@@ -312,10 +312,11 @@ function views_rss_core_preprocess_views_view_rss(&$variables) {
    foreach ($variables['rows'] as $row) {
      foreach ($row['#row']->elements as $element) {
        if ($element['key'] === 'pubDate') {
          $this_pub_date = (string) $element['value'];
          if (!$max_pub_date || strtotime($this_pub_date) > strtotime($max_pub_date)) {
          $this_pub_date = strtotime((string) $element['value']);
          if (!$max_pub_date || $this_pub_date > $max_pub_date) {
            $max_pub_date = $this_pub_date;
          }
          $element['value'] = views_rss_format_date($this_pub_date);
          break;
        }
      }
@@ -324,7 +325,8 @@ function views_rss_core_preprocess_views_view_rss(&$variables) {
      $variables['channel_elements']['pubDate'] = [
        '#type' => 'html_tag',
        '#tag' => 'pubDate',
        '#value' => $max_pub_date,
        // Convert the date value to RFC-822 format.
        '#value' => views_rss_format_date($max_pub_date),
      ];
    }
  }
+2 −2
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ class DisplayFeedTest extends BrowserTestBase {
    $this->assertStringContainsString('views-rss.xml?field_tags_target_id=1', $this->getSession()->getDriver()->getText('//item/source/@url'));

    // Verify the channel pubDate matches the highest node pubDate.
    $this->assertEquals(gmdate('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate'));
    $this->assertEquals(date('r', $node->getCreatedTime()), $this->getSession()->getDriver()->getText('//channel/pubDate'));
    $this->assertGreaterThanOrEqual($this->testStartTime, strtotime($this->getSession()->getDriver()->getText('//channel/lastBuildDate')));
  }

@@ -145,7 +145,7 @@ class DisplayFeedTest extends BrowserTestBase {
    $this->drupalGet('views-rss.xml');
    $this->assertSession()->statusCodeEquals(200);
    $driver = $this->getSession()->getDriver();
    dump($this->getSession()->getDriver()->getContent());
    // dump($this->getSession()->getDriver()->getContent());

    // Verify the basic structure.
    // In order to select the root element you have to specify "any element at
+13 −0
Original line number Diff line number Diff line
@@ -177,3 +177,16 @@ function views_rss_link_to_front_page() {
  }
  return $url;
}

/**
 * Output a timestamp in the format required for RSS.
 *
 * @param int $timestamp
 *   A timestamp value.
 *
 * @return string
 *   The timestamp value in the required format.
 */
function views_rss_format_date($timestamp) {
  return date('r', $timestamp);
}