Ticket #6346: 6346.01.patch
File 6346.01.patch, 5.6 KB (added by , 10 years ago) |
---|
-
src/bp-core/admin/bp-core-admin-schema.php
27 27 } 28 28 29 29 /** 30 * Indexes have a maximum size of 767 bytes. Historically, we haven't need to be 31 * concerned about that. As of 4.2, however, we moved to utf8mb4, which uses 32 * 4 bytes per character. This means that an index which used to have room for 33 * floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters. 34 * 35 * @since BuddyPress (2.3.0) 36 * 37 * @return int 38 */ 39 function bp_get_max_index_length() { 40 return 191; 41 } 42 43 /** 30 44 * Main installer 31 45 * 32 46 * Can be passed an optional array of components to explicitly run installation … … 95 109 $sql = array(); 96 110 $charset_collate = bp_core_set_charset(); 97 111 $bp_prefix = bp_core_get_table_prefix(); 112 $max_index = bp_get_max_index_length(); 98 113 99 114 $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications ( 100 115 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 115 130 ) {$charset_collate};"; 116 131 117 132 $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications_meta ( 118 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,133 id bigint(20) unsigned NOT NULL auto_increment, 119 134 notification_id bigint(20) NOT NULL, 120 135 meta_key varchar(255) DEFAULT NULL, 121 136 meta_value longtext DEFAULT NULL, 137 PRIMARY KEY (id), 122 138 KEY notification_id (notification_id), 123 KEY meta_key (meta_key )139 KEY meta_key (meta_key({$max_index})) 124 140 ) {$charset_collate};"; 125 141 126 142 dbDelta( $sql ); … … 139 155 $sql = array(); 140 156 $charset_collate = bp_core_set_charset(); 141 157 $bp_prefix = bp_core_get_table_prefix(); 158 $max_index = bp_get_max_index_length(); 142 159 143 160 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity ( 144 161 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 168 185 ) {$charset_collate};"; 169 186 170 187 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity_meta ( 171 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,188 id bigint(20) unsigned NOT NULL auto_increment, 172 189 activity_id bigint(20) NOT NULL, 173 190 meta_key varchar(255) DEFAULT NULL, 174 191 meta_value longtext DEFAULT NULL, 192 PRIMARY KEY (id), 175 193 KEY activity_id (activity_id), 176 KEY meta_key (meta_key )194 KEY meta_key (meta_key({$max_index})) 177 195 ) {$charset_collate};"; 178 196 179 197 dbDelta( $sql ); … … 220 238 $sql = array(); 221 239 $charset_collate = bp_core_set_charset(); 222 240 $bp_prefix = bp_core_get_table_prefix(); 241 $max_index = bp_get_max_index_length(); 223 242 224 243 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups ( 225 244 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 256 275 ) {$charset_collate};"; 257 276 258 277 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta ( 259 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,278 id bigint(20) unsigned NOT NULL auto_increment, 260 279 group_id bigint(20) NOT NULL, 261 280 meta_key varchar(255) DEFAULT NULL, 262 281 meta_value longtext DEFAULT NULL, 282 PRIMARY KEY (id), 263 283 KEY group_id (group_id), 264 KEY meta_key (meta_key )284 KEY meta_key (meta_key({$max_index})) 265 285 ) {$charset_collate};"; 266 286 267 287 dbDelta( $sql ); … … 280 300 $sql = array(); 281 301 $charset_collate = bp_core_set_charset(); 282 302 $bp_prefix = bp_core_get_table_prefix(); 303 $max_index = bp_get_max_index_length(); 283 304 284 305 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages ( 285 306 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 316 337 ) {$charset_collate};"; 317 338 318 339 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_meta ( 319 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,340 id bigint(20) unsigned NOT NULL auto_increment, 320 341 message_id bigint(20) NOT NULL, 321 342 meta_key varchar(255) DEFAULT NULL, 322 343 meta_value longtext DEFAULT NULL, 344 PRIMARY KEY (id), 323 345 KEY message_id (message_id), 324 KEY meta_key (meta_key )346 KEY meta_key (meta_key({$max_index})) 325 347 ) {$charset_collate};"; 326 348 327 349 dbDelta( $sql ); … … 342 364 $sql = array(); 343 365 $charset_collate = bp_core_set_charset(); 344 366 $bp_prefix = bp_core_get_table_prefix(); 367 $max_index = bp_get_max_index_length(); 345 368 346 369 // These values should only be updated if they are not already present 347 370 if ( ! bp_get_option( 'bp-xprofile-base-group-name' ) ) { … … 392 415 ) {$charset_collate};"; 393 416 394 417 $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta ( 395 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,418 id bigint(20) unsigned NOT NULL auto_increment, 396 419 object_id bigint(20) NOT NULL, 397 420 object_type varchar(150) NOT NULL, 398 421 meta_key varchar(255) DEFAULT NULL, 399 422 meta_value longtext DEFAULT NULL, 423 PRIMARY KEY (id), 400 424 KEY object_id (object_id), 401 KEY meta_key (meta_key )425 KEY meta_key (meta_key({$max_index})) 402 426 ) {$charset_collate};"; 403 427 404 428 dbDelta( $sql ); … … 430 454 $sql = array(); 431 455 $charset_collate = bp_core_set_charset(); 432 456 $bp_prefix = bp_core_get_table_prefix(); 457 $max_index = bp_get_max_index_length(); 433 458 434 459 $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs ( 435 460 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 440 465 ) {$charset_collate};"; 441 466 442 467 $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta ( 443 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,468 id bigint(20) unsigned NOT NULL auto_increment, 444 469 blog_id bigint(20) NOT NULL, 445 470 meta_key varchar(255) DEFAULT NULL, 446 471 meta_value longtext DEFAULT NULL, 472 PRIMARY KEY (id), 447 473 KEY blog_id (blog_id), 448 KEY meta_key (meta_key )474 KEY meta_key (meta_key({$max_index})) 449 475 ) {$charset_collate};"; 450 476 451 477 dbDelta( $sql );