From: Stéphane Jacob Date: Wed, 20 Apr 2011 21:01:32 +0000 (+0200) Subject: Do not iter on null objects. X-Git-Tag: xorg/1.1.1~37^2~1 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1ee74a83627ec5886223f8bb7fae2c79a5d71818;p=platal.git Do not iter on null objects. Signed-off-by: Stéphane Jacob --- diff --git a/modules/register/register.inc.php b/modules/register/register.inc.php index 47e59d2..17f9789 100644 --- a/modules/register/register.inc.php +++ b/modules/register/register.inc.php @@ -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 !';