From 1ee74a83627ec5886223f8bb7fae2c79a5d71818 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 20 Apr 2011 23:01:32 +0200 Subject: [PATCH] Do not iter on null objects. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/register/register.inc.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) 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 !'; -- 2.1.4