Changeset 2954507
- Timestamp:
- 08/16/2023 03:42:31 PM (3 years ago)
- Location:
- a2-optimized-wp/trunk
- Files:
-
- 3 edited
-
a2-optimized.php (modified) (2 diffs)
-
core/A2_Optimized_Benchmark.php (modified) (36 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
a2-optimized-wp/trunk/a2-optimized.php
r2929752 r2954507 10 10 * Plugin Name: A2 Optimized WP 11 11 * Plugin URI: https://wordpress.org/plugins/a2-optimized/ 12 * Version: 3.0.6.4. 112 * Version: 3.0.6.4.2 13 13 * Author: A2 Hosting 14 14 * Author URI: https://www.a2hosting.com/ … … 25 25 26 26 define( 'A2OPT_VERSION', '3.0' ); 27 define( 'A2OPT_FULL_VERSION', '3.0.6.4. 1' );27 define( 'A2OPT_FULL_VERSION', '3.0.6.4.2' ); 28 28 define( 'A2OPT_MIN_PHP', '5.6' ); 29 29 define( 'A2OPT_MIN_WP', '5.1' ); -
a2-optimized-wp/trunk/core/A2_Optimized_Benchmark.php
r2914399 r2954507 31 31 // Do the needful 32 32 } 33 33 34 34 /** 35 35 * Run all hosting benchmark tests and store results 36 * 36 * 37 37 * @return array $results[] An array of benchmark results 38 38 */ … … 40 40 public function run_hosting_test_suite($result_desc = null) { 41 41 $existing_results = []; 42 43 try {42 43 try { 44 44 $results = []; 45 45 $results['version'] = A2OPT_FULL_VERSION; 46 $results['sysinfo']['time'] = date( "Y-m-d H:i:s");46 $results['sysinfo']['time'] = date('Y-m-d H:i:s'); 47 47 $results['sysinfo']['php_version'] = PHP_VERSION; 48 48 $results['sysinfo']['platform'] = PHP_OS; … … 70 70 71 71 update_option('a2opt-benchmarks-hosting', $existing_results); 72 72 73 return [ 73 74 'status' => 'success', … … 75 76 'data' => $results 76 77 ]; 77 } catch (Exception $ex) {78 } catch (Exception $ex) { 78 79 return [ 79 80 'status' => 'error', … … 85 86 /** 86 87 * Run all PHP benchmark tests 87 * 88 * 88 89 * @return array $results[] An array of benchmark results 89 90 */ … … 108 109 * Run Math PHP benchmark tests 109 110 * 110 * @param float $multiplier Multiplier for number of times to run test 111 * @return string Time taken for test 112 */ 113 private function test_php_math($multiplier = 1.0) {111 * @param float $multiplier Multiplier for number of times to run test 112 * @return string Time taken for test 113 */ 114 private function test_php_math($multiplier = 1.0) { 114 115 $count = 150000 * $multiplier; 115 116 $time_start = microtime(true); … … 137 138 * Run string manipulation PHP benchmark tests 138 139 * 139 * @param float $multiplier Multiplier for number of times to run test 140 * @return string Time taken for test 141 */ 142 private function test_php_string($multiplier = 1.0) {140 * @param float $multiplier Multiplier for number of times to run test 141 * @return string Time taken for test 142 */ 143 private function test_php_string($multiplier = 1.0) { 143 144 $count = 150000 * $multiplier; 144 145 $time_start = microtime(true); … … 158 159 ord($string); 159 160 } 161 160 162 return $this->timer_diff($time_start); 161 163 } … … 164 166 * Run Loop PHP benchmark tests 165 167 * 166 * @param float $multiplier Multiplier for number of times to run test 167 * @return string Time taken for test 168 */ 169 private function test_php_loops($multiplier = 1.0) {168 * @param float $multiplier Multiplier for number of times to run test 169 * @return string Time taken for test 170 */ 171 private function test_php_loops($multiplier = 1.0) { 170 172 $count = 50000000 * $multiplier; 171 173 $time_start = microtime(true); … … 183 185 * Run If/Else PHP benchmark tests 184 186 * 185 * @param float $multiplier Multiplier for number of times to run test 186 * @return string Time taken for test 187 */ 188 private function test_php_ifelse($multiplier = 1.0) {187 * @param float $multiplier Multiplier for number of times to run test 188 * @return string Time taken for test 189 */ 190 private function test_php_ifelse($multiplier = 1.0) { 189 191 $count = 50000000 * $multiplier; 190 192 $time_start = microtime(true); 191 193 for ($i = 0; $i < $count; $i++) { 192 194 if ($i == -1) { 193 194 195 } elseif ($i == -2) { 195 196 } else if ($i == -3) { 197 198 } 199 } 196 } elseif ($i == -3) { 197 } 198 } 199 200 200 return $this->timer_diff($time_start); 201 201 } … … 203 203 /** 204 204 * Delete benchmarking records 205 * 205 * 206 206 * @param string $benchmarks_type frontend or backend 207 207 * @param int $items Number of items to keep; defaults to 25, constrained to [0-25] … … 209 209 */ 210 210 public function prune_benchmarks($benchmarks_type, $items = 25) { 211 if ($benchmarks_type != 'frontend' && $benchmarks_type != 'backend') return; 211 if ($benchmarks_type != 'frontend' && $benchmarks_type != 'backend') { 212 return; 213 } 212 214 $items = $this->constrain($items, 0, 25); 213 215 214 216 $benchmarks = []; 215 if ($benchmarks_type == 'frontend') $benchmarks = get_option('a2opt-benchmarks-frontend'); 216 elseif ($benchmarks_type == 'backend') $benchmarks = get_option('a2opt-benchmarks-hosting'); 217 if (empty($benchmarks)) return; 217 if ($benchmarks_type == 'frontend') { 218 $benchmarks = get_option('a2opt-benchmarks-frontend'); 219 } elseif ($benchmarks_type == 'backend') { 220 $benchmarks = get_option('a2opt-benchmarks-hosting'); 221 } 222 if (empty($benchmarks)) { 223 return; 224 } 218 225 219 226 $items_to_delete = count($benchmarks) - $items; 220 if ($items_to_delete < 1) return; 227 if ($items_to_delete < 1) { 228 return; 229 } 221 230 $items_deleted = 0; 222 231 … … 224 233 unset($benchmarks[$date]); 225 234 ++$items_deleted; 226 if ($items_deleted >= $items_to_delete) break; 227 } 228 229 if ($benchmarks_type == 'frontend') update_option('a2opt-benchmarks-frontend', $benchmarks); 230 elseif ($benchmarks_type == 'backend') update_option('a2opt-benchmarks-hosting', $benchmarks); 235 if ($items_deleted >= $items_to_delete) { 236 break; 237 } 238 } 239 240 if ($benchmarks_type == 'frontend') { 241 update_option('a2opt-benchmarks-frontend', $benchmarks); 242 } elseif ($benchmarks_type == 'backend') { 243 update_option('a2opt-benchmarks-hosting', $benchmarks); 244 } 231 245 } 232 246 233 247 /** 234 248 * Private helper function to constrain a float to a range of values 235 * 249 * 236 250 * @param float $value The value to constrain 237 251 * @param float $min The minimum value for the value (inclusive) … … 246 260 $value = $min; 247 261 } 262 248 263 return $value; 249 264 } … … 252 267 * Run MySQL benchmark tests 253 268 * 254 * @param int $count Optional number of times to run test 255 * @return string Time taken for test 256 */ 257 public function run_mysql_benchmarks($count = 1) {269 * @param int $count Optional number of times to run test 270 * @return string Time taken for test 271 */ 272 public function run_mysql_benchmarks($count = 1) { 258 273 $results = []; 259 274 … … 262 277 $wpdb_cfg['db.user'] = DB_USER; 263 278 $wpdb_cfg['db.pw'] = DB_PASSWORD; 264 $wpdb_cfg['db.name'] = DB_NAME; 279 $wpdb_cfg['db.name'] = DB_NAME; 265 280 266 281 $time_start = microtime(true); 267 282 268 283 //detect socket connection 269 if (stripos($wpdb_cfg['db.host'], '.sock')!==false){284 if (stripos($wpdb_cfg['db.host'], '.sock') !== false) { 270 285 //parse socket location 271 286 //set a default guess 272 $socket = "/var/lib/mysql.sock";287 $socket = '/var/lib/mysql.sock'; 273 288 $serverhost = explode(':', $wpdb_cfg['db.host']); 274 if (count($serverhost) == 2 && $serverhost[0] == 'localhost'){289 if (count($serverhost) == 2 && $serverhost[0] == 'localhost') { 275 290 $socket = $serverhost[1]; 276 291 } … … 279 294 //parse out port number if exists 280 295 $port = 3306;//default 281 if (stripos($wpdb_cfg['db.host'],':')){282 $port = substr($wpdb_cfg['db.host'], stripos($wpdb_cfg['db.host'], ':')+1);283 $wpdb_cfg['db.host'] = substr($wpdb_cfg['db.host'], 0, stripos($wpdb_cfg['db.host'], ':'));296 if (stripos($wpdb_cfg['db.host'], ':')) { 297 $port = substr($wpdb_cfg['db.host'], stripos($wpdb_cfg['db.host'], ':') + 1); 298 $wpdb_cfg['db.host'] = substr($wpdb_cfg['db.host'], 0, stripos($wpdb_cfg['db.host'], ':')); 284 299 } 285 300 $link = mysqli_connect($wpdb_cfg['db.host'], $wpdb_cfg['db.user'], $wpdb_cfg['db.pw'], $wpdb_cfg['db.name'], $port); … … 308 323 * Run WordPress DB benchmark tests 309 324 * 310 * @param int $count Optional number of times to run test 311 * @return array Time taken for test and number of queries per second 312 */ 313 public function run_wordpress_benchmarks($count = 500) {325 * @param int $count Optional number of times to run test 326 * @return array Time taken for test and number of queries per second 327 */ 328 public function run_wordpress_benchmarks($count = 500) { 314 329 global $wpdb; 315 330 316 331 // dummy text to insert into database 317 $dummytextseed = "Sed tincidunt malesuada viverra. Aliquam dolor diam, interdum quis mauris eget, accumsan imperdiet nisi. Proin mattis massa sapien, et tempor enim lacinia suscipit. Donec at massa ullamcorper, pellentesque lacus sit amet, facilisis metus. Proin lobortis elementum lorem eu volutpat. Aenean sed volutpat augue. Morbi vel dolor commodo, tempor ex ac, hendrerit ante. Vestibulum pellentesque fringilla ligula ac aliquet. Cras tempus enim nec imperdiet convallis. Aliquam elit ex, ornare vestibulum placerat quis, tincidunt ultrices dolor. Morbi gravida sapien congue leo sagittis, sed semper turpis blandit. Aenean malesuada eros vitae orci tristique, vitae imperdiet libero mollis. Nunc lacinia congue tempor. Etiam vitae enim ut eros fermentum elementum. Praesent aliquam iaculis velit, quis dictum nibh.";318 $dummytext = "";319 for ($x=0; $x<100; $x++){332 $dummytextseed = 'Sed tincidunt malesuada viverra. Aliquam dolor diam, interdum quis mauris eget, accumsan imperdiet nisi. Proin mattis massa sapien, et tempor enim lacinia suscipit. Donec at massa ullamcorper, pellentesque lacus sit amet, facilisis metus. Proin lobortis elementum lorem eu volutpat. Aenean sed volutpat augue. Morbi vel dolor commodo, tempor ex ac, hendrerit ante. Vestibulum pellentesque fringilla ligula ac aliquet. Cras tempus enim nec imperdiet convallis. Aliquam elit ex, ornare vestibulum placerat quis, tincidunt ultrices dolor. Morbi gravida sapien congue leo sagittis, sed semper turpis blandit. Aenean malesuada eros vitae orci tristique, vitae imperdiet libero mollis. Nunc lacinia congue tempor. Etiam vitae enim ut eros fermentum elementum. Praesent aliquam iaculis velit, quis dictum nibh.'; 333 $dummytext = ''; 334 for ($x=0; $x < 100; $x++) { 320 335 $dummytext .= str_shuffle($dummytextseed); 321 336 } … … 325 340 $table = $wpdb->prefix . 'options'; 326 341 $optionname = 'a2opt_benchmark_'; 327 for ($x=0; $x<$count;$x++){342 for ($x=0; $x < $count;$x++) { 328 343 //insert 329 $data = array('option_name' => $optionname . $x, 'option_value' => $dummytext);344 $data = ['option_name' => $optionname . $x, 'option_value' => $dummytext]; 330 345 $wpdb->insert($table, $data); 331 346 //select … … 333 348 $wpdb->get_var($select); 334 349 //update 335 $data = array('option_value' => $dummytextseed);336 $where = array('option_name' => $optionname . $x);350 $data = ['option_value' => $dummytextseed]; 351 $where = ['option_name' => $optionname . $x]; 337 352 $wpdb->update($table, $data, $where); 338 353 //delete 339 $where = array('option_name'=>$optionname.$x);340 $wpdb->delete($table, $where);354 $where = ['option_name'=>$optionname . $x]; 355 $wpdb->delete($table, $where); 341 356 } 342 357 343 358 $time = $this->timer_diff($time_start); 344 359 $queries = ($count * 4) / $time; 360 345 361 return [ 346 362 'time' => $time, 347 363 'queries_per_second' => $queries, 348 ]; 364 ]; 349 365 } 350 366 … … 352 368 * Run filesystem benchmark tests 353 369 * 354 * @param int $count Optional number of times to run test 355 * @return array Time taken for test and number of queries per second 356 */ 357 public function run_filesystem_benchmarks($count = 1) {370 * @param int $count Optional number of times to run test 371 * @return array Time taken for test and number of queries per second 372 */ 373 public function run_filesystem_benchmarks($count = 1) { 358 374 // Make sure tmp folder is empty and we can write to it 359 if (!$this->clean_tmp_folder()){375 if (!$this->clean_tmp_folder()) { 360 376 return false; 361 } ;362 363 $time_start = microtime(true); 364 365 $write_content = "";366 377 } 378 379 $time_start = microtime(true); 380 381 $write_content = ''; 382 367 383 // Get 1mb of data 368 for ($m=0; $m < 1024; $m++){384 for ($m=0; $m < 1024; $m++) { 369 385 $write_content .= $this->get_1kb_text(); 370 386 } 371 387 372 $fn = $this->tmp_folder_name . "/tmp.filewrite"; 373 374 for($i=0; $i < $count; $i++) { 375 376 if(file_exists($fn)) { 388 $fn = $this->tmp_folder_name . '/tmp.filewrite'; 389 390 for ($i=0; $i < $count; $i++) { 391 if (file_exists($fn)) { 377 392 unlink($fn); 378 393 clearstatcache(); 379 394 } 380 395 381 $fp = fopen($fn, "w");396 $fp = fopen($fn, 'w'); 382 397 383 398 // Write 50mb 384 for ($k=0; $k < 50; $k++){385 if ($this->timer_diff($time_start) > 10){399 for ($k=0; $k < 50; $k++) { 400 if ($this->timer_diff($time_start) > 10) { 386 401 // If this is taking more than 10 seconds, we're being throttled, just bail 387 402 fclose($fp); 388 403 clearstatcache(); 389 404 $this->clean_tmp_folder(); 405 390 406 return 10; 391 407 } 392 408 393 409 fwrite($fp, $write_content); 394 410 } … … 406 422 /** 407 423 * Filter out the data being returned by lighthouse down to only the data that we actually care about. 408 * 424 * 409 425 * @param array array of data that's been returned from lighthouse api call 410 426 * @return array filtered array of only the data that we want to store 411 427 */ 412 private function filter_lighthouse_data($lighthouse_data){ 413 428 private function filter_lighthouse_data($lighthouse_data) { 414 429 $scores = []; 415 430 416 foreach ($lighthouse_data['lighthouseResult']['categories'] as $group) {417 foreach ($group['auditRefs'] as $ref){431 foreach ($lighthouse_data['lighthouseResult']['categories'] as $group) { 432 foreach ($group['auditRefs'] as $ref) { 418 433 if ('server-response-time' === $ref['id']) { 419 434 $scores['ttfb'] = round( $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue'] ); … … 423 438 $scores['fcp'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue']; 424 439 } 425 440 426 441 if ( 'cumulative-layout-shift' === $ref['id'] ) { 427 442 $scores['cls'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue']; 428 443 } 429 444 430 445 if ( 'largest-contentful-paint' === $ref['id'] ) { 431 446 $scores['lcp'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue']; 432 447 } 433 448 434 449 if ( 'max-potential-fid' === $ref['id'] ) { 435 450 $scores['fid'] = $lighthouse_data['lighthouseResult']['audits'][ $ref['id'] ]['numericValue']; … … 438 453 } 439 454 440 foreach ($this->get_seo_audits() as $audit){441 if (isset($lighthouse_data['lighthouseResult']['audits'][$audit])){455 foreach ($this->get_seo_audits() as $audit) { 456 if (isset($lighthouse_data['lighthouseResult']['audits'][$audit])) { 442 457 $scores['audit_result'][$audit] = $lighthouse_data['lighthouseResult']['audits'][$audit]; 443 458 } … … 449 464 } 450 465 451 452 466 /** 453 467 * Get Lighthouse results 454 468 * 455 * @param string $strategy Desktop or Mobile 456 * @return array $results Array containing the results of the test 457 */ 458 public function get_lighthouse_results($strategy = "desktop", $retry_count = 3, $result_desc = null){469 * @param string $strategy Desktop or Mobile 470 * @return array $results Array containing the results of the test 471 */ 472 public function get_lighthouse_results($strategy = 'desktop', $retry_count = 3, $result_desc = null) { 459 473 $output = []; 460 474 461 475 $url = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . get_site_url() . '&strategy=' . $strategy; 462 476 $pagespeed_options = get_option('a2opt-pagespeed'); 463 if ($pagespeed_options && isset($pagespeed_options['api-key'])){477 if ($pagespeed_options && isset($pagespeed_options['api-key'])) { 464 478 $url .= '&key=' . $pagespeed_options['api-key']; 465 479 } 466 480 $response = wp_remote_get($url, ['timeout' => 45]); 467 if (is_array($response) && !is_wp_error($response)){481 if (is_array($response) && !is_wp_error($response)) { 468 482 $lighthouse_data = json_decode($response['body'], true); 469 if (!isset($lighthouse_data['error']) || empty($lighthouse_data['error'])){483 if (!isset($lighthouse_data['error']) || empty($lighthouse_data['error'])) { 470 484 // success 471 485 $option_key = 'a2opt-benchmarks-frontend'; 472 486 $existing_results = get_option($option_key); 473 if (!$existing_results){487 if (!$existing_results) { 474 488 $existing_results = []; 475 489 } 476 490 477 491 $existing_results[date('Y-m-d H:i:s')] = [ 478 492 'strategy' => $strategy, … … 488 502 } else { 489 503 $error_code = $lighthouse_data['error']['code']; 490 if (in_array($error_code, [500,400]) || $retry_count <= 0) {504 if (in_array($error_code, [500,400]) || $retry_count <= 0) { 491 505 $error_msg = ''; 492 if (isset($lighthouse_data['error']['message'])){506 if (isset($lighthouse_data['error']['message'])) { 493 507 $error_msg = $lighthouse_data['error']['message']; 494 508 } … … 497 511 'message' => 'There was an error retrieving results from Pagespeed. ' . $error_msg, 498 512 ]; 499 } 500 else { 513 } else { 501 514 $output = $this->get_lighthouse_results($strategy, --$retry_count, $result_desc); 502 515 } 503 } ;516 } 504 517 } else { 505 518 $output = [ … … 512 525 } 513 526 514 515 private function get_seo_audits(){ 527 private function get_seo_audits() { 516 528 $audits = [ 517 529 'first-contentful-paint', … … 558 570 'uses-long-cache-ttl' 559 571 ]; 560 572 561 573 return $audits; 562 574 } 563 575 564 565 576 /** 566 577 * Time elapsed since the passed in time 567 578 * 568 * @param string $time_start timestamp 569 * @return string Time elapsed in seconds 570 */ 571 private function timer_diff($time_start) {579 * @param string $time_start timestamp 580 * @return string Time elapsed in seconds 581 */ 582 private function timer_diff($time_start) { 572 583 return number_format(microtime(true) - $time_start, 3); 573 584 } … … 576 587 * 1kb of text to build out file operations 577 588 * 578 * @return string The blob of text 589 * @return string The blob of text 579 590 */ 580 591 private function get_1kb_text() { 581 return( "AAA2A2A222222AAAA2AAA2AA22A222AA22AAA22A2A22AAA222A22A2A2A2AA22222AAAAAAA22A222AAA22AAAAA222AA2AAA22A2A2AA22AA2A2222A22AAAA2AAA2A222222AA22AAAA2A2A2AA2222A2A2AA2A2AAAA2AA222A222A22AAA22AA2AA22AA22AAA2AA2A22A222222A2AA2A222A22A22A2A2AAAA222A2A2A2A2AAAA2A22AA22AAA2A2AAA2A222A2AAAA2AA22A2AA222A222AA22222222AAAAA2A22A2AA22A2AAAAA2AAAAAA2AAAA22AAAA22A2AAAAAA2AA2A22A22AA2AA22A2AA2AAA2A2A22A222AA2AAAA22A2A2AAAA2AA2A2A22A2A2A2AA222AA22AAA2AAAAA2AA2A2A2A22AAA222A22AA22AA2A222A222AA2AAAA2222A2AA22AA2A22AAAA2AA222A2AAA22AA22A2AA2AA22A222AA2AAA22A2A222A2A2222A2A2222AAAAA2A222AA22A2A2A2222AAAA2AA22AAAA2AA2AAAAAAA22AAAA2AA2AA2A2A2AAAAAA22AA222AAAA2AAAA22AA222222A2AA222A22A2AA2A22222A2A2A2AA222222A2A222AAA2AA2A2A222A22222AAAAA2A2A22AAAAAA2A2A222A2AA2AAAA222AAAA2A22A222A2A2A2A2AA222AA2A2AA2A222AA2A2A2A22222A22A2A2A2AA2A2A2222A2222A2AAA2A2222AA222A22222222AA2AA222AA2AAAA2AA2AA22A2AA22AA2222A22A222AA2A2A22222AAA2A2A2A2AAAAAAA2222AA2222AA2222A2AAAA22AA2A2A2A2A22A2AAAAAAA222A22A22AA2AAA2AA222AA22A2AAAAA2A2AAA2AA22AA2A222AAA222A2");592 return('AAA2A2A222222AAAA2AAA2AA22A222AA22AAA22A2A22AAA222A22A2A2A2AA22222AAAAAAA22A222AAA22AAAAA222AA2AAA22A2A2AA22AA2A2222A22AAAA2AAA2A222222AA22AAAA2A2A2AA2222A2A2AA2A2AAAA2AA222A222A22AAA22AA2AA22AA22AAA2AA2A22A222222A2AA2A222A22A22A2A2AAAA222A2A2A2A2AAAA2A22AA22AAA2A2AAA2A222A2AAAA2AA22A2AA222A222AA22222222AAAAA2A22A2AA22A2AAAAA2AAAAAA2AAAA22AAAA22A2AAAAAA2AA2A22A22AA2AA22A2AA2AAA2A2A22A222AA2AAAA22A2A2AAAA2AA2A2A22A2A2A2AA222AA22AAA2AAAAA2AA2A2A2A22AAA222A22AA22AA2A222A222AA2AAAA2222A2AA22AA2A22AAAA2AA222A2AAA22AA22A2AA2AA22A222AA2AAA22A2A222A2A2222A2A2222AAAAA2A222AA22A2A2A2222AAAA2AA22AAAA2AA2AAAAAAA22AAAA2AA2AA2A2A2AAAAAA22AA222AAAA2AAAA22AA222222A2AA222A22A2AA2A22222A2A2A2AA222222A2A222AAA2AA2A2A222A22222AAAAA2A2A22AAAAAA2A2A222A2AA2AAAA222AAAA2A22A222A2A2A2A2AA222AA2A2AA2A222AA2A2A2A22222A22A2A2A2AA2A2A2222A2222A2AAA2A2222AA222A22222222AA2AA222AA2AAAA2AA2AA22A2AA22AA2222A22A222AA2A2A22222AAA2A2A2A2AAAAAAA2222AA2222AA2222A2AAAA22AA2A2A2A2A22A2AAAAAAA222A22A22AA2AAA2AA222AA22A2AAAAA2A2AAA2AA22AA2A222AAA222A2'); 582 593 } 583 594 … … 588 599 $tmp_folder = $this->tmp_folder_name; 589 600 if (!is_dir($tmp_folder)) { 590 if (!mkdir($tmp_folder)) {601 if (!mkdir($tmp_folder)) { 591 602 return false; 592 603 } 593 604 } 605 594 606 return true; 595 607 } … … 602 614 603 615 if (!is_dir($tmp_folder)) { 604 if ($this->make_tmp_folder()){616 if ($this->make_tmp_folder()) { 605 617 return true; 606 618 } else { … … 608 620 } 609 621 } 610 622 611 623 if ($dh = opendir($tmp_folder)) { 612 while (($file = readdir($dh)) !== false) {624 while (($file = readdir($dh)) !== false) { 613 625 if ($file != '.' && $file != '..') { 614 if (is_file($tmp_folder . '/' . $file)) {626 if (is_file($tmp_folder . '/' . $file)) { 615 627 unlink($tmp_folder . '/' . $file); 616 628 } … … 619 631 closedir($dh); 620 632 } 633 621 634 return true; 622 635 } … … 642 655 'mysql' => '1.907', 643 656 'wordpress_db' => [ 644 'time' => '1. 606',645 'queries_per_second' => '1 245.33',657 'time' => '1.290', 658 'queries_per_second' => '1550.38', 646 659 ], 647 660 'filesystem' => '2.503', 648 661 ]; 649 662 650 663 $results['a2hosting-other'] = [ 651 664 'name' => 'Fly', … … 662 675 'mysql' => '1.863', 663 676 'wordpress_db' => [ 664 'time' => '1. 673',665 'queries_per_second' => '1 195.4',677 'time' => '1.232', 678 'queries_per_second' => '1623.37', 666 679 ], 667 680 'filesystem' => '2.337', 668 681 ]; 669 682 670 if (file_exists('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php')){671 require_once('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php');672 $private_opts = new A2_Optimized_Private_Optimizations();683 if (file_exists('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php')) { 684 require_once('/opt/a2-optimized/wordpress/class.A2_Optimized_Private_Optimizations_v3.php'); 685 $private_opts = new A2_Optimized_Private_Optimizations(); 673 686 $results['a2hosting-other'] = $private_opts->get_baseline_results(); 674 }687 } 675 688 676 689 return $results; 677 690 } 678 679 691 } -
a2-optimized-wp/trunk/readme.txt
r2949508 r2954507 4 4 Requires at least: 5.1 5 5 Tested up to: 6.3 6 Stable tag: 3.0.6.4. 16 Stable tag: 3.0.6.4.2 7 7 Requires PHP: 5.6 8 8 License: GPLv3
Note: See TracChangeset
for help on using the changeset viewer.