_preload_old_requests_classes_and_interfaces

The timeline below displays how wordpress function _preload_old_requests_classes_and_interfaces has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Preloads old Requests classes and interfaces.
 *
 * This function preloads the old Requests code into memory before the
 * upgrade process deletes the files. Why? Requests code is loaded into
 * memory via an autoloader, meaning when a class or interface is needed
 * If a request is in process, Requests could attempt to access code. If
 * the file is not there, a fatal error could occur. If the file was
 * replaced, the new code is not compatible with the old, resulting in
 * a fatal error. Preloading ensures the code is in memory before the
 * code is updated.
 *
 * @since 6.2.0
 *
 * @global array              $_old_requests_files Requests files to be preloaded.
 * @global WP_Filesystem_Base $wp_filesystem       WordPress filesystem subclass.
 * @global string             $wp_version          The WordPress version string.
 *
 * @param string $to Path to old WordPress installation.
 */
function _preload_old_requests_classes_and_interfaces($to)
{
    global $_old_requests_files, $wp_filesystem, $wp_version;
    /*
     * Requests was introduced in WordPress 4.6.
     *
     * Skip preloading if the website was previously using
     * an earlier version of WordPress.
     */
    if (version_compare($wp_version, '4.6', '<')) {
        return;
    }
    if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
        define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
    }
    foreach ($_old_requests_files as $name => $file) {
        // Skip files that aren't interfaces or classes.
        if (is_int($name)) {
            continue;
        }
        // Skip if it's already loaded.
        if (class_exists($name) || interface_exists($name)) {
            continue;
        }
        // Skip if the file is missing.
        if (!$wp_filesystem->is_file($to . $file)) {
            continue;
        }
        require_once $to . $file;
    }
}