Pārlūkot izejas kodu

Added to Zend_Feed support for setting a guid element attr of isPermaLink to false when the guid is not a URI.
Fixes a validity issue with RSS feeds when generated.
Fixes ZF-2639 and ZF-5833


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19132 44c647ce-9c0f-0410-b52a-842ac1e357ba

padraic 16 gadi atpakaļ
vecāks
revīzija
0598b4a225
2 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. 3 0
      library/Zend/Feed/Rss.php
  2. 11 0
      tests/Zend/Feed/ImportTest.php

+ 3 - 0
library/Zend/Feed/Rss.php

@@ -411,6 +411,9 @@ class Zend_Feed_Rss extends Zend_Feed_Abstract
 
             if (isset($dataentry->guid)) {
                 $guid = $this->_element->createElement('guid', $dataentry->guid);
+                if (!Zend_Uri::check($dataentry->guid)) {
+                    $guid->setAttribute('isPermaLink', 'false');
+                }
                 $item->appendChild($guid);
             }
 

+ 11 - 0
tests/Zend/Feed/ImportTest.php

@@ -219,6 +219,17 @@ class Zend_Feed_ImportTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed::importArray($this->_getFullArray(), 'rss');
         $this->assertType('Zend_Feed_Rss', $feed);
     }
+    
+    /**
+     * Test the import of a RSS feed from an array
+     * @group ZF-5833
+     */
+    public function testRssImportSetsIsPermaLinkAsFalseIfGuidNotAUri()
+    {
+        $feed = Zend_Feed::importArray($this->_getFullArray(), 'rss');
+        $entry = $feed->current();
+        $this->assertEquals('false', $entry->guid['isPermaLink']);
+    }
 
     /**
      * Test the import of a RSS feed from an array