Changeset 10442
- Timestamp:
- 11/12/2020 06:20:16 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php
r9017 r10442 176 176 177 177 if ( false !== ( $originals = $this->cache_get( $slug, $branch, $cache_suffix ) ) ) { 178 if ( isset( $originals[0] ) ) { 179 // old cache style. 180 foreach ( $originals as $i => $o ) { 181 $originals[ $o->id ] = $o->singular; 182 unset( $originals[ $i ] ); // Safe: Original IDs are huge for plugins. 183 } 184 } 185 178 186 return $originals; 179 187 } … … 186 194 187 195 $originals = $wpdb->get_results( $wpdb->prepare( 188 'SELECT id, singular , commentFROM ' . GLOTPRESS_TABLE_PREFIX . 'originals WHERE project_id = %d AND status = %s ORDER BY CHAR_LENGTH(singular) DESC',196 'SELECT id, singular FROM ' . GLOTPRESS_TABLE_PREFIX . 'originals WHERE project_id = %d AND status = %s ORDER BY CHAR_LENGTH(singular) DESC', 189 197 $branch_id, '+active' 190 ) ); 191 192 if ( empty( $originals ) ) { 193 194 // Still cache if empty, but as array, never false. 195 $originals = array(); 196 } 198 ), ARRAY_A ); 199 200 $originals = array_column( $originals, 'singular', 'id' ); 197 201 198 202 $this->cache_set( $slug, $branch, $originals, $cache_suffix ); … … 408 412 // Sort the originals so as to process long strings first. 409 413 uasort( $originals, function( $a, $b ) { 410 $a_len = strlen( $a ->singular);411 $b_len = strlen( $b ->singular);414 $a_len = strlen( $a ); 415 $b_len = strlen( $b ); 412 416 413 417 return $a_len == $b_len ? 0 : ($a_len > $b_len ? -1 : 1); … … 415 419 416 420 // Mark each original for translation 417 foreach ( $originals as $original ) {418 if ( ! empty( $original->id ) && array_key_exists( $original->id, $translations) ) {419 $content = $this->mark_gp_original( $original ->id, $original->singular, $content );421 foreach ( $originals as $original_id => $original ) { 422 if ( isset( $translations[ $original_id ] ) ) { 423 $content = $this->mark_gp_original( $original_id, $original, $content ); 420 424 } 421 425 }
Note: See TracChangeset
for help on using the changeset viewer.