Ticket #49344: 49344.diff
File 49344.diff, 12.0 KB (added by , 5 years ago) |
---|
-
tests/phpunit/tests/db.php
295 295 296 296 $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); 297 297 298 $new_modes = array( 'IGNORE_SPACE', 'NO_AUTO_ CREATE_USER' );298 $new_modes = array( 'IGNORE_SPACE', 'NO_AUTO_VALUE_ON_ZERO' ); 299 299 300 300 $wpdb->set_sql_mode( $new_modes ); 301 301 … … 315 315 316 316 $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); 317 317 318 $new_modes = array( 'IGNORE_SPACE', 'NO_ZERO_DATE', 'NO_AUTO_ CREATE_USER' );318 $new_modes = array( 'IGNORE_SPACE', 'NO_ZERO_DATE', 'NO_AUTO_VALUE_ON_ZERO' ); 319 319 $wpdb->set_sql_mode( $new_modes ); 320 320 $check_new_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); 321 321 $this->assertNotContains( 'NO_ZERO_DATE', explode( ',', $check_new_modes ) ); … … 333 333 334 334 $current_modes = $wpdb->get_var( 'SELECT @@SESSION.sql_mode;' ); 335 335 336 $new_modes = array( 'IGNORE_SPACE', 'ONLY_FULL_GROUP_BY', 'NO_AUTO_ CREATE_USER' );336 $new_modes = array( 'IGNORE_SPACE', 'ONLY_FULL_GROUP_BY', 'NO_AUTO_VALUE_ON_ZERO' ); 337 337 338 338 add_filter( 'incompatible_sql_modes', array( $this, 'filter_allowed_incompatible_sql_mode' ), 1, 1 ); 339 339 $wpdb->set_sql_mode( $new_modes ); -
tests/phpunit/tests/dbdelta.php
15 15 protected $max_index_length = 191; 16 16 17 17 /** 18 * Display width for BIGINT data type. 19 * 20 * Prior to MySQL 8.0.17, a width of 20 digits was used: BIGINT(20). 21 * Since MySQL 8.0.17, display width for integer data types is no longer supported. 22 */ 23 protected $bigint_display_width = ''; 24 25 /** 18 26 * Make sure the upgrade code is loaded before the tests are run. 19 27 */ 20 28 public static function setUpBeforeClass() { … … 31 39 32 40 global $wpdb; 33 41 42 $db_version = $wpdb->db_version(); 43 44 if ( version_compare( $db_version, '8.0.17', '<' ) ) { 45 // Prior to MySQL 8.0.17, a width of 20 digits was used: BIGINT(20). 46 $this->bigint_display_width = '(20)'; 47 } 48 34 49 // Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7. 35 50 $wpdb->query( 36 51 $wpdb->prepare( 37 52 " 38 53 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 39 id bigint (20)NOT NULL AUTO_INCREMENT,54 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 40 55 column_1 varchar(255) NOT NULL, 41 56 column_2 text, 42 57 column_3 blob, … … 78 93 79 94 $updates = dbDelta( 80 95 "CREATE TABLE {$wpdb->prefix}dbdelta_create_test ( 81 id bigint (20)NOT NULL AUTO_INCREMENT,96 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 82 97 column_1 varchar(255) NOT NULL, 83 98 PRIMARY KEY (id) 84 99 );" … … 113 128 $updates = dbDelta( 114 129 " 115 130 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 116 id bigint (20)NOT NULL AUTO_INCREMENT,131 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 117 132 column_1 varchar(255) NOT NULL, 118 133 PRIMARY KEY (id), 119 134 KEY key_1 (column_1($this->max_index_length)), … … 132 147 133 148 global $wpdb; 134 149 135 // id: bigint (20)=> int(11)150 // id: bigint => int(11) 136 151 $updates = dbDelta( 137 152 " 138 153 CREATE TABLE {$wpdb->prefix}dbdelta_test ( … … 148 163 $this->assertEquals( 149 164 array( 150 165 "{$wpdb->prefix}dbdelta_test.id" 151 => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint (20)to int(11)",166 => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint{$this->bigint_display_width} to int(11)", 152 167 ), 153 168 $updates 154 169 ); … … 164 179 $updates = dbDelta( 165 180 " 166 181 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 167 id bigint (20)NOT NULL AUTO_INCREMENT,182 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 168 183 column_1 varchar(255) NOT NULL, 169 184 extra_col longtext, 170 185 PRIMARY KEY (id), … … 199 214 $updates = dbDelta( 200 215 " 201 216 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 202 id bigint (20)NOT NULL AUTO_INCREMENT,217 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 203 218 PRIMARY KEY (id), 204 219 KEY key_1 (column_1($this->max_index_length)), 205 220 KEY compound_key (id,column_1($this->max_index_length)) … … 223 238 $updates = dbDelta( 224 239 " 225 240 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 226 id bigint (20)NOT NULL AUTO_INCREMENT,241 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 227 242 column_1 varchar(255) NOT NULL, 228 243 extra_col longtext, 229 244 PRIMARY KEY (id), … … 275 290 $updates = dbDelta( 276 291 " 277 292 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 278 id bigint (20)NOT NULL AUTO_INCREMENT,293 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 279 294 column_1 varchar(255) NOT NULL, 280 295 PRIMARY KEY (id), 281 296 KEY key_1 (column_1($this->max_index_length)), … … 420 435 $result = dbDelta( 421 436 " 422 437 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 423 id bigint (20)NOT NULL AUTO_INCREMENT,438 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 424 439 column_1 varchar(255) NOT NULL, 425 440 column_2 tinytext, 426 441 column_3 blob, … … 445 460 $result = dbDelta( 446 461 " 447 462 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 448 id bigint (20)NOT NULL AUTO_INCREMENT,463 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 449 464 column_1 varchar(255) NOT NULL, 450 465 column_2 text, 451 466 column_3 tinyblob, … … 470 485 $result = dbDelta( 471 486 " 472 487 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 473 id bigint (20)NOT NULL AUTO_INCREMENT,488 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 474 489 column_1 varchar(255) NOT NULL, 475 490 column_2 bigtext, 476 491 column_3 blob, … … 501 516 $result = dbDelta( 502 517 " 503 518 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 504 id bigint (20)NOT NULL AUTO_INCREMENT,519 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 505 520 column_1 varchar(255) NOT NULL, 506 521 column_2 text, 507 522 column_3 mediumblob, … … 531 546 532 547 $schema = " 533 548 CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( 534 `id` bigint (20)NOT NULL AUTO_INCREMENT,549 `id` bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 535 550 `column_1` varchar(255) NOT NULL, 536 551 PRIMARY KEY (id), 537 552 KEY compound_key (id,column_1($this->max_index_length)) … … 554 569 function test_spatial_indices() { 555 570 global $wpdb; 556 571 557 if ( version_compare( $wpdb->db_version(), '5.4', '<' ) ) { 572 $db_version = $wpdb->db_version(); 573 574 if ( version_compare( $db_version, '5.4', '<' ) ) { 558 575 $this->markTestSkipped( 'Spatial indices require MySQL 5.4 and above.' ); 559 576 } 560 577 578 $geomcollection_name = 'geomcollection'; 579 580 if ( version_compare( $db_version, '8.0.11', '<' ) ) { 581 // Prior to MySQL 8.0.11, GeometryCollection data type name was used. 582 $geomcollection_name = 'geometrycollection'; 583 } 584 561 585 $schema = 562 586 " 563 587 CREATE TABLE {$wpdb->prefix}spatial_index_test ( 564 non_spatial bigint (20)unsigned NOT NULL,565 spatial_value geometrycollectionNOT NULL,588 non_spatial bigint{$this->bigint_display_width} unsigned NOT NULL, 589 spatial_value {$geomcollection_name} NOT NULL, 566 590 KEY non_spatial (non_spatial), 567 591 SPATIAL KEY spatial_key (spatial_value) 568 592 ) ENGINE=MyISAM; … … 578 602 $schema = 579 603 " 580 604 CREATE TABLE {$wpdb->prefix}spatial_index_test ( 581 non_spatial bigint (20)unsigned NOT NULL,582 spatial_value geometrycollectionNOT NULL,583 spatial_value2 geometrycollectionNOT NULL,605 non_spatial bigint{$this->bigint_display_width} unsigned NOT NULL, 606 spatial_value {$geomcollection_name} NOT NULL, 607 spatial_value2 {$geomcollection_name} NOT NULL, 584 608 KEY non_spatial (non_spatial), 585 609 SPATIAL KEY spatial_key (spatial_value) 586 610 SPATIAL KEY spatial_key2 (spatial_value2) … … 608 632 609 633 $schema = " 610 634 CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( 611 `id` bigint (20)NOT NULL AUTO_INCREMENT,635 `id` bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 612 636 `references` varchar(255) NOT NULL, 613 637 PRIMARY KEY (`id`), 614 638 KEY `compound_key` (`id`,`references`($this->max_index_length)) … … 638 662 $updates = dbDelta( 639 663 " 640 664 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 641 id bigint (20)NOT NULL AUTO_INCREMENT,665 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 642 666 column_1 varchar(255) NOT NULL, 643 667 column_2 text, 644 668 column_3 blob, … … 682 706 683 707 $schema = " 684 708 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 685 id bigint (20)NOT NULL AUTO_INCREMENT,709 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 686 710 column_1 varchar(255) NOT NULL, 687 711 column_2 text, 688 712 column_3 blob, … … 721 745 $updates = dbDelta( 722 746 " 723 747 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 724 id bigint (20)NOT NULL AUTO_INCREMENT,748 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 725 749 column_1 varchar(255) NOT NULL, 726 750 column_2 text, 727 751 column_3 blob, … … 744 768 745 769 $schema = " 746 770 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 747 id bigint (20)NOT NULL AUTO_INCREMENT,771 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 748 772 column_1 varchar(255) NOT NULL, 749 773 column_2 text, 750 774 column_3 blob, … … 779 803 $updates = dbDelta( 780 804 " 781 805 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 782 id bigint (20)NOT NULL AUTO_INCREMENT,806 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 783 807 column_1 varchar(255) NOT NULL, 784 808 column_2 text, 785 809 column_3 blob, … … 803 827 $updates = dbDelta( 804 828 " 805 829 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 806 id bigint (20)NOT NULL AUTO_INCREMENT,830 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 807 831 column_1 varchar(255) NOT NULL, 808 832 column_2 text, 809 833 column_3 blob, … … 827 851 $updates = dbDelta( 828 852 " 829 853 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 830 id bigint (20)NOT NULL AUTO_INCREMENT,854 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 831 855 column_1 varchar(255) NOT NULL, 832 856 column_2 text, 833 857 column_3 blob, … … 851 875 $updates = dbDelta( 852 876 " 853 877 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 854 id bigint (20)NOT NULL AUTO_INCREMENT,878 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 855 879 column_1 varchar(255) NOT NULL, 856 880 column_2 text, 857 881 column_3 blob, … … 875 899 $updates = dbDelta( 876 900 " 877 901 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 878 id bigint (20)NOT NULL AUTO_INCREMENT,902 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 879 903 column_1 varchar(255) NOT NULL, 880 904 column_2 text, 881 905 column_3 blob, … … 900 924 $updates = dbDelta( 901 925 " 902 926 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 903 id bigint (20)NOT NULL AUTO_INCREMENT,927 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 904 928 column_1 varchar(255) NOT NULL, 905 929 column_2 text, 906 930 column_3 blob, … … 925 949 $updates = dbDelta( 926 950 " 927 951 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 928 id bigint (20)NOT NULL AUTO_INCREMENT,952 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 929 953 column_1 varchar(255) NOT NULL, 930 954 column_2 text, 931 955 column_3 blob, … … 948 972 $updates = dbDelta( 949 973 " 950 974 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 951 id bigint (20)NOT NULL AUTO_INCREMENT,975 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 952 976 column_1 varchar(255) NOT NULL, 953 977 column_2 text, 954 978 column_3 blob, … … 966 990 $updates = dbDelta( 967 991 " 968 992 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 969 id bigint (20)NOT NULL AUTO_INCREMENT,993 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 970 994 column_1 varchar(255) NOT NULL, 971 995 column_2 text, 972 996 column_3 blob, … … 984 1008 $updates = dbDelta( 985 1009 " 986 1010 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 987 id bigint (20)NOT NULL AUTO_INCREMENT,1011 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 988 1012 column_1 varchar(255) NOT NULL, 989 1013 column_2 text, 990 1014 column_3 blob,