diff --git src/wp-includes/wp-db.php src/wp-includes/wp-db.php
index 77b64da..b5e38c1 100644
|
|
class wpdb { |
2637 | 2637 | */ |
2638 | 2638 | $charset = apply_filters( 'pre_get_table_charset', null, $table ); |
2639 | 2639 | if ( null !== $charset ) { |
| 2640 | $this->table_charset[ $tablekey ] = $charset; |
2640 | 2641 | return $charset; |
2641 | 2642 | } |
2642 | 2643 | |
diff --git tests/phpunit/tests/db/charset.php tests/phpunit/tests/db/charset.php
index e0f9df2..d54dd14 100644
|
|
class Tests_DB_Charset extends WP_UnitTestCase { |
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
| 836 | * Tests if the column charset handles table charset changes with the `pre_get_table_charset` filter. |
| 837 | * |
| 838 | * @ticket 38921 |
| 839 | */ |
| 840 | public function test_get_table_and_column_charset_with_pre_get_table_charset_filter() { |
| 841 | add_filter( 'pre_get_table_charset', array( $this, 'change_table_charset_callback' ), 10, 2 ); |
| 842 | $table_charset = self::$_wpdb->get_table_charset( 'some_table' ); |
| 843 | remove_filter( 'pre_get_table_charset', array( $this, 'change_table_charset_callback' ), 10, 2 ); |
| 844 | |
| 845 | $column_charset = self::$_wpdb->get_col_charset( 'some_table', 'some_column' ); |
| 846 | |
| 847 | $this->assertSame( 'fake_charset', $table_charset ); |
| 848 | $this->assertSame( 'fake_charset', $column_charset ); |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Callback for the `pre_get_table_charset` filter. |
| 853 | * |
| 854 | * @param string $charset The table's character set. |
| 855 | * @param string $table The name of the table. |
| 856 | * @return string $charset The table's character set. |
| 857 | */ |
| 858 | public function change_table_charset_callback( $charset, $table ) { |
| 859 | return 'fake_charset'; |
| 860 | } |
| 861 | |
| 862 | /** |
836 | 863 | * @dataProvider data_test_get_column_charset |
837 | 864 | * @ticket 33501 |
838 | 865 | */ |