joomla/joomla-platform — pull request #1416 by elinw (2012-07-28 01:50:48+00:00)
Title: Corrections to JAccess when there is an invalid or missing asset or parenting is to root.

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 is is 1. This solves problems when the asset table data has been created outside of Joomla and imported, possible 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.