PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.0
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / autoloader.php
wp-staging Last commit date
Backend 1 week ago Backup 1 week ago Basic 1 week ago Component 1 week ago Core 1 week ago Framework 1 week ago Frontend 5 months ago Notifications 8 months ago Staging 1 week ago assets 1 week ago languages 1 week ago resources 1 year ago vendor_wpstg 1 week ago views 1 week ago CONTRIBUTING.md 1 year ago Deactivate.php 8 months ago README.md 3 months ago SECURITY.md 2 years ago autoloader.php 1 month ago bootstrap.php 1 month ago commonBootstrap.php 1 week ago constantsFree.php 1 week ago freeBootstrap.php 1 month ago install.php 1 week ago opcacheBootstrap.php 1 week ago readme.txt 1 week ago runtimeRequirements.php 3 months ago uninstall.php 1 week ago wp-staging-error-handler.php 6 months ago wp-staging.php 1 week ago
autoloader.php
65 lines
1 <?php
2
3 // Register the autoloader for the plugin source code, and for the prefixed vendors.
4 //
5 // Defensive guards against missing/corrupted vendor_wpstg files (issue #5074):
6 // without these, a missing autoload map would make `include_once` return false,
7 // `array_merge(array, false)` would throw a TypeError on PHP 8+, and the entire
8 // WordPress site would crash. Bail early instead so bootstrap.php can detect the
9 // failed autoloader via class_exists() and show an admin notice.
10 //
11 // is_readable() (rather than file_exists()) covers the "file present but
12 // unreadable" case — security scanners chmod'ing vendor files to 000 is one
13 // of the real-world triggers — and avoids include_once emitting an E_WARNING
14 // that would leak to the page output when WP_DEBUG_DISPLAY is on.
15 $wpstgSrcMapFile = __DIR__ . '/vendor_wpstg/autoload/src.php';
16 $wpstgVendorMapFile = __DIR__ . '/vendor_wpstg/autoload/vendor.php';
17 $wpstgFilesMapFile = __DIR__ . '/vendor_wpstg/autoload/files.php';
18
19 if (
20 !is_readable($wpstgSrcMapFile)
21 || !is_readable($wpstgVendorMapFile)
22 || !is_readable($wpstgFilesMapFile)
23 ) {
24 return;
25 }
26
27 // Validate ALL three maps (including files.php) before registering the
28 // autoloader. If files.php is corrupted, we must bail before
29 // spl_autoload_register so bootstrap.php's class_exists() guard sees an
30 // unregistered autoloader and surfaces the admin notice — otherwise the
31 // plugin would continue booting in a half-broken state without composer's
32 // file-based autoloads.
33 $wpstgSrcMap = include_once $wpstgSrcMapFile;
34 $wpstgVendorMap = include_once $wpstgVendorMapFile;
35 $wpstgFilesToInclude = include_once $wpstgFilesMapFile;
36
37 if (
38 !is_array($wpstgSrcMap)
39 || !is_array($wpstgVendorMap)
40 || !is_array($wpstgFilesToInclude)
41 ) {
42 return;
43 }
44
45 $class_map = array_merge($wpstgSrcMap, $wpstgVendorMap);
46
47 spl_autoload_register(
48 // @phpstan-ignore-next-line - Autoloader return value preserved for compatibility
49 function (string $class) use ($class_map) {
50 if (isset($class_map[$class]) && file_exists($class_map[$class])) {
51 include_once $class_map[$class];
52
53 return true;
54 }
55 },
56 true,
57 true
58 );
59
60 foreach ($wpstgFilesToInclude as $file) {
61 if (is_readable($file)) {
62 require $file;
63 }
64 }
65