Curiously, this line will thrown an error even when I'm authenticated:

$sf_user->getGuardUser()->getId()


The method getGuardUser() seems to return nothing. Oddly, if I wish to
go to a secure page that has been defined with this security:

all:
  is_secure:  off

memberList:
  is_secure:  on


I can go to memberList and see all the members, as if I'm logged in,
yet this still returns nothing:

$sf_user->getGuardUser()

$sf_user is an instance of myUser, which descend from
sfGuardSecurityUser and which has this method:


  public function getGuardUser()
  {
    if (!$this->user && $id = $this->getAttribute('user_id', null,
'sfGuardSecurityUser'))
    {
      $this->user = sfGuardUserPeer::retrieveByPk($id);

      if (!$this->user)
      {
        // the user does not exist anymore in the database
        $this->signOut();

        throw new sfException('The user does not exist anymore in the
database.');
      }
    }
    return $this->user;
  }




On Sep 19, 12:14 am, Jake Barnes <[email protected]> wrote:
> The following code always works for me. I can go to the front page of
> the site, and I can log in and I never get an error.
>
> For one of my clients, the site works great in FireFox, but throws an
> error in Google Chrome. For another of my clients, the following code
> dies with a fatal error all the time. The error is that the method
> "getId()" is being called on either a non-existent object, or an
> object without that method. In other words, this line throws a fatal
> error:
>
> $sf_user->getGuardUser()->getId()
>
> This code appears in layout.php.
>
> Here is the code:
>
> <?php if(isset($sf_user)): ?>
>
>   <?php if($sf_user->isAuthenticated()): ?>
>
>     <?php $criteriaToFindProfile = new Criteria();
> $criteriaToFindProfile->add(sfGuardUserProfilePeer::USER_ID, 
> $sf_user->getGuardUser()->getId()); $thisUsersProfile =
>
> sfGuardUserProfilePeer::doSelectOne($criteriaToFindProfile); ?>
>
>     <?php if (@ is_object($thisUsersProfile)): $username =
> $thisUsersProfile->getFirstName()." "; $username .= $thisUsersProfile-
>
> >getLastName(); if (!$username) $username = $thisUsersProfile-
> >getsfGuardUser()->getUsername(); endif; ?>
>
>     <?php if (@ is_object($thisUsersProfile)): ?><p>Hello, <a
> id="userid" href="<?php echo url_for('content/profile?id='.
> $thisUsersProfile->getId()) ?>"><?php echo $username ?>!</a></p><?php
> endif ?>
>     <a href="<?php echo url_for("sfGuardAuth/signout") ?>"><img src="<?
> php echo image_path('logout.png') ?>" alt="LOGOUT" /></a>
>
>   <?php endif; ?>
>
> <?php endif; ?>
>
> Can anyone think why this would behave differently on different
> people's browsers?
>
> I'm having trouble fixing this bug, because I can not recreate it on
> my own machine.
>
> What is really bizarre is that my clients browser somehow got past
> this line:
>
>  <?php if($sf_user->isAuthenticated()): ?>
>
> Since the page always died for them with a fatal error, they had no
> way to log in.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to