[buddypress-trac] [BuddyPress Trac] #8141: bp_invitations table not created on update

buddypress-trac noreply at wordpress.org
Fri Apr 10 22:22:04 UTC 2020


#8141: bp_invitations table not created on update
--------------------------+------------------------------
 Reporter:  shanebp       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Groups        |     Version:  5.0.0
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by shanebp):

 I've been seeing this error a lot recently.
 It seems that the table is only created during the initial install or
 upgrade.
 This isn't a fix, but it is a workaround hack that works.
 It just checks for the table on activation.
 Perhaps a BP Tool is more appropriate.

 {{{

 function bp_check_invitations_db_table() {
         global $wpdb;

         require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

         $sql             = array();
         $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
         $bp_prefix       = bp_core_get_table_prefix();
         $sql[] = "CREATE TABLE IF NOT EXISTS {$bp_prefix}bp_invitations (
                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
                 user_id bigint(20) NOT NULL,
                 inviter_id bigint(20) NOT NULL,
                 invitee_email varchar(100) DEFAULT NULL,
                 class varchar(120) NOT NULL,
                 item_id bigint(20) NOT NULL,
                 secondary_item_id bigint(20) DEFAULT NULL,
                 type varchar(12) NOT NULL DEFAULT 'invite',
                 content longtext DEFAULT '',
                 date_modified datetime NOT NULL,
                 invite_sent tinyint(1) NOT NULL DEFAULT '0',
                 accepted tinyint(1) NOT NULL DEFAULT '0',
                 KEY user_id (user_id),
                 KEY inviter_id (inviter_id),
                 KEY invitee_email (invitee_email),
                 KEY class (class),
                 KEY item_id (item_id),
                 KEY secondary_item_id (secondary_item_id),
                 KEY type (type),
                 KEY invite_sent (invite_sent),
                 KEY accepted (accepted)
                 ) {$charset_collate};";
         dbDelta( $sql );

 }
 add_action( 'bp_activation', 'bp_check_invitations_db_table' );

 }}}

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8141#comment:16>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list