Ticket #50038: 50038.2.diff
File 50038.2.diff, 6.2 KB (added by , 4 years ago) |
---|
-
src/wp-admin/includes/class-wp-debug-data.php
519 519 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ), 520 520 ); 521 521 522 if ( ! function_exists( 'ini_get' ) ) { 523 $info['wp-media']['fields']['ini_get'] = array( 524 'label' => __( 'File upload settings' ), 525 'value' => sprintf( 526 /* translators: %s: ini_get() */ 527 __( 'Unable to determine some settings, as the %s function has been disabled.' ), 528 'ini_get()' 529 ), 530 'debug' => 'ini_get() is disabled', 531 ); 532 } else { 533 // Get the PHP ini directive values. 534 $post_max_size = ini_get( 'post_max_size' ); 535 $upload_max_size = ini_get( 'upload_max_filesize' ); 536 $max_file_uploads = ini_get( 'max_file_uploads' ); 537 $effective = min( WP_Site_Health::parse_ini_size( $post_max_size ), WP_Site_Health::parse_ini_size( $upload_max_size ) ); 538 // Add info in Media section. 539 $info['wp-media']['fields']['file_uploads'] = array( 540 'label' => __( 'File uploads' ), 541 'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ), 542 'debug' => 'File uploads is turned off', 543 ); 544 $info['wp-media']['fields']['post_max_size'] = array( 545 'label' => __( 'Max size of post data allowed' ), 546 'value' => $post_max_size, 547 ); 548 $info['wp-media']['fields']['upload_max_filesize'] = array( 549 'label' => __( 'Max size of an uploaded file' ), 550 'value' => $upload_max_size, 551 ); 552 $info['wp-media']['fields']['upload_max'] = array( 553 'label' => __( 'Max effective file size' ), 554 'value' => size_format( $effective ), 555 ); 556 $info['wp-media']['fields']['max_file_uploads'] = array( 557 'label' => __( 'Max number of files allowed' ), 558 'value' => number_format( $max_file_uploads ), 559 ); 560 } 561 522 562 // If Imagick is used as our editor, provide some more information about its limitations. 523 563 if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) { 524 564 $limits = array( -
src/wp-admin/includes/class-wp-site-health.php
1956 1956 } 1957 1957 1958 1958 /** 1959 * Test if 'file_uploads' directive in PHP.ini is turned off 1960 * 1961 * @since 5.5.0 1962 * 1963 * @return array The test results. 1964 */ 1965 public function get_test_file_uploads() { 1966 $result = array( 1967 'label' => __( 'Files can be uploaded.' ), 1968 'status' => 'good', 1969 'badge' => array( 1970 'label' => __( 'Performance' ), 1971 'color' => 'blue', 1972 ), 1973 'description' => sprintf( 1974 '<p>%s</p>', 1975 sprintf( 1976 /* translators: %1$s: file_uploads %2$s: php.ini */ 1977 __( 'The %1$s directive in %2$s determines if uploading to is allowed in your WordPress.' ), 1978 '<code>file_uploads</code>', 1979 '<code>php.ini</code>' 1980 ) 1981 ), 1982 'actions' => '', 1983 'test' => 'file_uploads', 1984 ); 1985 1986 if ( ! function_exists( 'ini_get' ) ) { 1987 $result['status'] = 'critical'; 1988 $result['description'] .= sprintf( 1989 /* translators: %s: ini_get() */ 1990 __( 'The %s function has been disabled, some media settings are unavailable because of this.' ), 1991 '<code>ini_get()</code>' 1992 ); 1993 return $result; 1994 } 1995 1996 if ( empty( ini_get( 'file_uploads' ) ) ) { 1997 $result['status'] = 'critical'; 1998 $result['description'] .= sprintf( 1999 '<p>%s</p>', 2000 sprintf( 2001 /* translators: %1$s: file_uploads %2$s: 0 */ 2002 __( '%1$s is set to %2$s. You won\'t be able to upload files in your WordPress.' ), 2003 '<code>file_uploads</code>', 2004 '<code>0</code>' 2005 ) 2006 ); 2007 return $result; 2008 } 2009 2010 if ( parse_ini_size( ini_get( 'post_max_size' ) ) !== parse_ini_size( ini_get( 'upload_max_filesize' ) ) ) { 2011 $result['label'] = __( 'Mismatched "post_max_size" and "upload_max_filesize" values.' ); 2012 $result['status'] = 'recommended'; 2013 $result['description'] = sprintf( 2014 '<p>%s</p>', 2015 sprintf( 2016 /* translators: %1$s: post_max_size %2$s: upload_max_filesize */ 2017 __( 'The settings for %1$s and %2$s are not the same, this could cause some problems when trying to upload files.' ), 2018 '<code>post_max_size</code>', 2019 '<code>upload_max_filesize</code>' 2020 ) 2021 ); 2022 return $result; 2023 } 2024 2025 return $result; 2026 } 2027 2028 /** 1959 2029 * Return a set of tests that belong to the site status page. 1960 2030 * 1961 2031 * Each site status test is defined here, they may be `direct` tests, that run on page load, or `async` tests … … 2025 2095 'label' => __( 'Debugging enabled' ), 2026 2096 'test' => 'is_in_debug_mode', 2027 2097 ), 2098 'file_uploads' => array( 2099 'label' => __( 'File uploads' ), 2100 'test' => 'file_uploads', 2101 ), 2028 2102 ), 2029 2103 'async' => array( 2030 2104 'dotorg_communication' => array( -
src/wp-includes/functions.php
477 477 } 478 478 479 479 /** 480 * Converts a shorthand byte string to bytes. 481 * 482 * Useful when needing to compare two byte strings for size differences. 483 * 484 * E.g. 485 * "1G" (1 Gigabyte) = 1073741824 486 * "10M" (10 Megabytes) = 10485760 487 * "1K" (1 Kilobyte) = 1024 488 * 489 * @since 5.5.0 490 * 491 * @param string $size_string Shorthand byte string 492 * @return int $size_string converted to numberic bytes. 493 */ 494 function parse_ini_size( $size_string ) { 495 $size_string = trim( $size_string ); 496 $last = strtolower( substr( $size_string, - 1 ) ); 497 $value = intval( $size_string ); 498 499 switch ( $last ) { 500 case 'g': 501 return (int) $value * GB_IN_BYTES; 502 case 'm': 503 return (int) $value * MB_IN_BYTES; 504 case 'k': 505 return (int) $value * KB_IN_BYTES; 506 default: 507 return (int) $value; 508 } 509 } 510 511 /** 480 512 * Convert a duration to human readable format. 481 513 * 482 514 * @since 5.1.0