Sync to resolve merge conflict, code style OCD

Current PR can't be automatically merged because of a PR changing the queries to use `JDatabaseQuery` instead.  To get around that (which helps gather more testing via the patch tester component), I've caught most of the way up to the current staging branch.  And because it needs to be done at some point and I have a mild OCD about it, a lot of code style stuff is cleaned up at https://github.com/mbabker/joomla-cms/commit/c40282f8cb15933ff2f784642620e1b8c11c618f