Joomla!
http://forum.joomla.org/

[FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC
http://forum.joomla.org/viewtopic.php?f=235&t=211859
Page 1 of 1

Author:  gregdev [ Wed Sep 12, 2007 7:07 pm ]
Post subject:  [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

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

Author:  Robin [ Wed Sep 12, 2007 7:12 pm ]
Post subject:  Re: Recent change (rev. 8841) to JUser::getTable() breaks BC

Q&T; marking as under review

Author:  tcp [ Thu Sep 13, 2007 4:05 pm ]
Post subject:  Re: [under review] Recent change (rev. 8841) to JUser::getTable() breaks BC

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

Author:  Jinx [ Thu Sep 13, 2007 6:25 pm ]
Post subject:  Re: [under review] Recent change (rev. 8841) to JUser::getTable() breaks BC

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.

Author:  gregdev [ Thu Sep 13, 2007 6:28 pm ]
Post subject:  Re: [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

Thanks.

There is a typo:

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


Should be a G.

Greg

Author:  tcp [ Thu Sep 13, 2007 6:39 pm ]
Post subject:  Re: [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

@jinx: botchay.  But why is bregdev talkinb about my blobals?

Fixed in Rev 8870

Author:  gregdev [ Thu Sep 13, 2007 7:47 pm ]
Post subject:  Re: [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

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

Author:  Jinx [ Thu Sep 13, 2007 8:08 pm ]
Post subject:  Re: [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

Should be fixed now.

Author:  gregdev [ Thu Sep 13, 2007 8:31 pm ]
Post subject:  Re: [FIXED] Recent change (rev. 8841) to JUser::getTable() breaks BC

OK now. Thanks.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/