#5138 closed enhancement (fixed)
Audit & replace $bp global touches with wrapper functions & methods
Reported by: | johnjamesjacoby | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | normal | Version: | 1.0 |
Component: | Route Parser | Keywords: | |
Cc: |
Description (last modified by )
BuddyPress touches the $bp
global directly countless times. In the past, this was fine enough, as it gave us an easy and reliable way to get global data relative to BuddyPress's current state. As BuddyPress becomes more robust, this is becoming more fragile, more difficult to extend, and a bottleneck for future enhancements to the software.
One specific case is adding rewrite rules, a feature slated for 1.8, bumped to 1.9.
Because we directly reference $bp->loggedin_user->domain
inside templates, functions, methods, and classes, translating that reference into an unpretty permalink becomes problematic, as existing plugins have come to expect that it is always a pretty URL.
Another case is the $bp->pages
array. As we introduce rewrite rules, our dependance on this array will disappear, though because we reference it directly in 60+ places, we're forced to touch these references rather than using a function and replacing its guts.
There are numerous other examples that require ongoing clean-up, both related and unrelated to adding rewrite rules in 1.9 and beyond. I'm creating this ticket as a general task to patch and commit changes to $bp
touches towards.
Change History (21)
#14
@
10 years ago
I just ran Scrutiniser to evaluate these changes (specifically r9377) and it thinks Activity::rebuild_activity_comment_tree() got "worse" though it is not clear to me why it thinks that: https://scrutinizer-ci.com/g/buddypress/BuddyPress/inspections/979b3a27-156d-4e63-9758-7fd68adf831c
$bp->loggedin_user->domain
ended up being a bad example, as I cleaned most of that up during the epic 1.5 release.