? ? Pending

User tests: Successful: Unsuccessful:

avatar ggppdk
ggppdk
7 Jul 2017

Pull Request for Issue #16997

Summary of Changes

Currently there is a string with int comparison in the code (please see the code that i am chaning)
$root_user == $user_id

Example:
"somename" == 0 will return true,
because "somename" typecasted to integer is 0 , thus you get
0 == 0 which is true

There are several ways to fix the comparison, for consistenct, i choose to use same code as used in
JUser::authorize() method

Testing Instructions

  1. Make a module of "Registered" access level (better a module shown to all menu items)
  2. Add $root_user = "somename"; to configuration.php
  3. Visiting website without being logged

Expected result

The module is not showed

Actual result

The module is showed because all access levels have been granted to the guest user

Documentation Changes Required

None

avatar ggppdk ggppdk - open - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 7 Jul 2017
Category Libraries
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Jul 2017

@Artwebco @pabloarias please test if this PR solve #16997

avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 7 Jul 2017
The description was changed
avatar ggppdk ggppdk - edited - 7 Jul 2017
avatar ggppdk ggppdk - change - 10 Jul 2017
Labels Added: ?
avatar matrikular matrikular - test_item - 17 Jul 2017 - Tested successfully
avatar matrikular
matrikular - comment - 17 Jul 2017

I have tested this item successfully on cec254b

Since we don't need to check any further if $root_user is empty or the current user is a guest, how about this:

if (!empty($root_user) && (bool) $user->guest === false &&
	($root_user === $user->username || (is_numeric($root_user) && (int) $root_user === $user->id)))
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Jul 2017
Status Pending Information Required
avatar franz-wohlkoenig franz-wohlkoenig - change - 18 Aug 2017
Status Information Required Pending
avatar Heggi93 Heggi93 - test_item - 22 Aug 2017 - Tested successfully
avatar Heggi93
Heggi93 - comment - 22 Aug 2017

I have tested this item successfully on cec254b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17011.

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 Aug 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Aug 2017

RTC after two successful tests.

avatar izharaazmi
izharaazmi - comment - 22 Aug 2017

@ggppdk Can you please look at the conflicts.

409f8a5 22 Aug 2017 avatar ggppdk CS
8328b7f 22 Aug 2017 avatar ggppdk CS
5d04315 22 Aug 2017 avatar ggppdk CS
avatar ggppdk ggppdk - change - 22 Aug 2017
Labels Added: Conflicting Files ?
avatar ggppdk
ggppdk - comment - 22 Aug 2017

Resolved conflicts

avatar zero-24
zero-24 - comment - 26 Sep 2017

Merging as the conflicts are resolved and the patch still works as expected thanks @ggppdk

avatar zero-24 zero-24 - change - 26 Sep 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-09-26 22:18:26
Closed_By zero-24
Labels Removed: Conflicting Files
avatar zero-24 zero-24 - close - 26 Sep 2017
avatar zero-24 zero-24 - merge - 26 Sep 2017

Add a Comment

Login with GitHub to post a comment