PROD-10342 - Fix empty default extensions in Manage File Extensions modal - #5040
Open
sajib-bb wants to merge 4 commits into
Open
PROD-10342 - Fix empty default extensions in Manage File Extensions modal #5040sajib-bb wants to merge 4 commits into
sajib-bb wants to merge 4 commits into
Conversation
bb_media_get_extension_options() and bb_media_get_extension_data() read the extensions option with an empty array as fallback, so a site where bp_document_extensions_support or bp_video_extensions_support was never saved shows no default extensions in the Manage File Extensions modal. Also fixes the same gap in the toggle-only save path in bb_media_sanitize_extensions(), which could otherwise persist an empty array and permanently lose the defaults on first toggle.
The document extensions field is registered during bb_register_features, before bp_media_allowed_document_type() is guaranteed to be loaded, so its options and extension_data can still end up empty even with the fallback in callbacks.php. Re-populate the field on bb_admin_settings_before_get_feature, which fires per settings request after the full plugin has loaded, so the Manage File Extensions modal reliably shows the default extensions.
Same fix as the document extensions field: bp_video_allowed_video_type() may not be loaded yet when the video extensions field is registered, leaving its options and extension_data empty. Refresh them on bb_admin_settings_before_get_feature once the plugin has fully loaded.
…/document default mix-up bb_media_get_extension_options() and bb_media_get_extension_data() only substituted the hard-coded default extension list when bp_get_option() found the option row missing entirely. That doesn't cover sites where bp_document_extensions_support (or bp_video_extensions_support) exists in wp_options but was saved as an empty array — which is exactly what the legacy bb_update_to_2_4_10() upgrade routine does on any site that passed through DB version 20561 without ever having a custom extension list: it reads the option with array() as fallback, finds nothing to merge, and writes that same empty array back unconditionally. Once an option is poisoned that way, get_option() keeps returning the real (empty) stored value forever, so the "fall back to defaults" fix never engages for that site. Both getters also always used bp_media_allowed_document_type() as their default source regardless of $option_name, so a site where bp_video_extensions_support was genuinely never saved would have its video extensions field populated with document extensions instead of video ones. - Add bb_media_get_default_extensions( $option_name ) to centralize the option-name -> defaults mapping in one place instead of duplicating it (correctly, for video vs document) across three call sites. - Use it in bb_media_get_extension_options(), bb_media_get_extension_data(), and bb_media_sanitize_extensions(), and treat an empty-but-present option the same as a missing one by falling back to the defaults whenever the read comes back empty.
reza-bb
reviewed
Sep 1, 2026
reza-bb
left a comment
Contributor
There was a problem hiding this comment.
Please check the feedback and update accordingly
| bb_register_feature_field( 'media', 'videos', 'videos_settings', $field ); | ||
| } | ||
| add_action( 'bb_admin_settings_before_get_feature', 'bb_media_lazy_refresh_video_extension_defaults' ); | ||
|
|
| // default extensions to an empty array before any of them have been | ||
| // persisted. | ||
| // | ||
| // @since BuddyBoss [BBVERSION] |
Contributor
There was a problem hiding this comment.
WPCS Squiz.Commenting.InlineComment.InvalidEndChar error
| // See bb_media_get_extension_options() above — an empty-but-present | ||
| // option needs the same fallback as a missing one. | ||
| // | ||
| // @since BuddyBoss [BBVERSION] |
Contributor
There was a problem hiding this comment.
WPCS Squiz.Commenting.InlineComment.InvalidEndChar error
| // saved at all — get_option() only substitutes the default for a | ||
| // missing row, so an empty-but-present option needs its own fallback. | ||
| // | ||
| // @since BuddyBoss [BBVERSION] |
Contributor
There was a problem hiding this comment.
WPCS Squiz.Commenting.InlineComment.InvalidEndChar error
| * | ||
| * @param string $feature_id The feature being loaded. | ||
| */ | ||
| function bb_media_lazy_refresh_video_extension_defaults( $feature_id ) { |
Contributor
There was a problem hiding this comment.
the two bb_media_lazy_refresh_*_extension_defaults() functions are ~90% identical. One shared helper parameterised by panel/section/field and some wrappers cuts ~40 lines and removes the copy-paste risk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira Issue:
https://buddyboss.atlassian.net/browse/PROD-10342
General Note
Keep all conversations related to this PR in the associated Jira issue(s). Do NOT add comment on this PR or edit this PR’s description.
Notes to Developer
Notes to Reviewer