Browse Source

Anomalie #816: Err 500 getOne

Bastien Sevajol 11 years ago
parent
commit
412ca27c59

+ 2 - 0
app/Resources/translations/elements.en.yml View File

9
   
9
   
10
   sentence_filter_link_string: delete them.
10
   sentence_filter_link_string: delete them.
11
   
11
   
12
+  nofound_anymore:      Share not found (maybe deleted by owner)
13
+  
12
 element:
14
 element:
13
   favorite:
15
   favorite:
14
     add:                Add to faves
16
     add:                Add to faves

+ 1 - 0
app/Resources/translations/elements.fr.yml View File

8
                          <br />Vous pouvez ajouter des tags ou
8
                          <br />Vous pouvez ajouter des tags ou
9
                          <a class="filter_clear_url" href="#" >%link_string%</a>.
9
                          <a class="filter_clear_url" href="#" >%link_string%</a>.
10
   sentence_filter_link_string: les retirer
10
   sentence_filter_link_string: les retirer
11
+  nofound_anymore:      Le partage est introuvable (il peut avoir été supprimé par son auteur)
11
   
12
   
12
 element:
13
 element:
13
   favorite:
14
   favorite:

+ 4 - 2
src/Muzich/CoreBundle/Controller/ElementController.php View File

1085
     if (!($element = $es->getElements($this->getDoctrine(), $this->getUserId(true), 'single')))
1085
     if (!($element = $es->getElements($this->getDoctrine(), $this->getUserId(true), 'single')))
1086
     {
1086
     {
1087
       return $this->jsonResponse(array(
1087
       return $this->jsonResponse(array(
1088
-      'status'  => 'error'
1089
-    ));
1088
+        self::RESPONSE_STATUS_ID  => self::RESPONSE_STATUS_ERROR,
1089
+        self::RESPONSE_ERROR_ID   => self::ERROR_TYPE_NOTFOUND,
1090
+        self::RESPONSE_MESSAGE_ID => $this->trans('noelements.nofound_anymore', array(), 'elements')
1091
+      ));
1090
     }
1092
     }
1091
     
1093
     
1092
     $html = $this->render('MuzichCoreBundle:SearchElement:li.element.html.twig', array(
1094
     $html = $this->render('MuzichCoreBundle:SearchElement:li.element.html.twig', array(

+ 6 - 0
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

3141
           function(){}
3141
           function(){}
3142
         );
3142
         );
3143
 
3143
 
3144
+        line.find('img.loader').hide();
3144
         if (response.status === 'success')
3145
         if (response.status === 'success')
3145
         {
3146
         {
3146
           line.find('div.content_opened').html('<ul class="elements">' + response.data + '</ul>');
3147
           line.find('div.content_opened').html('<ul class="elements">' + response.data + '</ul>');
3147
         }
3148
         }
3149
+        else
3150
+        if (response.status === 'error')
3151
+        {
3152
+          line.find('div.content_opened').html(response.message);
3153
+        }
3148
       });
3154
       });
3149
     }
3155
     }
3150
     else
3156
     else

+ 10 - 1
src/Muzich/CoreBundle/Searcher/ElementSearcher.php View File

3
 namespace Muzich\CoreBundle\Searcher;
3
 namespace Muzich\CoreBundle\Searcher;
4
 
4
 
5
 use Doctrine\Bundle\DoctrineBundle\Registry;
5
 use Doctrine\Bundle\DoctrineBundle\Registry;
6
+use Doctrine\ORM\NoResultException;
6
 
7
 
7
 class ElementSearcher extends Searcher implements SearcherInterface
8
 class ElementSearcher extends Searcher implements SearcherInterface
8
 {
9
 {
341
       break;
342
       break;
342
     
343
     
343
       case 'single':
344
       case 'single':
344
-        return $query->getSingleResult();
345
+        try
346
+        {
347
+          return $query->getSingleResult();
348
+        } 
349
+        catch (NoResultException $exc)
350
+        {
351
+          return null;
352
+        }
353
+        
345
       break;
354
       break;
346
     
355
     
347
       default :
356
       default :

+ 8 - 0
src/Muzich/CoreBundle/lib/Controller.php View File

20
 class Controller extends BaseController
20
 class Controller extends BaseController
21
 {
21
 {
22
   
22
   
23
+  const RESPONSE_STATUS_ID = 'status';
24
+  const RESPONSE_ERROR_ID = 'error';
25
+  const RESPONSE_MESSAGE_ID = 'message';
26
+  const RESPONSE_STATUS_ERROR = 'error';
27
+  
28
+  const ERROR_TYPE_NOTFOUND = 'notfound';
29
+  const ERROR_TYPE_MUSTBECONNECTED = 'mustbeconnected';
30
+  
23
   protected static $user = null;
31
   protected static $user = null;
24
   protected static $user_personal_query = null;
32
   protected static $user_personal_query = null;
25
   protected static $tags = array();
33
   protected static $tags = array();