Ticket #50038: 50038.diff
File 50038.diff, 5.8 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' => __( 'File uploads is on in PHP ini' ), 1968 'status' => 'good', 1969 'badge' => array( 1970 'label' => __( 'Media' ), 1971 'color' => 'blue', 1972 ), 1973 'description' => sprintf( 1974 '<p>%s</p>', 1975 __( 'The <code>file_uploads</code> directive in <code>php.ini</code> determines if uploading to is allowed in your WordPress.' ) 1976 ), 1977 'actions' => '', 1978 'test' => 'file_uploads', 1979 ); 1980 1981 if ( ! function_exists( 'ini_get' ) ) { 1982 $result['status'] = 'critical'; 1983 $result['description'] .= sprintf( 1984 /* translators: %s: ini_get() */ 1985 __( 'Unable to determine some settings, as the %s function has been disabled.' ), 1986 'ini_get()' 1987 ); 1988 return $result; 1989 } 1990 1991 if ( empty( ini_get( 'file_uploads' ) ) ) { 1992 $result['status'] = 'critical'; 1993 $result['description'] .= sprintf( 1994 '<p>%s</p>', 1995 __( '<code>file_uploads</code> is set to <code>0</code>. You won\'t be able to upload files in your WordPress.' ) 1996 ); 1997 return $result; 1998 } 1999 2000 if ( $this->parse_ini_size( ini_get( 'post_max_size' ) ) !== $this->parse_ini_size( ini_get( 'upload_max_filesize' ) ) ) { 2001 $result['label'] = __( 'Mismatched "post_max_size" and "upload_max_filesize" values.' ); 2002 $result['status'] = 'recommended'; 2003 $result['description'] = sprintf( 2004 '<p>%s</p>', 2005 __( 'Mismatched values for PHP INI directives <code>post_max_size</code> and <code>upload_max_filesize</code> may cause problems. These values are in PHP INI.' ) 2006 ); 2007 return $result; 2008 } 2009 2010 return $result; 2011 } 2012 2013 /** 1959 2014 * Return a set of tests that belong to the site status page. 1960 2015 * 1961 2016 * Each site status test is defined here, they may be `direct` tests, that run on page load, or `async` tests … … 2025 2080 'label' => __( 'Debugging enabled' ), 2026 2081 'test' => 'is_in_debug_mode', 2027 2082 ), 2083 'file_uploads' => array( 2084 'label' => __( 'File uploads' ), 2085 'test' => 'file_uploads', 2086 ), 2028 2087 ), 2029 2088 'async' => array( 2030 2089 '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