Fixed issue when no ads with default language.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 30 May 2012 00:19:09 +0000 (02:19 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 30 May 2012 00:19:09 +0000 (02:19 +0200)
Right know I let users create ads without the default language.
That must be fixed.

apps/userfront/modules/api/actions/actions.class.php
lib/model/doctrine/AdDescriptionTable.class.php

index d9fe629..f3b93d6 100644 (file)
@@ -39,8 +39,6 @@ class apiActions extends sfActions
   public function executeGetadsbygps(sfWebRequest $request)
   {
     //RESTFUL permits to use cookies to implement authentication (user / password)
-    $parameters = $this->getRoute()->getParameters();
-    $userId = $this->getUser()->getGuardUser()->getId();
 
     $this->ads = array();
     $this->ads = AdDescriptionTable::getInstance()->getAdsByGPSAndUserIdAndLanguageId($this->getRoute()->getParameters(),
index a65c7f6..8339438 100644 (file)
@@ -103,7 +103,13 @@ class AdDescriptionTable extends Doctrine_Table
                 //Return with the default language
                 $languageCode = sfConfig::get('app_default_language');
                 $languageId = LanguageTable::getInstance()->findOneByCode($languageCode)->getId();
-                $ads[] = $this->findOneByAdIdAndLanguageId($adId, $languageId);
+                $ad = $this->findOneByAdIdAndLanguageId($adId, $languageId);
+                //This should never happen if every ad has at least the language by default.
+                //TODO: Do not let the users create ads without the default language.
+                if ($ad != null)
+                {
+                    $ads[] = $ad;
+                }
             }
         }
         return $ads;