Skip to:
Content

BuddyPress.org

Ticket #8042: 8042.patch

File 8042.patch, 3.0 KB (added by imath, 5 years ago)
  • src/bp-core/admin/bp-core-admin-schema.php

    diff --git src/bp-core/admin/bp-core-admin-schema.php src/bp-core/admin/bp-core-admin-schema.php
    index 02a410ba9..244d1a1f9 100644
    function bp_core_install_extended_profiles() { 
    382382
    383383        if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
    384384                $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
     385
     386                // Make sure the custom visibility is disabled for the default field.
     387                if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
     388                        $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
     389                }
    385390        }
    386391
    387392        dbDelta( $insert_sql );
  • src/bp-core/bp-core-update.php

    diff --git src/bp-core/bp-core-update.php src/bp-core/bp-core-update.php
    index b006ff4d5..b2cc9761a 100644
    function bp_version_updater() { 
    268268                if ( $raw_db_version < 11105 ) {
    269269                        bp_update_to_2_7();
    270270                }
     271
     272                // Version 5.0.0.
     273                if ( $raw_db_version < 12385 ) {
     274                        bp_update_to_5_0();
     275                }
    271276        }
    272277
    273278        /* All done! *************************************************************/
    function bp_update_to_2_7() { 
    542547        bp_add_option( '_bp_ignore_deprecated_code', false );
    543548}
    544549
     550/**
     551 * 5.0.0 update routine.
     552 *
     553 * - Make sure the custom visibility is disabled for the default profile field.
     554 *
     555 * @since 5.0.0
     556 */
     557function bp_update_to_5_0() {
     558        /**
     559         * The xProfile component is active by default on new installs, even if it
     560         * might be inactive during this update, we need to set the custom visibility
     561         * for the default field, in case the Administrator decides to reactivate it.
     562         */
     563        global $wpdb;
     564        $bp_prefix = bp_core_get_table_prefix();
     565        $field_id  = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = %s", addslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) );
     566
     567        $wpdb->insert(
     568                $bp_prefix . 'bp_xprofile_meta',
     569                array(
     570                        'object_id'   => $field_id,
     571                        'object_type' => 'field',
     572                        'meta_key'    => 'allow_custom_visibility',
     573                        'meta_value'  => 'disabled'
     574                ),
     575                array(
     576                        '%d',
     577                        '%s',
     578                        '%s',
     579                        '%s'
     580                )
     581        );
     582}
     583
    545584/**
    546585 * Updates the component field for new_members type.
    547586 *
  • src/class-buddypress.php

    diff --git src/class-buddypress.php src/class-buddypress.php
    index 0789be65c..e6d8d609b 100644
    class BuddyPress { 
    304304                /** Versions **********************************************************/
    305305
    306306                $this->version    = '5.0.0-alpha';
    307                 $this->db_version = 11105;
     307                $this->db_version = 12385;
    308308
    309309                /** Loading ***********************************************************/
    310310