From: Gustavo Martin Morcuende Date: Wed, 30 May 2012 00:19:09 +0000 (+0200) Subject: Fixed issue when no ads with default language. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=be73ba57ade2226169b87cb315cd8d1922f74349;p=mobi%2F.git Fixed issue when no ads with default language. Right know I let users create ads without the default language. That must be fixed. --- diff --git a/apps/userfront/modules/api/actions/actions.class.php b/apps/userfront/modules/api/actions/actions.class.php index d9fe629..f3b93d6 100644 --- a/apps/userfront/modules/api/actions/actions.class.php +++ b/apps/userfront/modules/api/actions/actions.class.php @@ -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(), diff --git a/lib/model/doctrine/AdDescriptionTable.class.php b/lib/model/doctrine/AdDescriptionTable.class.php index a65c7f6..8339438 100644 --- a/lib/model/doctrine/AdDescriptionTable.class.php +++ b/lib/model/doctrine/AdDescriptionTable.class.php @@ -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;