From be73ba57ade2226169b87cb315cd8d1922f74349 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Wed, 30 May 2012 02:19:09 +0200 Subject: [PATCH] Fixed issue when no ads with default language. Right know I let users create ads without the default language. That must be fixed. --- apps/userfront/modules/api/actions/actions.class.php | 2 -- lib/model/doctrine/AdDescriptionTable.class.php | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) 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; -- 2.1.4