Do not iter on null objects.
authorStéphane Jacob <sj@m4x.org>
Wed, 20 Apr 2011 21:01:32 +0000 (23:01 +0200)
committerStéphane Jacob <sj@m4x.org>
Wed, 20 Apr 2011 21:01:32 +0000 (23:01 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/register/register.inc.php

index 47e59d2..17f9789 100644 (file)
@@ -64,16 +64,17 @@ function checkOldId($subState)
             new UFC_Promo('=', UserFilter::DISPLAY, $subState->s('promo')),
             new PFC_Not(new UFC_Registered(true))
     ));
-    $it = $uf->iterProfiles();
-    while ($profile = $it->next()) {
-        if ($profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) {
-            $subState->set('lastname', $profile->lastName());
-            $subState->set('firstname', $profile->firstName());
-            $subState->set('uid', $profile->owner()->id());
-            $subState->set('watch', $profile->owner()->watch);
-            $subState->set('birthdateRef', $profile->__get('birthdate_ref'));
-            $subState->set('xorgid', $profile->__get('xorg_id'));
-            return true;
+    if ($it = $uf->iterProfiles()) {
+        while ($profile = $it->next()) {
+            if ($profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) {
+                $subState->set('lastname', $profile->lastName());
+                $subState->set('firstname', $profile->firstName());
+                $subState->set('uid', $profile->owner()->id());
+                $subState->set('watch', $profile->owner()->watch);
+                $subState->set('birthdateRef', $profile->__get('birthdate_ref'));
+                $subState->set('xorgid', $profile->__get('xorg_id'));
+                return true;
+            }
         }
     }
 
@@ -82,14 +83,15 @@ function checkOldId($subState)
             new UFC_Promo('=', UserFilter::DISPLAY, $subState->s('promo')),
             new UFC_Registered(true)
     ));
-    $it = $uf->iterProfiles();
-    while ($profile = $it->next()) {
-        if ($profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) {
-            $subState->set('uid', $profile->owner()->id());
-            $subState->set('watch', $profile->owner()->watch);
-            $subState->set('birthdateRef', $profile->__get('birthdate_ref'));
-            $subState->set('xorgid', $profile->__get('xorg_id'));
-            return 'Tu es vraisemblablement déjà inscrit !';
+    if ($it = $uf->iterProfiles()) {
+        while ($profile = $it->next()) {
+            if ($profile->compareNames($subState->s('firstname'), $subState->s('lastname'))) {
+                $subState->set('uid', $profile->owner()->id());
+                $subState->set('watch', $profile->owner()->watch);
+                $subState->set('birthdateRef', $profile->__get('birthdate_ref'));
+                $subState->set('xorgid', $profile->__get('xorg_id'));
+                return 'Tu es vraisemblablement déjà inscrit !';
+            }
         }
     }
     return 'Erreur : vérifie que tu as bien orthographié ton nom !';