mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-03 19:41:39 +00:00
General: Correct the fallback logic in apache_mod_loaded().
If the `apache_get_modules()` function is redeclared to return an empty array, `apache_mod_loaded()` would assume that no Apache modules are installed and activated, which may not be correct. This commit improves the logic by using pre-existing `phpinfo()` fallback to check for loaded modules in that case. Includes replacing a hardcoded number passed as a flag to `phpinfo()` with the `INFO_MODULES` predefined constant for clarity. Follow-up to [7441], [7508], [29330]. Props engahmeds3ed, audrasjb, Clorith, SergeyBiryukov. Fixes #56010. git-svn-id: https://develop.svn.wordpress.org/trunk@54299 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5888,15 +5888,24 @@ function apache_mod_loaded( $mod, $default = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$loaded_mods = array();
|
||||
|
||||
if ( function_exists( 'apache_get_modules' ) ) {
|
||||
$mods = apache_get_modules();
|
||||
if ( in_array( $mod, $mods, true ) ) {
|
||||
$loaded_mods = apache_get_modules();
|
||||
|
||||
if ( in_array( $mod, $loaded_mods, true ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
|
||||
ob_start();
|
||||
phpinfo( 8 );
|
||||
$phpinfo = ob_get_clean();
|
||||
}
|
||||
|
||||
if ( empty( $loaded_mods )
|
||||
&& function_exists( 'phpinfo' )
|
||||
&& false === strpos( ini_get( 'disable_functions' ), 'phpinfo' )
|
||||
) {
|
||||
ob_start();
|
||||
phpinfo( INFO_MODULES );
|
||||
$phpinfo = ob_get_clean();
|
||||
|
||||
if ( false !== strpos( $phpinfo, $mod ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user