wpseek.com
A WordPress-centric search engine for devs and theme authors



_preload_old_requests_classes_and_interfaces › WordPress Function

Since6.2.0
Deprecatedn/a
_preload_old_requests_classes_and_interfaces ( $to )
Parameters:
  • (string) $to Path to old WordPress installation.
    Required: Yes
Defined at:
Codex:

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.


Source

function _preload_old_requests_classes_and_interfaces( $to ) {
	global $_old_requests_files, $wp_filesystem;

	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;
	}
}