This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
Corrections to JAccess when there is an invalid or missing asset or parenting is to root. #1416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although there is some confusion in the wording examination of the comments and docblocks of JAccess indicates that if there is parenting to the root asset or there is an invalid asset that the rules from the root asset should be used. For various reasons this was not actually working in the current class. This has been causing problems for developers who wish to parent assets from the root asset. In addition this corrects a situation where as a result of the asset_id being privately manage a corrupted asset_id could never be corrected using the class.
The approach to solving this involved several steps.
First, change the code so that the id of the root asset is always obtained using the API rather than assuming either that the parent_id is 0 or that the id is 1. This solves problems when the asset table data has been created outside of Joomla and imported, possibly with the root not as the first record.
Second, when there are no rules available, for example when the asset is not found, the root asset rules are used regardless of whether the rules are being treated as recursive or not. This is important for a number of reasons not least of which is it provides super user permissions if available. Previously in this situation the super user did not have special super user permissions.
Third, there are some complications when getActions/getActionsFromFile/getActionsFromData do not include a section that matches an asset (that is that final assets are parented to the root asset with nothing akin to a component in between). In this case, such assets will now fall back to the root asset for their rules unless something else is provided.
Fourth, a number of the tests for JRules and JAccess had incorrect expected results. These have been corrected.