Make WordPress Core


Ignore:
Timestamp:
09/24/2022 01:51:22 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r54292 r54299  
    58895889    }
    58905890
     5891    $loaded_mods = array();
     5892
    58915893    if ( function_exists( 'apache_get_modules' ) ) {
    5892         $mods = apache_get_modules();
    5893         if ( in_array( $mod, $mods, true ) ) {
     5894        $loaded_mods = apache_get_modules();
     5895
     5896        if ( in_array( $mod, $loaded_mods, true ) ) {
    58945897            return true;
    58955898        }
    5896     } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
    5897             ob_start();
    5898             phpinfo( 8 );
    5899             $phpinfo = ob_get_clean();
     5899    }
     5900
     5901    if ( empty( $loaded_mods )
     5902        && function_exists( 'phpinfo' )
     5903        && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' )
     5904    ) {
     5905        ob_start();
     5906        phpinfo( INFO_MODULES );
     5907        $phpinfo = ob_get_clean();
     5908
    59005909        if ( false !== strpos( $phpinfo, $mod ) ) {
    59015910            return true;
Note: See TracChangeset for help on using the changeset viewer.