Browse Source

Zend_Feed_Writer: Prevent rendering of Atom Threaded comment count attribute and element if a comment count was not set (was defaulting to 0 if not set - but this may present false data)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20323 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 years ago
parent
commit
27e1eb6c0d
1 changed files with 6 additions and 8 deletions
  1. 6 8
      library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php

+ 6 - 8
library/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php

@@ -78,10 +78,9 @@ class Zend_Feed_Writer_Extension_Threading_Renderer_Entry
         $clink->setAttribute('type', 'text/html');
         $clink->setAttribute('href', $link);
         $count = $this->getDataContainer()->getCommentCount();
-        if (!$count) {
-            $count = 0;
+        if (!is_null($count)) {
+            $clink->setAttribute('thr:count', $count);
         }
-        $clink->setAttribute('thr:count', $count);
         $root->appendChild($clink);
     }
     
@@ -104,10 +103,9 @@ class Zend_Feed_Writer_Extension_Threading_Renderer_Entry
             $flink->setAttribute('type', 'application/'. $link['type'] .'+xml');
             $flink->setAttribute('href', $link['uri']);
             $count = $this->getDataContainer()->getCommentCount();
-            if (!$count) {
-                $count = 0;
+            if (!is_null($count)) {
+                $flink->setAttribute('thr:count', $count);
             }
-            $flink->setAttribute('thr:count', $count);
             $root->appendChild($flink);
         }
     }
@@ -122,8 +120,8 @@ class Zend_Feed_Writer_Extension_Threading_Renderer_Entry
     protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
     {
         $count = $this->getDataContainer()->getCommentCount();
-        if (!$count) {
-            $count = 0;
+        if (is_null($count)) {
+            return;
         }
         $tcount = $this->_dom->createElement('thr:total');
         $tcount->nodeValue = $count;