Browse Source

Add check for simple category elements.

Fixes #2655
mark_story 14 years ago
parent
commit
3a8c49e319

+ 31 - 0
lib/Cake/Test/Case/View/Helper/RssHelperTest.php

@@ -436,6 +436,37 @@ class RssHelperTest extends CakeTestCase {
 			'/item'
 		);
 		$this->assertTags($result, $expected);
+
+		$item = array(
+			'title' => 'My title',
+			'description' => 'My description',
+			'link' => 'http://www.google.com/',
+			'category' => array('Category One', 'Category Two')
+		);
+		$result = $this->Rss->item(null, $item);
+		$expected = array(
+			'<item',
+			'<title',
+			'My title',
+			'/title',
+			'<description',
+			'My description',
+			'/description',
+			'<link',
+			'http://www.google.com/',
+			'/link',
+			'<category',
+			'Category One',
+			'/category',
+			'<category',
+			'Category Two',
+			'/category',
+			'<guid',
+			'http://www.google.com/',
+			'/guid',
+			'/item'
+		);
+		$this->assertTags($result, $expected);
 	}
 
 /**

+ 1 - 1
lib/Cake/View/Helper/RssHelper.php

@@ -212,7 +212,7 @@ class RssHelper extends AppHelper {
 					if (is_array($val) && !empty($val[0])) {
 						foreach ($val as $category) {
 							$attrib = array();
-							if (isset($category['domain'])) {
+							if (is_array($category) && isset($category['domain'])) {
 								$attrib['domain'] = $category['domain'];
 								unset($category['domain']);
 							}