Changeset 2255068
- Timestamp:
- 03/05/2020 12:27:31 PM (6 years ago)
- Location:
- wp-performance-pack/trunk
- Files:
-
- 6 edited
-
admin/class.admin-renderer.php (modified) (2 diffs)
-
modules/l10n_improvements/class.labelsobject.php (modified) (1 diff)
-
modules/l10n_improvements/class.wppp_l10n_improvements.php (modified) (1 diff)
-
modules/l10n_improvements/class.wppp_mo_dynamic.php (modified) (14 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-performance-pack.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-performance-pack/trunk/admin/class.admin-renderer.php
r2250533 r2255068 235 235 } 236 236 237 // gettext extension is required 238 if ( !extension_loaded( 'gettext' ) ) { 239 $result = 1; 240 return 1; 241 }; 242 243 // language dir must exist (an be writeable...) 244 $locale = get_locale(); 245 $updir = wp_upload_dir(); 246 $path = WP_CONTENT_DIR . '/wppp/localize/' . $locale . '/LC_MESSAGES'; 247 if ( !is_dir( $path ) ) { 248 if ( !wp_mkdir_p( $path ) ) { 249 $result = 2; 250 return 2; 251 } 252 } 253 254 // load test translation and test if it translates correct 255 $mo = new WPPP_Native_Gettext(); 256 if ( !$mo->import_from_file( sprintf( '%s/native-gettext-test.mo', dirname( __FILE__ ) ) ) ) { 257 $result = 3; 258 return 3; 259 } 260 261 if ( $mo->translate( 'native-gettext-test' ) !== 'success' ) { 262 $result = 4; 263 return 4; 264 } 265 266 // all tests successful => return 0 267 $result = 0; 268 return 0; 237 try { 238 // gettext extension is required 239 if ( !extension_loaded( 'gettext' ) ) { 240 $result = 1; 241 return 1; 242 }; 243 244 // language dir must exist (an be writeable...) 245 $locale = get_locale(); 246 $updir = wp_upload_dir(); 247 $path = WP_CONTENT_DIR . '/wppp/localize/' . $locale . '/LC_MESSAGES'; 248 if ( !is_dir( $path ) ) { 249 if ( !wp_mkdir_p( $path ) ) { 250 $result = 2; 251 return 2; 252 } 253 } 254 255 // load test translation and test if it translates correct 256 $mo = new WPPP_Native_Gettext(); 257 if ( !$mo->import_from_file( sprintf( '%s/native-gettext-test.mo', dirname( __FILE__ ) ) ) ) { 258 $result = 3; 259 return 3; 260 } 261 262 if ( $mo->translate( 'native-gettext-test' ) !== 'success' ) { 263 $result = 4; 264 return 4; 265 } 266 267 // all tests successful => return 0 268 $result = 0; 269 return 0; 270 } catch ( Exception $e ) { 271 // catch any other error and log the error 272 error_log( '[WPPP native gettext test] ' . $e->message ); 273 $result = 5; 274 return 5; 275 } 269 276 } 270 277 … … 314 321 break; 315 322 case 4 : _e( 'Gettext test failed. Activate WPPP debugging for additional info.', 'wp-performance-pack' ); 323 break; 324 case 5 : _e( 'Gettext test failed due to an error. Search your web servers error log for <code>[WPPP native gettext test]</code> for details.', 'wp-performance-pack' ); 316 325 break; 317 326 } -
wp-performance-pack/trunk/modules/l10n_improvements/class.labelsobject.php
r2209823 r2255068 2 2 /** 3 3 * Class for translating strings "on demand". 4 * Instead filling arrays with directly translated strings, LabelsObject executes4 * Instead of filling arrays with directly translated strings, LabelsObject executes 5 5 * the translation only when the string is accessed, i.e. used. This prevents unnecessary 6 6 * calls to translation functions for strings which are never used on a page. -
wp-performance-pack/trunk/modules/l10n_improvements/class.wppp_l10n_improvements.php
r2228316 r2255068 116 116 117 117 if ( isset( $l10n[$domain] ) ) { 118 if ( $l10n[$domain] instanceof WPPP_MO_dynamic && $l10n[$domain]->M o_file_loaded( $mofile ) ) {118 if ( $l10n[$domain] instanceof WPPP_MO_dynamic && $l10n[$domain]->MO_file_loaded( $mofile ) ) { 119 119 return true; 120 120 } -
wp-performance-pack/trunk/modules/l10n_improvements/class.wppp_mo_dynamic.php
r2250533 r2255068 9 9 * Author: Bjoern Ahrens <bjoern@ahrens.net> 10 10 * Author URI: http://www.bjoernahrens.de 11 * Version: 2. 1.311 * Version: 2.2 12 12 */ 13 13 … … 17 17 */ 18 18 class WPPP_MO_Item { 19 var $mofile = ''; 20 var $fhandle = NULL; 19 const PLURAL_SEP = "\x00"; 20 private $is_overloaded; 21 22 public $fhandle = NULL; 23 public $filename = ''; 24 public $is_open = false; 21 25 22 26 var $total = 0; … … 24 28 var $originals_table; 25 29 var $translations_table; 26 var $last_access;27 30 28 31 var $hash_table; 29 32 var $hash_length = 0; 30 33 31 function clear_reader () { 34 private function import_fail() { 35 fclose( $this->fhandle ); 36 $this->fhandle = false; 37 $this->is_open = false; 38 unset( $this->originals ); 39 unset( $this->originals_table ); 40 unset( $this->translations_table ); 41 unset( $this->hash_table ); 42 } 43 44 private function strlen( &$string ) { 45 if ( $this->is_overloaded ) { 46 return mb_strlen( $string, 'ascii' ); 47 } else { 48 return strlen( $string ); 49 } 50 } 51 52 public function getOriginal( $index ) { 53 if ( $this->originals_table[ $index ] > 0 ) { 54 fseek( $this->fhandle, $this->originals_table[ $index * 2 + 1 ] ); 55 return fread( $this->fhandle, $this->originals_table[ $index * 2 ] ); 56 } else 57 return ''; 58 } 59 60 function __construct( $filename ) { 61 $this->filename = $filename; 62 $this->last_access = 0; 63 $this->is_overloaded = ( ( ini_get( "mbstring.func_overload" ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); 64 } 65 66 function clear_reader() { 32 67 if ( $this->fhandle !== NULL ) { 33 68 fclose( $this->fhandle ); 34 69 $this->fhandle = NULL; 35 70 } 71 $this->is_open = false; 72 } 73 74 /** 75 * Get byte order of MO file. 76 * 77 * @return string V for little endian, N biug endian 78 */ 79 function get_byteorder() { 80 $bytes = fread( $this->fhandle, 4 ); 81 if ( 4 != $this->strlen( $bytes ) ) 82 return false; 83 $magic = unpack( 'V', $bytes ); 84 $magic = reset( $magic ); 85 86 // The magic is 0x950412de 87 // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 88 $magic_little = (int) - 1794895138; 89 $magic_little_64 = (int) 2500072158; 90 // 0xde120495 91 $magic_big = ((int) - 569244523) & 0xFFFFFFFF; 92 if ($magic_little == $magic || $magic_little_64 == $magic) { 93 return 'V'; 94 } else if ($magic_big == $magic) { 95 return 'N'; 96 } else { 97 return false; 98 } 99 } 100 101 /** 102 * Open MO file and read initial data (including headers) from file. 103 * Also tests if the file is a valid MO file. 104 * 105 * @return bool|string false on error (file open error, invalid MO file), MO files header entry otherwise 106 */ 107 function open_mo_file() { 108 $file_size = filesize( $this->filename ); 109 $this->fhandle = fopen( $this->filename, 'rb' ); 110 $this->is_open = true; 111 112 $endian = $this->get_byteorder(); 113 if ( false === $endian ) { 114 $this->import_fail(); 115 return false; 116 } 117 118 $header = fread( $this->fhandle, 24 ); 119 if ( $this->strlen( $header ) != 24 ) { 120 $this->import_fail(); 121 return false; 122 } 123 124 // parse header 125 $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header ); 126 if ( !is_array( $header ) ) { 127 $this->import_fail(); 128 return false; 129 } 130 extract( $header ); 131 132 // support revision 0 of MO format specs, only 133 if ( $revision !== 0 ) { 134 $this->import_fail(); 135 return false; 136 } 137 138 // read tables - order in file is: 1. original indices, 2. translation indices, (optional) 3. hash table 139 $originals_lengths_length = $translations_lenghts_addr - $originals_lenghts_addr; 140 if ( $originals_lengths_length != $total * 8 ) { 141 $this->import_fail(); 142 return false; 143 } 144 $translations_lenghts_length = $hash_addr - $translations_lenghts_addr; 145 if ( $translations_lenghts_length != $total * 8 ) { 146 $this->import_fail(); 147 return false; 148 } 149 $this->hash_length = $hash_length; 150 $this->total = $total; 151 152 // read from file 153 fseek( $this->fhandle, $originals_lenghts_addr ); 154 $str = fread( $this->fhandle, $originals_lengths_length + $translations_lenghts_length + ( $hash_length * 4 ) ); 155 if ( $this->strlen( $str ) != $originals_lengths_length + $translations_lenghts_length + ( $hash_length * 4 ) ) { 156 $this->import_fail(); 157 return false; 158 } 159 $tables = array_chunk( unpack( $endian.( $total * 4 + $hash_length ), $str ), $total * 2 ); 160 if ( class_exists ( 'SplFixedArray' ) ) { 161 $this->originals_table = SplFixedArray::fromArray( $tables[ 0 ], false ); 162 $this->translations_table = SplFixedArray::fromArray( $tables[ 1 ], false ); 163 if ( $hash_length > 0 ) 164 $this->hash_table = SplFixedArray::fromArray( $tables[ 2 ], false ); 165 unset( $tables ); 166 } else { 167 $this->originals_table = $tables[ 0 ]; 168 $this->translations_table = $tables[ 1 ]; 169 if ( $hash_length > 0 ) 170 $this->hash_table = $tables[ 2 ]; 171 } 172 173 // "sanity checks" ( tests for corrupted mo file ) 174 for ( $i = 0, $max = $total * 2; $i < $max; $i += 2 ) { 175 if ( $this->originals_table[ $i + 1 ] + $this->originals_table[ $i ] > $file_size 176 || $this->translations_table[ $i + 1 ] + $this->translations_table[ $i ] > $file_size ) { 177 $this->import_fail(); 178 return false; 179 } 180 } 181 182 // search and return header entry (empty original string) 183 for ( $i = 0, $max = $total * 2; $i < $max; $i += 2 ) { 184 // Search emtpy original. Usually the first entry in the MO file. 185 $original = ''; 186 if ( $this->originals_table[ $i ] > 0 ) { 187 fseek( $this->fhandle, $this->originals_table[ $i + 1 ] ); 188 $original = fread( $this->fhandle, $this->originals_table[ $i ] ); 189 190 $j = strpos( $original, self::PLURAL_SEP ); 191 if ( $j !== false ) 192 $original = substr( $original, 0, $j ); 193 } 194 195 if ( $original === '' ) { 196 if ( $this->translations_table[ $i ] > 0 ) { 197 fseek( $this->fhandle, $this->translations_table[ $i + 1 ] ); 198 return fread( $this->fhandle, $this->translations_table[ $i ] ); 199 } else { 200 return ''; 201 } 202 } 203 } 204 return ''; 36 205 } 37 206 } … … 45 214 const PLURAL_SEP = "\x00"; 46 215 const CONTEXT_SEP = "\x04"; 216 47 217 private $caching = false; 48 218 private $modified = false; 49 219 private $cachegroup; 50 private $is_overloaded;51 220 52 221 protected $domain = ''; 53 222 protected $MOs = array(); 54 55 223 protected $translations = NULL; 56 224 protected $base_translations = NULL; … … 59 227 $this->domain = $domain; 60 228 $this->caching = $caching; 61 $this->is_overloaded = ( ( ini_get( "mbstring.func_overload" ) & 2 ) != 0 ) && function_exists( 'mb_substr' );62 229 if ( $caching ) { 63 230 add_action ( 'shutdown', array( $this, 'save_to_cache' ) ); … … 67 234 // reader is loaded (cannot delete old plugin/theme/etc. because a language file 68 235 // is still opened). 69 add_filter('upgrader_pre_install', array($this, 'clear_reader_before_upgrade'), 10, 2); 70 } 71 72 function get_byteorder( &$moitem ) { 73 $bytes = fread( $moitem->fhandle, 4 ); 74 if ( 4 != $this->strlen( $bytes ) ) 75 return false; 76 $magic = unpack( 'V', $bytes ); 77 $magic = reset( $magic ); 78 79 // The magic is 0x950412de 80 // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 81 $magic_little = (int) - 1794895138; 82 $magic_little_64 = (int) 2500072158; 83 // 0xde120495 84 $magic_big = ((int) - 569244523) & 0xFFFFFFFF; 85 if ($magic_little == $magic || $magic_little_64 == $magic) { 86 return 'little'; 87 } else if ($magic_big == $magic) { 88 return 'big'; 89 } else { 90 return false; 91 } 236 add_filter( 'upgrader_pre_install', array( $this, 'clear_reader_before_upgrade' ), 10, 2 ); 92 237 } 93 238 … … 132 277 133 278 function import_from_file( $filename ) { 134 $moitem = new WPPP_MO_Item(); 135 $moitem->mofile = $filename; 136 $this->MOs[] = $moitem; 137 279 $this->MOs[] = new WPPP_MO_Item( $filename ); 138 280 // because only a reference to the MO file is created, at this point there is no information if $filename is a valid MO file, so the return value is always true 139 281 return true; … … 197 339 } 198 340 199 private function import_fail ( &$moitem ) { 200 fclose( $moitem->fhandle ); 201 $moitem->fhandle = false; 202 unset( $moitem->originals ); 203 unset( $moitem->originals_table ); 204 unset( $moitem->translations_table ); 205 unset( $moitem->hash_table ); 206 207 return false; 208 } 209 210 private function strlen( $string ) { 211 if ( $this->is_overloaded ) { 212 return mb_strlen( $string, 'ascii' ); 213 } else { 214 return strlen( $string ); 215 } 216 } 217 218 function import_from_reader( &$moitem ) { 219 if ( $moitem->fhandle !== NULL) { 220 return ( $moitem->fhandle !== false ); 221 } 222 223 $file_size = filesize( $moitem->mofile ); 224 $moitem->fhandle = fopen( $moitem->mofile, 'rb' ); 225 226 $endian_string = $this->get_byteorder( $moitem ); 227 if ( false === $endian_string ) { 228 return $this->import_fail( $moitem ); 229 } 230 $endian = ( 'big' == $endian_string ) ? 'N' : 'V'; 231 232 $header = fread( $moitem->fhandle, 24 ); 233 if ( $this->strlen( $header ) != 24 ) { 234 return $this->import_fail( $moitem ); 235 } 236 237 // parse header 238 $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header ); 239 if ( !is_array( $header ) ) { 240 return $this->import_fail( $moitem ); 241 } 242 extract( $header ); 243 244 // support revision 0 of MO format specs, only 245 if ( $revision !== 0 ) { 246 return $this->import_fail( $moitem ); 247 } 248 249 $moitem->total = $total; 250 251 // read hashtable 252 $moitem->hash_length = $hash_length; 253 if ( $hash_length > 0 ) { 254 fseek( $moitem->fhandle, $hash_addr ); 255 $str = fread( $moitem->fhandle, $hash_length * 4 ); 256 if ( $this->strlen( $str ) != $hash_length * 4 ) { 257 return $this->import_fail( $moitem ); 258 } 259 if ( class_exists ( 'SplFixedArray' ) ) 260 $moitem->hash_table = SplFixedArray::fromArray( unpack ( $endian.$hash_length, $str ), false ); 261 else 262 $moitem->hash_table = array_slice( unpack ( $endian.$hash_length, $str ), 0 ); // force zero based index 263 } 264 265 // read originals' indices 266 fseek( $moitem->fhandle, $originals_lenghts_addr ); 267 $originals_lengths_length = $translations_lenghts_addr - $originals_lenghts_addr; 268 if ( $originals_lengths_length != $total * 8 ) { 269 return $this->import_fail( $moitem ); 270 } 271 $str = fread( $moitem->fhandle, $originals_lengths_length ); 272 if ( $this->strlen( $str ) != $originals_lengths_length ) { 273 return $this->import_fail( $moitem ); 274 } 275 if ( class_exists ( 'SplFixedArray' ) ) 276 $moitem->originals_table = SplFixedArray::fromArray( unpack ( $endian.($total * 2), $str ), false ); 277 else 278 $moitem->originals_table = array_slice( unpack ( $endian.($total * 2), $str ), 0 ); // force zero based index 279 280 // "sanity check" ( i.e. test for corrupted mo file ) 281 for ( $i = 0, $max = $total * 2; $i < $max; $i+=2 ) { 282 if ( $moitem->originals_table[ $i + 1 ] > $file_size 283 || $moitem->originals_table[ $i + 1 ] + $moitem->originals_table[ $i ] > $file_size ) { 284 return $this->import_fail( $moitem ); 285 } 286 } 287 288 // read translations' indices 289 $translations_lenghts_length = $hash_addr - $translations_lenghts_addr; 290 if ( $translations_lenghts_length != $total * 8 ) { 291 return $this->import_fail( $moitem ); 292 } 293 $str = fread( $moitem->fhandle, $translations_lenghts_length ); 294 if ( $this->strlen( $str ) != $translations_lenghts_length ) { 295 return $this->import_fail( $moitem ); 296 } 297 if ( class_exists ( 'SplFixedArray' ) ) 298 $moitem->translations_table = SplFixedArray::fromArray( unpack ( $endian.($total * 2), $str ), false ); 299 else 300 $moitem->translations_table = array_slice( unpack ( $endian.($total * 2), $str ), 0 ); // force zero based index 301 302 // "sanity check" ( i.e. test for corrupted mo file ) 303 for ( $i = 0, $max = $total * 2; $i < $max; $i+=2 ) { 304 if ( $moitem->translations_table[ $i + 1 ] > $file_size 305 || $moitem->translations_table[ $i + 1 ] + $moitem->translations_table[ $i ] > $file_size ) { 306 return $this->import_fail( $moitem ); 307 } 308 } 309 310 // read headers 311 for ( $i = 0, $max = $total * 2; $i < $max; $i+=2 ) { 312 // Search emtpy original. Usually should be first entry in MO file. 313 $original = ''; 314 if ( $moitem->originals_table[$i] > 0 ) { 315 fseek( $moitem->fhandle, $moitem->originals_table[$i+1] ); 316 $original = fread( $moitem->fhandle, $moitem->originals_table[$i] ); 317 318 $j = strpos( $original, self::PLURAL_SEP ); 319 if ( $j !== false ) 320 $original = substr( $original, 0, $j ); 321 } 322 323 if ( $original === '' ) { 324 $translation = ''; 325 if ( $moitem->translations_table[$i] > 0 ) { 326 fseek( $moitem->fhandle, $moitem->translations_table[$i+1] ); 327 $translation = fread( $moitem->fhandle, $moitem->translations_table[$i] ); 328 } 329 330 $this->set_headers( $this->make_headers( $translation ) ); 331 } else 332 return true; 333 } 334 return true; 335 } 336 337 protected function search_translation ( $key ) { 341 protected function search_translation( $key ) { 338 342 $hash_val = NULL; 339 343 $key_len = strlen( $key ); 340 344 341 345 for ( $j = 0, $max = count( $this->MOs ); $j < $max; $j++ ) { 342 $moitem = $this->MOs[$j]; 343 if ( $moitem->fhandle === NULL ) { 344 if ( !$this->import_from_reader( $moitem ) ) { 346 $moitem = $this->MOs[ $j ]; 347 if ( !$moitem->is_open ) { 348 $header = $moitem->open_mo_file(); 349 if ( $header === false ) { 345 350 // Error reading MO file, so delete it from MO list to prevent subsequent access 346 unset( $this->MOs[ $j] );351 unset( $this->MOs[ $j ] ); 347 352 return false; // return or continue? 348 353 } 354 $this->set_headers( $this->make_headers( $header ) ); 349 355 } 350 356 … … 357 363 if ( $hash_val === NULL) { 358 364 $hash_val = 0; 359 $chars = unpack( 'C*', $key ); //faster than accessing every single char by ord(char)360 foreach ( $charsas $char ) {365 // unpack is faster than accessing every single char by ord(char) 366 foreach ( unpack( 'C*', $key ) as $char ) { 361 367 $hash_val = ( $hash_val << 4 ) + $char; 362 368 if( 0 !== ( $g = $hash_val & 0xF0000000 ) ){ 363 369 if ( $g < 0 ) 364 $hash_val ^= ( ( ( $g & 0x7FFFFFFF) >> 24 ) | 0x80 ); // wordaround: php operator >> is arithmetic, not logic, so shifting negative values gives unexpected results. Cut sign bit, shift right, set sign bit again.370 $hash_val ^= ( ( ( $g & 0x7FFFFFFF ) >> 24 ) | 0x80 ); // wordaround: php operator >> is arithmetic, not logic, so shifting negative values gives unexpected results. Cut sign bit, shift right, set sign bit again. 365 371 /* 366 372 workaround based on this function (adapted to actual used parameters): … … 386 392 if ( $hash_val >= 0 ) { 387 393 $idx = $hash_val % $moitem->hash_length; 388 $incr = 1 + ( $hash_val % ($moitem->hash_length - 2));394 $incr = 1 + ( $hash_val % ( $moitem->hash_length - 2 ) ); 389 395 } else { 390 $hash_val = (float) sprintf( '%u', $hash_val); // workaround php not knowing unsigned int - %u outputs $hval as unsigned, then cast to float391 $idx = fmod( $hash_val, $moitem->hash_length );392 $incr = 1 + fmod ($hash_val, ($moitem->hash_length - 2));396 $hash_val = (float) sprintf( '%u', $hash_val ); // workaround php not knowing unsigned int - %u outputs $hval as unsigned, then cast to float 397 $idx = fmod( $hash_val, $moitem->hash_length ); 398 $incr = 1 + fmod( $hash_val, ( $moitem->hash_length - 2 ) ); 393 399 } 394 400 … … 402 408 403 409 // read original string 404 $mo_original = '';405 410 if ( $moitem->originals_table[ $pos ] > 0 ) { 406 411 fseek( $moitem->fhandle, $moitem->originals_table[ $pos + 1 ] ); 407 412 $mo_original = fread( $moitem->fhandle, $moitem->originals_table[ $pos ] ); 408 } 409 410 if ( $moitem->originals_table[$pos] == $key_len 411 || $mo_original[ $key_len ] == self::PLURAL_SEP ) { 413 412 414 // strings can only match if they have the same length, no need to inspect otherwise 413 414 if ( false !== ( $i = strpos( $mo_original, self::PLURAL_SEP ) ) ) 415 $cmpval = strncmp( $key, $mo_original, $i ); 415 if ( $moitem->originals_table[ $pos ] == $key_len ) 416 $cmpval = ( $key === $mo_original ); 417 elseif ( $mo_original[ $key_len ] == self::PLURAL_SEP ) 418 $cmpval = substr_compare( $key, $mo_original, 0, $key_len ); 416 419 else 417 $cmpval = strcmp( $key, $mo_original ); 418 419 if ( $cmpval === 0 ) { 420 // key found, read translation string 421 fseek( $moitem->fhandle, $moitem->translations_table[$pos+1] ); 422 $translation = fread( $moitem->fhandle, $moitem->translations_table[$pos] ); 423 if ( $j > 0 ) { 424 // Assuming frequent subsequent translations from the same file resort MOs by access time to avoid unnecessary search in the wrong files. 425 $moitem->last_access=time(); 426 usort( $this->MOs, function ($a, $b) {return ($b->last_access - $a->last_access);} ); 427 } 428 return $translation; 420 $cmpval = false; 421 } else 422 $cmpval = ( $key === '' ); 423 424 425 if ( $cmpval ) { 426 // key found, read translation string 427 fseek( $moitem->fhandle, $moitem->translations_table[$pos+1] ); 428 $translation = fread( $moitem->fhandle, $moitem->translations_table[$pos] ); 429 if ( $j > 0 ) { 430 // Assuming frequent subsequent translations from the same file move current moitem to front of array. 431 unset( $this->MOs[ $j ] ); 432 array_unshift( $this->MOs, $moitem ); 429 433 } 434 return $translation; 430 435 } 431 436 } … … 469 474 $translation = fread( $moitem->fhandle, $moitem->translations_table[$pos] ); 470 475 if ( $j > 0 ) { 471 // Assuming frequent subsequent translations from the same file resort MOs by access time to avoid unnecessary search in the wrong files.472 $moitem->last_access=time();473 usort( $this->MOs, function ($a, $b) {return ($b->last_access - $a->last_access);});476 // Assuming frequent subsequent translations from the same file move current moitem to front of array. 477 unset( $this->MOs[ $j ] ); 478 array_unshift( $this->MOs, $moitem ); 474 479 } 475 480 return $translation; … … 585 590 $found = false; 586 591 while ( !$found && ( $i < $c ) ) { 587 $found = $this->MOs[$i]-> mofile == $moitem->mofile;592 $found = $this->MOs[$i]->filename == $moitem->filename; 588 593 $i++; 589 594 } … … 603 608 604 609 function MO_file_loaded ( $mofile ) { 605 foreach ( $this->MOs as $moitem) {606 if ( $moitem->mofile == $mofile) {610 foreach ( $this->MOs as $moitem ) { 611 if ( $moitem->filename == $mofile ) { 607 612 return true; 608 613 } -
wp-performance-pack/trunk/readme.txt
r2250533 r2255068 4 4 Requires at least: 4.7 5 5 Tested up to: 5.3.2 6 Stable tag: 2.2.5 6 Requires PHP: 5.3 7 Stable tag: 2.2.6 7 8 License: GPLv2 or later 8 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 127 128 == Changelog == 128 129 130 = 2.2.6 = 131 * [gettext] Improved error handling during test for native gettext support. 132 * [mo-dynamic] Some smaller improvements. 133 129 134 = 2.2.5 = 130 135 * Fixed some JavaScript errors in options. -
wp-performance-pack/trunk/wp-performance-pack.php
r2250533 r2255068 4 4 Plugin URI: http://wordpress.org/plugins/wp-performance-pack 5 5 Description: Performance optimizations for WordPress. Improve localization performance and image handling, serve images through CDN. 6 Version: 2.2. 56 Version: 2.2.6 7 7 Text Domain: wp-performance-pack 8 8 Author: Björn Ahrens … … 130 130 * @const string 131 131 */ 132 const wppp_version = '2.2. 5';132 const wppp_version = '2.2.6'; 133 133 134 134 /**
Note: See TracChangeset
for help on using the changeset viewer.