? ? Failure

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
1 Jun 2017

As discussed in #16411 (comment)

Summary of Changes

This changes JAccess::getAuthorisedViewLevels() to return all viewlevels in case the user is Super User (has global core.admin permissions).
At the same time, it simplifies the check for root users as $user->authorise already checks for that.

Testing Instructions

As long as #16411 isn't merged, the same check could be done. This is basically an alternative way of fixing it.

Documentation Changes Required

This is a different behavior of the method from today, however since the root user already has that behavior, it imho would make sense to threat super users the same as root users.

avatar Bakual Bakual - open - 1 Jun 2017
avatar Bakual Bakual - change - 1 Jun 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Jun 2017
Category Libraries
avatar Bakual
Bakual - comment - 1 Jun 2017

@mbabker Please review

avatar mbabker
mbabker - comment - 1 Jun 2017

As long as the authorise check works for a root user without explicitly checking it, this seems fine to me.

avatar Bakual
Bakual - comment - 1 Jun 2017

As long as the authorise check works for a root user without explicitly checking it, this seems fine to me.

Looks like very similar checks to me:
(from JUser::authorise: https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/user/user.php#L366-L377)

// Check for the configuration file failsafe.
$rootUser = JFactory::getConfig()->get('root_user');
// The root_user variable can be a numeric user ID or a username.
if (is_numeric($rootUser) && $this->id > 0 && $this->id == $rootUser)
{
	$this->isRoot = true;
}
elseif ($this->username && $this->username == $rootUser)
{
	$this->isRoot = true;
}
avatar mbabker
mbabker - comment - 1 Jun 2017

Then we're good.

avatar Bakual
Bakual - comment - 1 Jun 2017

Except that the unit tests fail since this changes the behavior. ?

avatar Bakual Bakual - change - 1 Jun 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 1 Jun 2017
Category Libraries Libraries Unit Tests
avatar Bakual Bakual - change - 1 Jun 2017
Labels Added: ?
avatar Bakual
Bakual - comment - 1 Jun 2017

I'm lost with that JUser test. @mbabker do you know why that fails?

avatar joomla-cms-bot joomla-cms-bot - change - 8 Jan 2018
Category Libraries Unit Tests CLI Libraries Unit Tests
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jan 2018
Category Libraries Unit Tests CLI Libraries Unit Tests
avatar Bakual
Bakual - comment - 8 Jan 2018

Rebased the PR. Still don't understand why the unit test fails.

avatar rdeutz rdeutz - assigned - 18 Aug 18
avatar ghost
ghost - comment - 19 Jul 2019

As long as #16411 isn't merged, the same check could be done. This is basically an alternative way of fixing it.

@Bakual #16411 is merged, but the Test Instructions are the same?

avatar Bakual
Bakual - comment - 19 Jul 2019

I guess you would have to set up a super user account where it hasn't permissions to view all viewlevels. I don't know if that is even possible to do. If not, it's just code review and checking nothing breaks in regards to viewlevels.

But then, I have still no clue how to fix the unit test...

avatar nicksavov
nicksavov - comment - 12 May 2020

We'd like to help with this one. Where does the issue stand? Is it only the unit test that needs fixing?

avatar Bakual
Bakual - comment - 12 May 2020

@nicksavov As far as I remember it's only the unit test, yes. I'm lost with those.

avatar rdeutz
rdeutz - comment - 15 Mar 2021

@Bakual can you update to latest staging, please

avatar Bakual Bakual - change - 15 Mar 2021
Labels Added: ?
avatar Bakual
Bakual - comment - 15 Mar 2021

Merged staging

avatar Bakual
Bakual - comment - 15 Mar 2021

Tests still fail and my understanding of testing fails as well.

avatar Hackwar
Hackwar - comment - 15 Mar 2021

Just noting here that this would break 3 of the websites that I'm managing. To my customers, this would be a breaking change. I'm pretty sure that I'm not the only one. Besides that, this breaks the Guest viewlevel feature for Superusers. I strongly suggest to not merge this.

avatar Bakual
Bakual - comment - 16 Mar 2021

Imho, it's indeed a change in behavior. But how it is breaking a site?
To my understanding, a SuperUser is meant to see everything, also guest stuff. And yes that means that a site may look ugly if logged in as SuperUser. Eg you already see articles which are not published as SuperUser.

avatar Hackwar
Hackwar - comment - 16 Mar 2021

I have several customers who work with superuser privileges in their daily work. Might not be the best solution, but it is what it is. One customer for example has 4 different usertypes on his site and each usertype has a complete separate set of menu items. Returning all viewlevels means, that instead of 4-6 top level menu items, you get around 20 items displayed. Besides that, each usertype has different sets of modules on a dashboard, again resulting in ~20 modules instead of 5, some of which don't work with superusers.

This is a breaking change.

avatar Fedik
Fedik - comment - 16 Mar 2021

While the changes makes sense, I agree with @Hackwar

Since we can create a custom menu in the backend it is actually very useful to have separated view levels.
Example:
Super User can have a default backend menu,
And Custom User only "Specific" menu (or many of them. depend from the site set up).

When this patch will be merged then Super User will have all custom menus, that will clutter backend view, and will be no easy way to work around.

it more like a "usability break" ?

avatar richard67
richard67 - comment - 16 Mar 2021

@Bakual Regarding unit tests: You see the failure here in drone only if you expand the log file so it's shown completely. The you can see:

There was 1 failure:

1) JUserTest::testGetAuthorisedViewLevels with data set "User42" (42, array(1, 2, 3, 4, 5))
Failed for user 42
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => 1
-    1 => 2
-    2 => 3
-    3 => 4
-    4 => 5
 )

/drone/src/tests/unit/suites/libraries/joomla/user/JUserTest.php:320

The problem could come from this line:

https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/joomla/user/JUserTest.php#L278

I think the expected value null needs to be adjusted to array(1, 2, 3, 4, 5) to reflect the change from this PR.

Does that help somehow?

avatar HLeithner
HLeithner - comment - 17 Mar 2021

As discussed in the maintainers chat and also explained here, it doesn't make sense to return all view levels for a super user and would break many workflows. A super user may is allowed to do everything but doesn't mean he/she should see everything. By returning all viewlevels it's not possible to "hide" anything for a super user account which would lead to an unable to use cms.

I'm closing this as discussed by the maintainers team. Thanks all for the comment and the effort.

avatar HLeithner HLeithner - close - 17 Mar 2021
avatar HLeithner HLeithner - change - 17 Mar 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-03-17 08:15:47
Closed_By HLeithner
Labels Added: ?
Removed: ?

Add a Comment

Login with GitHub to post a comment