Joomla 3.6.0 beta 2 - $user->get('isRoot')

224 views
Skip to first unread message

vales

unread,
Jun 28, 2016, 3:18:16 PM6/28/16
to Joomla! CMS Development

In the version of Joomla 3.6.0 Beta 2 does not work the method

$user =JFactory::getUser();
$user->get('isRoot')

When Super User is logged the method does not return the value true.

Regards

Viktor Vogel

unread,
Jun 29, 2016, 2:13:52 AM6/29/16
to Joomla! CMS Development
Hi Vales,

please report issues and bugs in the issue tracker: https://issues.joomla.org/

Thanks!

Viktor

Hannes Papenberg

unread,
Jun 29, 2016, 3:01:28 AM6/29/16
to joomla-...@googlegroups.com
You should NEVER use the isRoot attribute of JUser. Always use
->authorise() with the correct parameters. isRoot is an optimization in
Joomlas code and should never be used outside of JUser::authorise, nor
is it guaranteed to work at any point in time.

The behavior that you are describing is not a bug to me, but a feature.

Hannes

Izhar Aazmi

unread,
Jun 29, 2016, 4:13:59 AM6/29/16
to joomla-...@googlegroups.com
This is because the 'isRoot' attribute is never populated unless a call is made to JUser::authorise() method on the instance. Previously it worked (still only for logged in user) because the user instance was stored in the session with any changes made to it persistent.

With J3.6 it is always a fresh instance on each request. See https://github.com/joomla/joomla-cms/pull/8805 and https://github.com/joomla/joomla-cms/pull/10356 for details.

Prior to J3.6, if some extension or library for some reason makes a call the JUser::authorise() method then the 'isRoot' was populated and was made available to all subsequent page loads due to the persistence. It anyway was never applicable for other user than the one logged in.

But this is not the correct thing to rely upon some other code to do something that you require.

So you must make a call to $user->authorise method before you should rely on isRoot parameter. But I wonder, why would you use isRoot when you anyway have to call authorise.

Better to follow what  Hannes already said. NEVER use isRoot attribute as it is strictly meant for internal optimisation.

--

klas berlič

unread,
Jun 29, 2016, 6:31:39 AM6/29/16
to joomla-...@googlegroups.com
isRoot attribute as it is strictly meant for internal optimisation.

Then it should not be public. Public part of api should always be working and guaranteed to be the same in the future.

Regards

--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send email to joomla-...@googlegroups.com.

Izhar Aazmi

unread,
Jun 29, 2016, 6:44:56 AM6/29/16
to joomla-...@googlegroups.com
I agree on this. It is indeed protected. But the JObject::get method returns it anyway. You won't be able to use it like $user->isRoot.

Hannes Papenberg

unread,
Jun 29, 2016, 7:04:22 AM6/29/16
to joomla-...@googlegroups.com
Line 27 of JUser
protected $isRoot = null;

Am 29.06.2016 um 12:31 schrieb klas berlič:
> /isRoot attribute as it is strictly meant for internal optimisation./
>
> Then it should not be public. Public part of api should always be
> working and guaranteed to be the same in the future.
>
> Regards
>
> 2016-06-29 10:13 GMT+02:00 Izhar Aazmi <izhar...@gmail.com
> <mailto:izhar...@gmail.com>>:
> <mailto:joomla-dev-cm...@googlegroups.com>.
> To post to this group, send email to joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.
>
> Visit this group at https://groups.google.com/group/joomla-dev-cms.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! CMS Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to joomla-dev-cm...@googlegroups.com
> <mailto:joomla-dev-cm...@googlegroups.com>.
> To post to this group, send email to joomla-...@googlegroups.com
> <mailto:joomla-...@googlegroups.com>.

Niels Braczek

unread,
Jun 29, 2016, 7:22:18 AM6/29/16
to joomla-...@googlegroups.com
Am 29.06.2016 um 12:44 schrieb Izhar Aazmi:

> I agree on this. It is indeed protected. But the JObject::get method
> returns it anyway. You won't be able to use it like $user->isRoot.

JObject is deprecated.

Regards,
Niels

--
| New Stars on the Horizon: GreenCape · nibralab · laJoom |
| http://www.bsds.de · BSDS Braczek Software- und DatenSysteme |
| Webdesign · Webhosting · e-Commerce · Joomla! Content Management |
------------------------------------------------------------------

Michael Babker

unread,
Jun 29, 2016, 8:11:23 AM6/29/16
to joomla-...@googlegroups.com
The dangerous thing about anything extending JObject is that there are no class variables that are not public because of its get and set methods.  So even though the variable is declared protected when interacting with them through these two methods they're as good as public.

Izhar Aazmi

unread,
Jun 29, 2016, 8:20:07 AM6/29/16
to joomla-...@googlegroups.com
can we have a get/set method of JUser of its own not behaving like JObject? What are B/C complications which are actually harmful with this?

Michael Babker

unread,
Jun 29, 2016, 8:27:02 AM6/29/16
to joomla-...@googlegroups.com
Can you?  Sure.  Should you?  Probably not.  If you implement one that properly scope limits it's technically a B/C break because you're changing a behavior (even if it's against the API documentation it's the explicitly expected behavior right now).

Reply all
Reply to author
Forward
0 new messages