Ticket #47454: 47454.patch
File 47454.patch, 5.5 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/class-wp-site-health.php
714 714 * 715 715 * @param string $extension Optional. The extension name to test. Default null. 716 716 * @param string $function Optional. The function name to test. Default null. 717 * @param string $constant Optional. The constant name to test for. Default null. 718 * @param string $class Optional. The class name to test for. Default null. 717 719 * 718 720 * @return bool Whether or not the extension and function are available. 719 721 */ 720 private function test_php_extension_availability( $extension = null, $function = null ) {722 private function test_php_extension_availability( $extension = null, $function = null, $constant = null, $class = null ) { 721 723 // If no extension or function is passed, claim to fail testing, as we have nothing to test against. 722 if ( ! $extension && ! $function ) {724 if ( ! $extension && ! $function && ! $constant && ! $class ) { 723 725 return false; 724 726 } 725 727 … … 729 731 if ( $function && ! function_exists( $function ) ) { 730 732 return false; 731 733 } 734 if ( $constant && ! defined( $constant ) ) { 735 return false; 736 } 737 if ( $class && ! class_exists( $class ) ) { 738 return false; 739 } 732 740 733 741 return true; 734 742 } … … 772 780 ); 773 781 774 782 $modules = array( 775 'bcmath' => array(776 'function' => 'bcadd',777 'required' => false,778 ),779 783 'curl' => array( 780 784 'function' => 'curl_version', 781 785 'required' => false, 782 786 ), 787 'dom' => array( 788 'class' => 'DOMNode', 789 'required' => false, 790 ), 783 791 'exif' => array( 784 792 'function' => 'exif_read_data', 785 793 'required' => false, 786 ),787 'filter' => array(788 'function' => 'filter_list',789 'required' => false,790 794 ), 791 795 'fileinfo' => array( 792 796 'function' => 'finfo_file', 793 797 'required' => false, 794 798 ), 795 'mod_xml' => array( 796 'extension' => 'libxml', 797 'required' => false, 799 'hash' => array( 800 'function' => 'hash', 801 'required' => false, 802 ), 803 'json' => array( 804 'function' => 'json_encode', 805 'required' => false, 806 ), 807 'mbstring' => array( 808 'function' => 'mb_check_encoding', 809 'required' => false, 798 810 ), 799 811 'mysqli' => array( 800 812 'function' => 'mysqli_connect', 801 813 'required' => false, 802 814 ), 803 815 'libsodium' => array( 804 ' function' => 'sodium_compare',816 'constant' => 'SODIUM_LIBRARY_VERSION', 805 817 'required' => false, 806 818 'php_bundled_version' => '7.2.0', 807 819 ), … … 817 829 'extension' => 'imagick', 818 830 'required' => false, 819 831 ), 832 'mod_xml' => array( 833 'extension' => 'libxml', 834 'required' => false, 835 ), 836 'zip' => array( 837 'class' => 'ZipArchive', 838 'required' => false, 839 ), 840 'filter' => array( 841 'function' => 'filter_list', 842 'required' => false, 843 ), 820 844 'gd' => array( 821 845 'extension' => 'gd', 822 846 'required' => false, 823 847 'fallback_for' => 'imagick', 824 848 ), 849 'iconv' => array( 850 'function' => 'iconv', 851 'required' => false, 852 ), 825 853 'mcrypt' => array( 826 854 'extension' => 'mcrypt', 827 855 'required' => false, 828 856 'fallback_for' => 'libsodium', 829 857 ), 858 'simplexml' => array( 859 'extension' => 'simplexml', 860 'required' => false, 861 'fallback_for' => 'mod_xml', 862 ), 830 863 'xmlreader' => array( 831 864 'extension' => 'xmlreader', 832 865 'required' => false, 833 'fallback_for' => ' xml',866 'fallback_for' => 'mod_xml', 834 867 ), 835 868 'zlib' => array( 836 869 'extension' => 'zlib', … … 853 886 * 854 887 * string $function Optional. A function name to test for the existence of. 855 888 * string $extension Optional. An extension to check if is loaded in PHP. 889 * string $constant Optional. A constant name to check for to verify an extension exists. 890 * string $class Optional. A class name to check for to verify an extension exists. 856 891 * bool $required Is this a required feature or not. 857 892 * string $fallback_for Optional. The module this module replaces as a fallback. 858 893 * } … … 863 898 $failures = array(); 864 899 865 900 foreach ( $modules as $library => $module ) { 866 $extension = ( isset( $module['extension'] ) ? $module['extension'] : null ); 867 $function = ( isset( $module['function'] ) ? $module['function'] : null ); 901 $extension = ( isset( $module['extension'] ) ? $module['extension'] : null ); 902 $function = ( isset( $module['function'] ) ? $module['function'] : null ); 903 $constant = ( isset( $module['constant'] ) ? $module['constant'] : null ); 904 $class_name = ( isset( $module['class'] ) ? $module['class'] : null ); 868 905 869 906 // If this module is a fallback for another function, check if that other function passed. 870 907 if ( isset( $module['fallback_for'] ) ) { … … 879 916 } 880 917 } 881 918 882 if ( ! $this->test_php_extension_availability( $extension, $function ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {919 if ( ! $this->test_php_extension_availability( $extension, $function, $constant, $class_name ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) { 883 920 if ( $module['required'] ) { 884 921 $result['status'] = 'critical'; 885 922