PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.10.1
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.10.1
9.5.11 9.5.10.1 9.5.10 trunk 9.4.0 9.4.1 9.4.2 9.4.3 9.5.0 9.5.0.1 9.5.0.2 9.5.1 9.5.2 9.5.2.2 9.5.2.3 9.5.3 9.5.3.1 9.5.3.2 9.5.4 9.5.5 9.5.6 9.5.7 9.5.8 9.5.9
really-simple-ssl / core / vendor / jetpack-autoloader / class-shutdown-handler.php
really-simple-ssl / core / vendor / jetpack-autoloader Last commit date
class-autoloader-handler.php 1 month ago class-autoloader-locator.php 1 month ago class-autoloader.php 1 month ago class-container.php 1 month ago class-hook-manager.php 1 month ago class-latest-autoloader-guard.php 1 month ago class-manifest-reader.php 1 month ago class-path-processor.php 1 month ago class-php-autoloader.php 1 month ago class-plugin-locator.php 1 month ago class-plugins-handler.php 1 month ago class-shutdown-handler.php 1 month ago class-version-loader.php 1 month ago class-version-selector.php 1 month ago
class-shutdown-handler.php
93 lines
1 <?php
2 /**
3 * This file was automatically generated by automattic/jetpack-autoloader.
4 *
5 * @package automattic/jetpack-autoloader
6 */
7
8 namespace Automattic\Jetpack\Autoloader\jpb362f03b12b29b02131a59d9d1231943\al5_0_15;
9
10 // phpcs:ignore
11
12 /**
13 * This class handles the shutdown of the autoloader.
14 */
15 class Shutdown_Handler {
16
17 /**
18 * The Plugins_Handler instance.
19 *
20 * @var Plugins_Handler
21 */
22 private $plugins_handler;
23
24 /**
25 * The plugins cached by this autoloader.
26 *
27 * @var string[]
28 */
29 private $cached_plugins;
30
31 /**
32 * Indicates whether or not this autoloader was included by another.
33 *
34 * @var bool
35 */
36 private $was_included_by_autoloader;
37
38 /**
39 * Constructor.
40 *
41 * @param Plugins_Handler $plugins_handler The Plugins_Handler instance to use.
42 * @param string[] $cached_plugins The plugins cached by the autoloaer.
43 * @param bool $was_included_by_autoloader Indicates whether or not the autoloader was included by another.
44 */
45 public function __construct( $plugins_handler, $cached_plugins, $was_included_by_autoloader ) {
46 $this->plugins_handler = $plugins_handler;
47 $this->cached_plugins = $cached_plugins;
48 $this->was_included_by_autoloader = $was_included_by_autoloader;
49 }
50
51 /**
52 * Handles the shutdown of the autoloader.
53 */
54 public function __invoke() {
55 // Don't save a broken cache if an error happens during some plugin's initialization.
56 if ( ! did_action( 'plugins_loaded' ) ) {
57 // Ensure that the cache is emptied to prevent consecutive failures if the cache is to blame.
58 if ( ! empty( $this->cached_plugins ) ) {
59 $this->plugins_handler->cache_plugins( array() );
60 }
61
62 return;
63 }
64
65 // Load the active plugins fresh since the list we pulled earlier might not contain
66 // plugins that were activated but did not reset the autoloader. This happens
67 // when a plugin is in the cache but not "active" when the autoloader loads.
68 // We also want to make sure that plugins which are deactivating are not
69 // considered "active" so that they will be removed from the cache now.
70 try {
71 $active_plugins = $this->plugins_handler->get_active_plugins( false, ! $this->was_included_by_autoloader );
72 } catch ( \Exception $ex ) {
73 // When the package is deleted before shutdown it will throw an exception.
74 // In the event this happens we should erase the cache.
75 if ( ! empty( $this->cached_plugins ) ) {
76 $this->plugins_handler->cache_plugins( array() );
77 }
78 return;
79 }
80
81 // The paths should be sorted for easy comparisons with those loaded from the cache.
82 // Note we don't need to sort the cached entries because they're already sorted.
83 sort( $active_plugins );
84
85 // We don't want to waste time saving a cache that hasn't changed.
86 if ( $this->cached_plugins === $active_plugins ) {
87 return;
88 }
89
90 $this->plugins_handler->cache_plugins( $active_plugins );
91 }
92 }
93