Changeset 46268
- Timestamp:
- 09/23/2019 07:49:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-site-health.php
r46267 r46268 728 728 * 729 729 * @since 5.2.0 730 * @since 5.3.0 The `$constant` and `$class` parameters were added. 730 731 * 731 732 * @param string $extension Optional. The extension name to test. Default null. 732 733 * @param string $function Optional. The function name to test. Default null. 734 * @param string $constant Optional. The constant name to test for. Default null. 735 * @param string $class Optional. The class name to test for. Default null. 733 736 * 734 737 * @return bool Whether or not the extension and function are available. 735 738 */ 736 private function test_php_extension_availability( $extension = null, $function = null ) {739 private function test_php_extension_availability( $extension = null, $function = null, $constant = null, $class = null ) { 737 740 // If no extension or function is passed, claim to fail testing, as we have nothing to test against. 738 if ( ! $extension && ! $function ) {741 if ( ! $extension && ! $function && ! $constant && ! $class ) { 739 742 return false; 740 743 } … … 744 747 } 745 748 if ( $function && ! function_exists( $function ) ) { 749 return false; 750 } 751 if ( $constant && ! defined( $constant ) ) { 752 return false; 753 } 754 if ( $class && ! class_exists( $class ) ) { 746 755 return false; 747 756 } … … 789 798 790 799 $modules = array( 791 'bcmath' => array(792 'function' => 'bcadd',793 'required' => false,794 ),795 800 'curl' => array( 796 801 'function' => 'curl_version', 797 802 'required' => false, 798 803 ), 804 'dom' => array( 805 'class' => 'DOMNode', 806 'required' => false, 807 ), 799 808 'exif' => array( 800 809 'function' => 'exif_read_data', 801 810 'required' => false, 802 811 ), 812 'fileinfo' => array( 813 'function' => 'finfo_file', 814 'required' => false, 815 ), 816 'hash' => array( 817 'function' => 'hash', 818 'required' => false, 819 ), 820 'json' => array( 821 'function' => 'json_last_error', 822 'required' => true, 823 ), 824 'mbstring' => array( 825 'function' => 'mb_check_encoding', 826 'required' => false, 827 ), 828 'mysqli' => array( 829 'function' => 'mysqli_connect', 830 'required' => false, 831 ), 832 'libsodium' => array( 833 'constant' => 'SODIUM_LIBRARY_VERSION', 834 'required' => false, 835 'php_bundled_version' => '7.2.0', 836 ), 837 'openssl' => array( 838 'function' => 'openssl_encrypt', 839 'required' => false, 840 ), 841 'pcre' => array( 842 'function' => 'preg_match', 843 'required' => false, 844 ), 845 'imagick' => array( 846 'extension' => 'imagick', 847 'required' => false, 848 ), 849 'mod_xml' => array( 850 'extension' => 'libxml', 851 'required' => false, 852 ), 853 'zip' => array( 854 'class' => 'ZipArchive', 855 'required' => false, 856 ), 803 857 'filter' => array( 804 858 'function' => 'filter_list', 805 859 'required' => false, 806 ),807 'fileinfo' => array(808 'function' => 'finfo_file',809 'required' => false,810 ),811 'mod_xml' => array(812 'extension' => 'libxml',813 'required' => false,814 ),815 'mysqli' => array(816 'function' => 'mysqli_connect',817 'required' => false,818 ),819 'libsodium' => array(820 'function' => 'sodium_compare',821 'required' => false,822 'php_bundled_version' => '7.2.0',823 ),824 'openssl' => array(825 'function' => 'openssl_encrypt',826 'required' => false,827 ),828 'pcre' => array(829 'function' => 'preg_match',830 'required' => false,831 ),832 'imagick' => array(833 'extension' => 'imagick',834 'required' => false,835 860 ), 836 861 'gd' => array( … … 839 864 'fallback_for' => 'imagick', 840 865 ), 866 'iconv' => array( 867 'function' => 'iconv', 868 'required' => false, 869 ), 841 870 'mcrypt' => array( 842 871 'extension' => 'mcrypt', … … 844 873 'fallback_for' => 'libsodium', 845 874 ), 875 'simplexml' => array( 876 'extension' => 'simplexml', 877 'required' => false, 878 'fallback_for' => 'mod_xml', 879 ), 846 880 'xmlreader' => array( 847 881 'extension' => 'xmlreader', 848 882 'required' => false, 849 'fallback_for' => ' xml',883 'fallback_for' => 'mod_xml', 850 884 ), 851 885 'zlib' => array( … … 860 894 * 861 895 * @since 5.2.0 896 * @since 5.3.0 The `$constant` and `$class` parameters were added. 862 897 * 863 898 * @param array $modules { … … 870 905 * string $function Optional. A function name to test for the existence of. 871 906 * string $extension Optional. An extension to check if is loaded in PHP. 907 * string $constant Optional. A constant name to check for to verify an extension exists. 908 * string $class Optional. A class name to check for to verify an extension exists. 872 909 * bool $required Is this a required feature or not. 873 910 * string $fallback_for Optional. The module this module replaces as a fallback. … … 880 917 881 918 foreach ( $modules as $library => $module ) { 882 $extension = ( isset( $module['extension'] ) ? $module['extension'] : null ); 883 $function = ( isset( $module['function'] ) ? $module['function'] : null ); 919 $extension = ( isset( $module['extension'] ) ? $module['extension'] : null ); 920 $function = ( isset( $module['function'] ) ? $module['function'] : null ); 921 $constant = ( isset( $module['constant'] ) ? $module['constant'] : null ); 922 $class_name = ( isset( $module['class'] ) ? $module['class'] : null ); 884 923 885 924 // If this module is a fallback for another function, check if that other function passed. … … 896 935 } 897 936 898 if ( ! $this->test_php_extension_availability( $extension, $function ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {937 if ( ! $this->test_php_extension_availability( $extension, $function, $constant, $class_name ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) { 899 938 if ( $module['required'] ) { 900 939 $result['status'] = 'critical';
Note: See TracChangeset
for help on using the changeset viewer.