[pLog-svn] r3093 - plog/trunk/class/dao

mark at devel.lifetype.net mark at devel.lifetype.net
Wed Mar 22 06:09:03 GMT 2006


Author: mark
Date: 2006-03-22 06:09:01 +0000 (Wed, 22 Mar 2006)
New Revision: 3093

Modified:
   plog/trunk/class/dao/articles.class.php
Log:
Fix a error if the globalArticleCategory is a null object. Oscar I need you help to review this.

Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php	2006-03-21 15:19:46 UTC (rev 3092)
+++ plog/trunk/class/dao/articles.class.php	2006-03-22 06:09:01 UTC (rev 3093)
@@ -744,15 +744,21 @@
 			include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
 			$cats = new GlobalArticleCategories();
 			$artCategory = $article->getGlobalCategory();
-			$artCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()));
-			$artCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
-			$cats->updateGlobalArticleCategory( $artCategory );
 			
+			if ($artCategory) {
+				$artCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()));
+				$artCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$artCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
+				$cats->updateGlobalArticleCategory( $artCategory );
+			}
+			
 			if( $oldArticle ) {
 				$oldCategory = $oldArticle->getGlobalCategory();
-				$oldCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()));
-				$oldCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
-				$cats->updateGlobalArticleCategory( $oldCategory );				
+				if ($oldCategory)
+				{
+					$oldCategory->setNumArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()));
+					$oldCategory->setNumActiveArticles( $this->getNumItems( $this->getPrefix()."articles", "global_category_id = ".$oldCategory->getId()." AND status = ".POST_STATUS_PUBLISHED ));
+					$cats->updateGlobalArticleCategory( $oldCategory );
+				}		
 			}
 			
 			return( true );



More information about the pLog-svn mailing list