[pLog-svn] r5302 - in plog/branches/lifetype-1.2/class: dao test/tests/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Apr 12 17:09:19 EDT 2007


Author: oscar
Date: 2007-04-12 17:09:19 -0400 (Thu, 12 Apr 2007)
New Revision: 5302

Modified:
   plog/branches/lifetype-1.2/class/dao/article.class.php
   plog/branches/lifetype-1.2/class/test/tests/dao/article_test.class.php
Log:
Fix for mantis issue 1244 (http://bugs.lifetype.net/view.php?id=1244) -- Article::getComments() not using the internal array.


Modified: plog/branches/lifetype-1.2/class/dao/article.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/article.class.php	2007-04-10 20:54:54 UTC (rev 5301)
+++ plog/branches/lifetype-1.2/class/dao/article.class.php	2007-04-12 21:09:19 UTC (rev 5302)
@@ -330,11 +330,14 @@
 		function getComments( $status = COMMENT_STATUS_NONSPAM )
 		{
 			// load the comments if they haven't been loaded yet
-			lt_include( PLOG_CLASS_PATH.'class/dao/articlecomments.class.php' );			
-			$userComments =  new ArticleComments();
-			$blogInfo = $this->getBlogInfo();
-			$blogSettings = $blogInfo->getSettings();
-			return( $userComments->getPostComments( $this->getId(), $blogSettings->getValue( 'comments_order' ), $status ));
+			if( is_null( $this->_comments[$status] )) {
+				lt_include( PLOG_CLASS_PATH.'class/dao/articlecomments.class.php' );			
+				$userComments =  new ArticleComments();
+				$blogInfo = $this->getBlogInfo();
+				$blogSettings = $blogInfo->getSettings();
+				$this->setComments( $userComments->getPostComments( $this->getId(), $blogSettings->getValue( 'comments_order' ), $status ), $status );
+			}	
+			return( $this->_comments[$status] );
 		}
 		
         /**
@@ -545,11 +548,12 @@
         /**
          * @private
          */
-		function setComments( $comments )
+		function setComments( $comments, $status = COMMENT_STATUS_NONSPAM )
 		{
-			$this->_comments = $comments;
-			if( !is_array( $this->_comments ))
-				$this->_comments = Array();
+			if( !isset( $this->_comments[$status] ))
+				$this->_comments[$status] = Array();
+				
+			$this->_comments[$status] = $comments;
 			
 			return true;
 		}

Modified: plog/branches/lifetype-1.2/class/test/tests/dao/article_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/dao/article_test.class.php	2007-04-10 20:54:54 UTC (rev 5301)
+++ plog/branches/lifetype-1.2/class/test/tests/dao/article_test.class.php	2007-04-12 21:09:19 UTC (rev 5302)
@@ -69,10 +69,20 @@
 								  "text"
 			     );
 			
+			$cSpam = new UserComment( $this->article->getId(), 
+								  $this->article->getBlogId(), 
+								  0, 
+								  "topic spam", 
+								  "text spam"
+			     );
+			$cSpam->setStatus( COMMENT_STATUS_SPAM );
+			
 			// now calling Article::getComments() after Article::setComments() with the dummy comment above
 			// should not return the same
 			$this->article->setComments( Array( $c ));
+			$this->article->setComments( Array( $cSpam ), COMMENT_STATUS_SPAM );
 			$this->assertEquals( Array( $c ), $this->article->getComments());
+			$this->assertEquals( Array( $cSpam ), $this->article->getComments( COMMENT_STATUS_SPAM ));
 		}
 	}
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list