From 7e49d807831d2eda56b71fdec5a8fa53d6986849 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 16 Dec 2016 06:43:48 +0000 Subject: [PATCH] Feeds: Do not translate the `lastBuildDate` field in RSS feeds. Props stevenkword. Partial Merge of [39613] to the 4.7 branch. Fixes #39141. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39615 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/feed-rss2.php | 2 +- tests/phpunit/tests/feed/rss2.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/feed-rss2.php b/src/wp-includes/feed-rss2.php index a7b9ac7ec1..fa58e2440a 100644 --- a/src/wp-includes/feed-rss2.php +++ b/src/wp-includes/feed-rss2.php @@ -44,7 +44,7 @@ do_action( 'rss_tag_pre', 'rss2' ); assertEquals( strtotime( get_lastpostmodified() ), strtotime( $pubdate[0]['content'] ) ); } + /** + * Test that translated feeds have a valid listed date. + * @group 39141 + */ + function test_channel_pubdate_element_translated() { + $original_locale = $GLOBALS['wp_locale']; + /* @var WP_Locale $locale */ + $locale = clone $GLOBALS['wp_locale']; + + $locale->weekday[2] = 'Tuesday_Translated'; + $locale->weekday_abbrev[ 'Tuesday_Translated' ] = 'Tue_Translated'; + + $GLOBALS['wp_locale'] = $locale; + + $this->go_to( '/?feed=rss2' ); + $feed = $this->do_rss2(); + + // Restore original locale. + $GLOBALS['wp_locale'] = $original_locale; + + $xml = xml_to_array( $feed ); + + // Verify the date is untranslated. + $pubdate = xml_find( $xml, 'rss', 'channel', 'lastBuildDate' ); + $this->assertNotContains( 'Tue_Translated', $pubdate[0]['content'] ); + } + /** * @ticket UT32 */