Joomla! Discussion Forums



It is currently Tue Nov 24, 2009 1:12 pm (All times are UTC )

 





Post new topic Reply to topic  [ 9 posts ] 
Author Message
Posted: Wed Sep 12, 2007 7:07 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Jul 15, 2006 6:27 pm
Posts: 37
Recent changes (rev. 8841) to JUser::getTable() removed this line:

Code:
$table->load($this->id);


This causes the global $my, as set up in legacy.php, to be empty:

Code:
      $user            =& JFactory::getUser();
      $GLOBALS['my']      = clone($user->getTable());
      $GLOBALS['my']->gid   = $user->get('aid', 0);


Adjusting legacy.php to be like this works:

Code:
      $user            =& JFactory::getUser();
      $GLOBALS['my']      = clone($user->getTable());
      $GLOBALS['my']->load($user->id);
      $GLOBALS['my']->gid   = $user->get('aid', 0);


But, shouldn't JUSer::getTable() return a valid user table for the current user?

Greg

_________________
http://www.virtuemart.net
http://www.plainlycode.com


Last edited by Jinx on Thu Sep 13, 2007 6:26 pm, edited 1 time in total.

Top
  E-mail  
 
Posted: Wed Sep 12, 2007 7:12 pm 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Thu Aug 18, 2005 10:41 am
Posts: 15089
Q&T; marking as under review

_________________
Regards Robin


Top
   
 
Posted: Thu Sep 13, 2007 4:05 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Wed Sep 21, 2005 9:25 am
Posts: 1542
Location: Thailand
Confirmed.

Code:
                // Create the user table object
-               $table  =& JTable::getInstance( 'user');
-               $table->load($this->id);
-
+               $table  =& JTable::getInstance( $tabletype);


Johan, would there be any reason why we wouldn't want to load the table if the user object was populated?

Code:
if ( $this->id ) {
  $table->load($this->id);
}


If there is an issue, could we accept an additional arg to getTable() to toggle the loading of data?

tcp

_________________
http://www.gmitc.biz/


Top
   
 
Posted: Thu Sep 13, 2007 6:25 pm 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Aug 12, 2005 12:47 am
Posts: 6431
Fixed on SVN.

@Toby : for performance reasons getTable should only return a JTable object. Don't like to add to many functions params, makes the API less KISS.

_________________
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.nooku.org - multi-lingual content manager and rapid extension development framework for Joomla 1.5
http://www.joomlatools.eu - training, consulting and extension development


Top
   
 
Posted: Thu Sep 13, 2007 6:28 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Jul 15, 2006 6:27 pm
Posts: 37
Thanks.

There is a typo:

Code:
$BLOBALS['my']      = $table->load($user->id);


Should be a G.

Greg

_________________
http://www.virtuemart.net
http://www.plainlycode.com


Top
  E-mail  
 
Posted: Thu Sep 13, 2007 6:39 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Wed Sep 21, 2005 9:25 am
Posts: 1542
Location: Thailand
@jinx: botchay.  But why is bregdev talkinb about my blobals?

Fixed in Rev 8870

_________________
http://www.gmitc.biz/


Top
   
 
Posted: Thu Sep 13, 2007 7:47 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Jul 15, 2006 6:27 pm
Posts: 37
OK. I looked more closely. This bug is not fixed. I guess the B distracted me.

The current code is like this:

Code:
      $user            =& JFactory::getUser();
      $table            = clone($user->getTable());
      $GLOBALS['my']      = $table->load($user->id);
      $GLOBALS['my']->gid   = $user->get('aid', 0);


This line is bad:

Code:
      $GLOBALS['my']      = $table->load($user->id);


$table->load($user->id) returns a boolean, not a JTable object.

Something like my original post would work.

Thanks,

Greg

_________________
http://www.virtuemart.net
http://www.plainlycode.com


Top
  E-mail  
 
Posted: Thu Sep 13, 2007 8:08 pm 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Aug 12, 2005 12:47 am
Posts: 6431
Should be fixed now.

_________________
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.nooku.org - multi-lingual content manager and rapid extension development framework for Joomla 1.5
http://www.joomlatools.eu - training, consulting and extension development


Top
   
 
Posted: Thu Sep 13, 2007 8:31 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Jul 15, 2006 6:27 pm
Posts: 37
OK now. Thanks.

_________________
http://www.virtuemart.net
http://www.plainlycode.com


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group