Opened 4 years ago
Closed 4 years ago
#8360 closed defect (bug) (fixed)
inconsistent table checks in notifications
Reported by: | shawfactor | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 7.0.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | has-patch commit |
Cc: |
Description
so in the class class-bp-notifications-notification.php the check_access static function uses $bp->core->table_name_notifications whereas buddypress()->notifications->table_name. For consistency these should be the same.
This is causing problems in my setup...
Do you agree this is correct? And do you agree that buddypress()->notifications->table_name is the correct value for both?
I will create a ticket once I have confirmation on your opinion guys
Attachments (1)
Change History (12)
#1
@
4 years ago
- Keywords reporter-feedback added
- Milestone changed from Awaiting Review to Under Consideration
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
4 years ago
#3
@
4 years ago
A quick search for $bp->core->
brings up 12 results, and all of them should probably be updated.
It is probably safe by now to simply remove this old code, but I never like the idea of totally obliterating backwards compatibility. Ya just never know.
To maintain back-compat, I can imagine adding a magic getter to BP_Core
that reroutes touches to table_name_notifications
to use buddypress()->notifications->table_name
instead. That way everything uses the same thing.
The only reason I can think not to setup a magic getter here, is if BP_Component
would ever want to introduce one, this would all need some adjusting.
#4
@
4 years ago
Also, it's weird that BP_Core_Notification
is still being used in some places. Those should be replaced in a separate ticket, specifically inside of bp_activity_at_message_notification()
.
#5
@
4 years ago
- Keywords has-patch added
- Owner set to johnjamesjacoby
- Status changed from new to assigned
1.diff does the following:
- Deprecates
->core->table_name_notifications
- Adds a magic getter to
BP_Core
, with a fallback if Notifications isn't active - Audits the related queries and method params, and makes sure they work as intended, and updates them to our latest coding standards
#6
@
4 years ago
- Milestone changed from Under Consideration to 7.0.0
Awesome, thanks a lot @johnjamesjacoby 😍
#8
@
4 years ago
- Keywords reporter-feedback removed
Guys the current behaviour is hugely problematic for my startup as we are trying to build a SAAS solution with shared tables for all components except xprofile, but maintaining different buddypress pages on each site.
WE have achieved this by setting BP_ENABLE_MULTIBLOG, using the buddypress-multi-network plugin, and filtering most tables to be "global_tables". However $bp->core table_name is not filtered so some functionality simply does not work. eg setting notifications to read (using bp_notifications_mark_notification) uses $bp->core->table_name_notification in check_access and buddypress()->notifications->table_name to actually update the notification (and hence does not work).
if there is a way of overririding this until buddypress 7.0 I´d be appreciative if you could let me know.
In terms of the future I would advocate for a consistent approach that does not handle backwards compatability as that would minimise technical debt.
Hi @shawfactor
both should return the same value:
wp_bp_notifications
(when the table prefix is set towp_
). The reason about this is that Notifications before becoming an optional component were a core feature.We've left it for back compatibility purpose in case people are still accessing directly this property.
The fix is not just a find/replace. We need to deprecate it.
What's the issue you have with it?