| | 1153 | * Execute changes made in WordPress 3.2.2. |
| | 1154 | * |
| | 1155 | * @since 3.2.2 |
| | 1156 | */ |
| | 1157 | function upgrade_322() { |
| | 1158 | global $wpdb; |
| | 1159 | |
| | 1160 | // add index to GUID column |
| | 1161 | add_clean_index( $wpdb->posts, 'guid' ); |
| | 1162 | |
| | 1163 | // repair non-unique GUIDs for pages and custom post types created with WP 3.0 |
| | 1164 | $non_unique_guids = $wpdb->get_col( $wpdb->prepare( " |
| | 1165 | SELECT p1.ID |
| | 1166 | FROM $wpdb->posts p1 |
| | 1167 | WHERE 1 < ( |
| | 1168 | SELECT COUNT(ID) |
| | 1169 | FROM $wpdb->posts p2 |
| | 1170 | WHERE p1.post_type != 'revision' |
| | 1171 | AND p1.guid = p2.guid |
| | 1172 | ) |
| | 1173 | AND p1.post_type != 'revision' |
| | 1174 | " ) ); |
| | 1175 | if ( count( $non_unique_guids ) ) { |
| | 1176 | foreach ( $non_unique_guids as $post_id ) { |
| | 1177 | $url = site_url('?p='.$post_id); |
| | 1178 | $wpdb->query( $wpdb->prepare( " |
| | 1179 | UPDATE $wpdb->posts |
| | 1180 | SET guid = %s |
| | 1181 | WHERE ID = %d |
| | 1182 | ", $url, $post_id ) ); |
| | 1183 | } |
| | 1184 | } |
| | 1185 | } |
| | 1186 | |
| | 1187 | /** |