Przeglądaj źródła

Anomalie #816: Err 500 getOne

Bastien Sevajol 11 lat temu
rodzic
commit
412ca27c59

+ 2 - 0
app/Resources/translations/elements.en.yml Wyświetl plik

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

+ 1 - 0
app/Resources/translations/elements.fr.yml Wyświetl plik

@@ -8,6 +8,7 @@ noelements:
8 8
                          <br />Vous pouvez ajouter des tags ou
9 9
                          <a class="filter_clear_url" href="#" >%link_string%</a>.
10 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 13
 element:
13 14
   favorite:

+ 4 - 2
src/Muzich/CoreBundle/Controller/ElementController.php Wyświetl plik

@@ -1085,8 +1085,10 @@ class ElementController extends Controller
1085 1085
     if (!($element = $es->getElements($this->getDoctrine(), $this->getUserId(true), 'single')))
1086 1086
     {
1087 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 1094
     $html = $this->render('MuzichCoreBundle:SearchElement:li.element.html.twig', array(

+ 6 - 0
src/Muzich/CoreBundle/Resources/public/js/muzich.js Wyświetl plik

@@ -3141,10 +3141,16 @@ $(document).ready(function(){
3141 3141
           function(){}
3142 3142
         );
3143 3143
 
3144
+        line.find('img.loader').hide();
3144 3145
         if (response.status === 'success')
3145 3146
         {
3146 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 3156
     else

+ 10 - 1
src/Muzich/CoreBundle/Searcher/ElementSearcher.php Wyświetl plik

@@ -3,6 +3,7 @@
3 3
 namespace Muzich\CoreBundle\Searcher;
4 4
 
5 5
 use Doctrine\Bundle\DoctrineBundle\Registry;
6
+use Doctrine\ORM\NoResultException;
6 7
 
7 8
 class ElementSearcher extends Searcher implements SearcherInterface
8 9
 {
@@ -341,7 +342,15 @@ class ElementSearcher extends Searcher implements SearcherInterface
341 342
       break;
342 343
     
343 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 354
       break;
346 355
     
347 356
       default :

+ 8 - 0
src/Muzich/CoreBundle/lib/Controller.php Wyświetl plik

@@ -20,6 +20,14 @@ use Muzich\CoreBundle\Form\Playlist\PlaylistForm;
20 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 31
   protected static $user = null;
24 32
   protected static $user_personal_query = null;
25 33
   protected static $tags = array();