Changeset 32814
- Timestamp:
- 06/17/2015 01:52:46 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/upgrade.php
r32768 r32814 535 535 // upgrade_420() to catch bad comments prior to any auto-expansion of 536 536 // MySQL column widths. 537 if ( $wp_current_db_version < 32 364 )537 if ( $wp_current_db_version < 32814 ) 538 538 upgrade_430(); 539 539 … … 1560 1560 } 1561 1561 } 1562 1563 if ( $wp_current_db_version < 32814 ) { 1564 split_all_shared_terms(); 1565 } 1562 1566 } 1563 1567 … … 1849 1853 1850 1854 return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); 1855 } 1856 1857 /** 1858 * Split all shared taxonomy terms. 1859 * 1860 * @since 4.3.0 1861 */ 1862 function split_all_shared_terms() { 1863 global $wpdb; 1864 1865 // Get a list of shared terms (those with more than one associated row in term_taxonomy). 1866 $shared_terms = $wpdb->get_results( 1867 "SELECT tt.term_id, t.*, count(*) as term_tt_count FROM {$wpdb->term_taxonomy} tt 1868 LEFT JOIN {$wpdb->terms} t ON t.term_id = tt.term_id 1869 GROUP BY t.term_id 1870 HAVING term_tt_count > 1" 1871 ); 1872 1873 // Rekey shared term array for faster lookups. 1874 $_shared_terms = array(); 1875 foreach ( $shared_terms as $shared_term ) { 1876 $term_id = intval( $shared_term->term_id ); 1877 $_shared_terms[ $term_id ] = $shared_term; 1878 } 1879 $shared_terms = $_shared_terms; 1880 1881 // Get term taxonomy data for all shared terms. 1882 $shared_term_ids = implode( ',', array_keys( $shared_terms ) ); 1883 $shared_tts = $wpdb->get_results( "SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})" ); 1884 1885 // Split term data recording is slow, so we do it just once, outside the loop. 1886 $suspend = wp_suspend_cache_invalidation( true ); 1887 $split_term_data = get_option( '_split_terms', array() ); 1888 $skipped_first_term = $taxonomies = array(); 1889 foreach ( $shared_tts as $shared_tt ) { 1890 $term_id = intval( $shared_tt->term_id ); 1891 1892 // Don't split the first tt belonging to a given term_id. 1893 if ( ! isset( $skipped_first_term[ $term_id ] ) ) { 1894 $skipped_first_term[ $term_id ] = 1; 1895 continue; 1896 } 1897 1898 if ( ! isset( $split_term_data[ $term_id ] ) ) { 1899 $split_term_data[ $term_id ] = array(); 1900 } 1901 1902 // Keep track of taxonomies whose hierarchies need flushing. 1903 if ( ! isset( $taxonomies[ $shared_tt->taxonomy ] ) ) { 1904 $taxonomies[ $shared_tt->taxonomy ] = 1; 1905 } 1906 1907 // Split the term. 1908 $split_term_data[ $term_id ][ $shared_tt->taxonomy ] = _split_shared_term( $shared_terms[ $term_id ], $shared_tt, false ); 1909 } 1910 1911 // Rebuild the cached hierarchy for each affected taxonomy. 1912 foreach ( array_keys( $taxonomies ) as $tax ) { 1913 delete_option( "{$tax}_children" ); 1914 _get_term_hierarchy( $tax ); 1915 } 1916 1917 wp_suspend_cache_invalidation( $suspend ); 1918 update_option( '_split_terms', $split_term_data ); 1851 1919 } 1852 1920 -
trunk/src/wp-includes/version.php
r32454 r32814 12 12 * @global int $wp_db_version 13 13 */ 14 $wp_db_version = 32 453;14 $wp_db_version = 32814; 15 15 16 16 /**
Note: See TracChangeset
for help on using the changeset viewer.