Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 3 years ago

#4813 closed enhancement (maybelater)

Serialize Notification Settings

Reported by: wdfee Owned by:
Milestone: Priority: low
Severity: minor Version:
Component: Settings Keywords: needs-patch, trac-tidy-2018
Cc:

Description

just a litte performance request: I've 13 database entries per user only for notifications (with group email subscription / bbpress enabled). I think the notifications would do pretty well as a serialized array in the database.

Saving is easy, just change in bp_settings_action_notifications() in bp-settings-actions.php from

if ( isset( $_POST['notifications'] ) ) {
	foreach ( (array) $_POST['notifications'] as $key => $value ) {
		bp_update_user_meta( (int) bp_displayed_user_id(), $key, $value );
	}
}

to

if ( isset( $_POST['notifications'] ) ) {
	bp_update_user_meta( (int) bp_displayed_user_id(), 'notifications', $_POST['notifications'] );
}

The much bigger part is to change all queries against it via bp_get_user_meta()

And a migration function...
Should go along with bbpress and Buddypress Group Email Subscription.
I don't know if there are other plugins out there that would need a fallback.

Change History (3)

#1 @boonebgorges
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to low

In some cases I actually prefer to keep settings like this in separate keys, rather than serialized, but in the case of message preferences I think it makes sense to combine them.

As you note, we'll need a migration script. Alternatively (or in addition) we could have wrapper functions for checking someone's notification status. Eg

function bp_get_user_notification_setting( $user_id, $type ) {
    if ( $settings = bp_get_user_meta( $user_id, 'bp_notifications_settings', true ) ) {
        $setting = $settings[ $type ];
    } else {
        $setting = bp_get_user_meta( $user_id, 'notification_' . $type, true );
    }
}

In any case, this kind of change is likely to break any plugins that are fetching these settings in their standalone keys.

#2 @DJPaul
3 years ago

  • Keywords trac-tidy-2018 added

We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.

Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.

If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.

For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/

#3 @DJPaul
3 years ago

  • Milestone Awaiting Contributions deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.