<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57658] trunk: Plugin Dependencies: Remove auto-deactivation and bootstrapping logic.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57658">57658</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57658","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>costdev</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-20 07:25:38 +0000 (Tue, 20 Feb 2024)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Plugin Dependencies: Remove auto-deactivation and bootstrapping logic.

Automatic deactivation of dependents with unmet dependencies requires a write operation to the database. This was performed during Core's bootstrap, which risked the database and cache becoming out-of-sync on sites with heavy traffic.

No longer loading plugins that have unmet requirements has not had a final approach decided core-wide, and is still in discussion in <a href="https://core.trac.wordpress.org/ticket/60491">#60491</a> to be handled in a future release.

The `plugin_data` option, used to persistently store plugin data for detecting unmet dependencies during Core's bootstrap, is no longer needed.

Follow-up to <a href="https://core.trac.wordpress.org/changeset/57545">[57545]</a>, <a href="https://core.trac.wordpress.org/changeset/57592">[57592]</a>, <a href="https://core.trac.wordpress.org/changeset/57606">[57606]</a>, <a href="https://core.trac.wordpress.org/changeset/57617">[57617]</a>.

Props dd32, azaozz, swissspidy, desrosj, afragen, pbiron, zunaid321, costdev.
Fixes <a href="https://core.trac.wordpress.org/ticket/60457">#60457</a>. See <a href="https://core.trac.wordpress.org/ticket/60491">#60491</a>, <a href="https://core.trac.wordpress.org/ticket/60510">#60510</a>, <a href="https://core.trac.wordpress.org/ticket/60518">#60518</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasspluginupgraderphp">trunk/src/wp-admin/includes/class-plugin-upgrader.php</a></li>
<li><a href="#trunksrcwpadminincludesplugininstallphp">trunk/src/wp-admin/includes/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminincludespluginphp">trunk/src/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunksrcwpadminplugininstallphp">trunk/src/wp-admin/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminpluginsphp">trunk/src/wp-admin/plugins.php</a></li>
<li><a href="#trunksrcwpincludesclasswpplugindependenciesphp">trunk/src/wp-includes/class-wp-plugin-dependencies.php</a></li>
<li><a href="#trunksrcwpsettingsphp">trunk/src/wp-settings.php</a></li>
<li><a href="#trunktestsphpunittestsadminplugindependenciesbasephp">trunk/tests/phpunit/tests/admin/plugin-dependencies/base.php</a></li>
<li><a href="#trunktestsphpunittestsadminplugindependenciesgetDependencyFilepathphp">trunk/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php</a></li>
<li><a href="#trunktestsphpunittestsadminplugindependencieshasCircularDependencyphp">trunk/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php</a></li>
<li><a href="#trunktestsphpunittestsadminplugindependenciesinitializephp">trunk/tests/phpunit/tests/admin/plugin-dependencies/initialize.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasspluginupgraderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-plugin-upgrader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-plugin-upgrader.php     2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-admin/includes/class-plugin-upgrader.php       2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,12 +155,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // Force refresh of plugin update information.
</span><span class="cx" style="display: block; padding: 0 10px">                wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $all_plugin_data = get_option( 'plugin_data', array() );
-               $plugin_file     = $this->new_plugin_data['file'];
-               unset( $this->new_plugin_data['file'] );
-               $all_plugin_data[ $plugin_file ] = $this->new_plugin_data;
-               update_option( 'plugin_data', $all_plugin_data );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( $parsed_args['overwrite_package'] ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        /**
</span><span class="cx" style="display: block; padding: 0 10px">                         * Fires when the upgrader has successfully overwritten a currently installed
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -488,16 +482,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        foreach ( $files as $file ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $info = get_plugin_data( $file, false, false );
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( ! empty( $info['Name'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        $basename = basename( $file );
-                                       $dirname  = basename( dirname( $file ) );
-
-                                       if ( '.' === $dirname ) {
-                                               $plugin_file = $basename;
-                                       } else {
-                                               $plugin_file = "$dirname/$basename";
-                                       }
-                                       $this->new_plugin_data         = ( $info );
-                                       $this->new_plugin_data['file'] = $plugin_file;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 $this->new_plugin_data = $info;
</ins><span class="cx" style="display: block; padding: 0 10px">                                         break;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span></span></pre></div>
<a id="trunksrcwpadminincludesplugininstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin-install.php    2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-admin/includes/plugin-install.php      2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -927,7 +927,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Determine the status of plugin dependencies.
</span><span class="cx" style="display: block; padding: 0 10px">        $installed_plugins                   = get_plugins();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $active_plugins                      = get_option( 'active_plugins' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $active_plugins                      = get_option( 'active_plugins', array() );
</ins><span class="cx" style="display: block; padding: 0 10px">         $plugin_dependencies_count           = count( $requires_plugins );
</span><span class="cx" style="display: block; padding: 0 10px">        $installed_plugin_dependencies_count = 0;
</span><span class="cx" style="display: block; padding: 0 10px">        $active_plugin_dependencies_count    = 0;
</span></span></pre></div>
<a id="trunksrcwpadminincludespluginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin.php    2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-admin/includes/plugin.php      2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -333,7 +333,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return $wp_plugins;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $new_plugin_data = array();
</del><span class="cx" style="display: block; padding: 0 10px">         foreach ( $plugin_files as $plugin_file ) {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! is_readable( "$plugin_root/$plugin_file" ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -346,13 +345,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        continue;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $new_plugin_file = str_replace(
-                       trailingslashit( WP_PLUGIN_DIR ),
-                       '',
-                       "$plugin_root/$plugin_file"
-               );
-
-               $new_plugin_data[ $new_plugin_file ]           = $plugin_data;
</del><span class="cx" style="display: block; padding: 0 10px">                 $wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,10 +353,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $cache_plugins[ $plugin_folder ] = $wp_plugins;
</span><span class="cx" style="display: block; padding: 0 10px">        wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! wp_installing() ) {
-               update_option( 'plugin_data', $new_plugin_data );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         return $wp_plugins;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -975,7 +963,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $plugins_dir = trailingslashit( $plugins_dir );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $plugin_translations = wp_get_installed_translations( 'plugins' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $all_plugin_data     = get_option( 'plugin_data', array() );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $errors = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1020,7 +1007,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $errors[] = $plugin_file;
</span><span class="cx" style="display: block; padding: 0 10px">                        continue;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                unset( $all_plugin_data[ $plugin_file ] );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $plugin_slug = dirname( $plugin_file );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1069,7 +1055,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        update_option( 'plugin_data', $all_plugin_data );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1214,6 +1199,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        WP_Plugin_Dependencies::initialize();
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( WP_Plugin_Dependencies::has_unmet_dependencies( $plugin ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $dependencies       = WP_Plugin_Dependencies::get_dependencies( $plugin );
</span><span class="cx" style="display: block; padding: 0 10px">                $unmet_dependencies = array();
</span></span></pre></div>
<a id="trunksrcwpadminplugininstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugin-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugin-install.php     2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-admin/plugin-install.php       2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,8 +135,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/admin-header.php';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+WP_Plugin_Dependencies::initialize();
</ins><span class="cx" style="display: block; padding: 0 10px"> WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-WP_Plugin_Dependencies::display_admin_notice_for_deactivated_dependents();
</del><span class="cx" style="display: block; padding: 0 10px"> WP_Plugin_Dependencies::display_admin_notice_for_circular_dependencies();
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>">
</span></span></pre></div>
<a id="trunksrcwpadminpluginsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugins.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugins.php    2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-admin/plugins.php      2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,6 +40,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'updates' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+WP_Plugin_Dependencies::initialize();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $action ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        switch ( $action ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -741,7 +743,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> <?php WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies(); ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php WP_Plugin_Dependencies::display_admin_notice_for_deactivated_dependents(); ?>
</del><span class="cx" style="display: block; padding: 0 10px"> <?php WP_Plugin_Dependencies::display_admin_notice_for_circular_dependencies(); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="wrap">
</span><span class="cx" style="display: block; padding: 0 10px"> <h1 class="wp-heading-inline">
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpplugindependenciesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-plugin-dependencies.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-plugin-dependencies.php    2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-includes/class-wp-plugin-dependencies.php      2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,15 +105,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">        protected static $circular_dependencies_slugs;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Initializes by fetching plugin header and plugin API data,
-        * and deactivating dependents with unmet dependencies.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Whether Plugin Dependencies have been initialized.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         *
+        * @var bool
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        protected static $initialized = false;
+
+       /**
+        * Initializes by fetching plugin header and plugin API data.
+        *
+        * @since 6.5.0
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         public static function initialize() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                self::read_dependencies_from_plugin_headers();
-               self::get_dependency_api_data();
-               self::deactivate_dependents_with_unmet_dependencies();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( false === self::$initialized ) {
+                       self::read_dependencies_from_plugin_headers();
+                       self::get_dependency_api_data();
+                       self::$initialized = true;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,7 +135,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @return bool Whether the plugin has plugins that depend on it.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public static function has_dependents( $plugin_file ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                return in_array( self::convert_to_slug( $plugin_file ), self::$dependency_slugs, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return in_array( self::convert_to_slug( $plugin_file ), (array) self::$dependency_slugs, true );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,7 +182,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public static function get_dependents( $slug ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $dependents = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                foreach ( self::$dependencies as $dependent => $dependencies ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         foreach ( (array) self::$dependencies as $dependent => $dependencies ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         if ( in_array( $slug, $dependencies, true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $dependents[] = $dependent;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -369,36 +379,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Displays an admin notice if dependencies have been deactivated.
-        *
-        * @since 6.5.0
-        */
-       public static function display_admin_notice_for_deactivated_dependents() {
-               /*
-                * Plugin deactivated if dependencies not met.
-                * Transient on a 10 second timeout.
-                */
-               $deactivate_requires = get_site_transient( 'wp_plugin_dependencies_deactivated_plugins' );
-               if ( ! empty( $deactivate_requires ) ) {
-                       $deactivated_plugins = '';
-                       foreach ( $deactivate_requires as $deactivated ) {
-                               $deactivated_plugins .= '<li>' . esc_html( self::$plugins[ $deactivated ]['Name'] ) . '</li>';
-                       }
-                       wp_admin_notice(
-                               sprintf(
-                                       /* translators: 1: plugin names */
-                                       __( 'The following plugin(s) have been deactivated due to uninstalled or inactive dependencies: %s' ),
-                                       "<ul>$deactivated_plugins</ul>"
-                               ),
-                               array(
-                                       'type'        => 'error',
-                                       'dismissible' => true,
-                               )
-                       );
-               }
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * Displays an admin notice if circular dependencies are installed.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 6.5.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -543,15 +523,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return self::$plugins;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $all_plugin_data = get_option( 'plugin_data', array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         require_once ABSPATH . '/wp-admin/includes/plugin.php';
+               self::$plugins = get_plugins();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( empty( $all_plugin_data ) ) {
-                       require_once ABSPATH . '/wp-admin/includes/plugin.php';
-                       $all_plugin_data = get_plugins();
-               }
-
-               self::$plugins = $all_plugin_data;
-
</del><span class="cx" style="display: block; padding: 0 10px">                 return self::$plugins;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -621,83 +595,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Gets plugin filepaths for active plugins that depend on the dependency.
-        *
-        * Recurses for each dependent that is also a dependency.
-        *
-        * @param string $plugin_file The dependency's filepath, relative to the plugin directory.
-        * @return string[] An array of active dependent plugin filepaths, relative to the plugin directory.
-        */
-       protected static function get_active_dependents_in_dependency_tree( $plugin_file ) {
-               $all_dependents = array();
-               $dependents     = self::get_dependents( self::convert_to_slug( $plugin_file ) );
-
-               if ( empty( $dependents ) ) {
-                       return $all_dependents;
-               }
-
-               require_once ABSPATH . '/wp-admin/includes/plugin.php';
-               foreach ( $dependents as $dependent ) {
-                       if ( is_plugin_active( $dependent ) ) {
-                               $all_dependents[] = $dependent;
-                               $all_dependents   = array_merge(
-                                       $all_dependents,
-                                       self::get_active_dependents_in_dependency_tree( $dependent )
-                               );
-                       }
-               }
-
-               return $all_dependents;
-       }
-
-       /**
-        * Deactivates dependent plugins with unmet dependencies.
-        *
-        * @since 6.5.0
-        */
-       protected static function deactivate_dependents_with_unmet_dependencies() {
-               $dependents_to_deactivate = array();
-               $circular_dependencies    = array_reduce(
-                       self::get_circular_dependencies(),
-                       function ( $all_circular, $circular_pair ) {
-                               return array_merge( $all_circular, $circular_pair );
-                       },
-                       array()
-               );
-
-               require_once ABSPATH . '/wp-admin/includes/plugin.php';
-               foreach ( self::$dependencies as $dependent => $dependencies ) {
-                       // Skip dependents that are no longer installed or aren't active.
-                       if ( ! array_key_exists( $dependent, self::$plugins ) || is_plugin_inactive( $dependent ) ) {
-                               continue;
-                       }
-
-                       // Skip plugins within a circular dependency tree or plugins that have no unmet dependencies.
-                       if ( in_array( $dependent, $circular_dependencies, true ) || ! self::has_unmet_dependencies( $dependent ) ) {
-                               continue;
-                       }
-
-                       $dependents_to_deactivate[] = $dependent;
-
-                       // Also add any plugins that rely on any of this plugin's dependents.
-                       $dependents_to_deactivate = array_merge(
-                               $dependents_to_deactivate,
-                               self::get_active_dependents_in_dependency_tree( $dependent )
-                       );
-               }
-
-               // Bail early if there are no dependents to deactivate.
-               if ( empty( $dependents_to_deactivate ) ) {
-                       return;
-               }
-
-               $dependents_to_deactivate = array_unique( $dependents_to_deactivate );
-
-               deactivate_plugins( $dependents_to_deactivate );
-               set_site_transient( 'wp_plugin_dependencies_deactivated_plugins', $dependents_to_deactivate, 10 );
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * Gets the filepath of installed dependencies.
</span><span class="cx" style="display: block; padding: 0 10px">         * If a dependency is not installed, the filepath defaults to false.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -710,6 +607,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return self::$dependency_filepaths;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( null === self::$dependency_slugs ) {
+                       return array();
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 self::$dependency_filepaths = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $plugin_dirnames = self::get_plugin_dirnames();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -846,6 +747,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return self::$circular_dependencies_pairs;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( null === self::$dependencies ) {
+                       return array();
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 self::$circular_dependencies_slugs = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                self::$circular_dependencies_pairs = array();
</span></span></pre></div>
<a id="trunksrcwpsettingsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-settings.php 2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/src/wp-settings.php   2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -388,6 +388,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/interactivity-api/class-wp-interactivity-api.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/interactivity-api/class-wp-interactivity-api-directives-processor.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/interactivity-api/interactivity-api.php';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require ABSPATH . WPINC . '/class-wp-plugin-dependencies.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_modules()->add_hooks();
</span><span class="cx" style="display: block; padding: 0 10px"> wp_interactivity()->add_hooks();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -419,12 +420,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_plugin_paths'] = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// Load and initialize WP_Plugin_Dependencies.
-require_once ABSPATH . WPINC . '/class-wp-plugin-dependencies.php';
-if ( ! defined( 'WP_RUN_CORE_TESTS' ) ) {
-       WP_Plugin_Dependencies::initialize();
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Load must-use plugins.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( wp_get_mu_plugins() as $mu_plugin ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $_wp_plugin_file = $mu_plugin;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -499,85 +494,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Load active plugins.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$all_plugin_data    = get_option( 'plugin_data', array() );
-$failed_plugins     = array();
-$plugins_dir_strlen = strlen( trailingslashit( WP_PLUGIN_DIR ) );
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $plugin_file = substr( $plugin, $plugins_dir_strlen );
-
-       /*
-        * Skip any plugins that have not been added to the 'plugin_data' option yet.
-        *
-        * Some plugin files may be added locally and activated, but will not yet be
-        * added to the 'plugin_data' option. This causes the 'active_plugins' option
-        * and the 'plugin_data' option to be temporarily out of sync until the next
-        * call to `get_plugins()`.
-        */
-       if ( isset( $all_plugin_data[ $plugin_file ] ) ) {
-               $plugin_headers = $all_plugin_data[ $plugin_file ];
-               $errors         = array();
-               $requirements   = array(
-                       'requires'     => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '',
-                       'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
-               );
-               $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
-               $compatible_php = is_php_version_compatible( $requirements['requires_php'] );
-
-               $php_update_message = '</p><p>' . sprintf(
-                       /* translators: %s: URL to Update PHP page. */
-                       __( '<a href="%s">Learn more about updating PHP</a>.' ),
-                       esc_url( wp_get_update_php_url() )
-               );
-
-               $annotation = wp_get_update_php_annotation();
-
-               if ( $annotation ) {
-                       $php_update_message .= '</p><p><em>' . $annotation . '</em>';
-               }
-
-               if ( ! $compatible_wp && ! $compatible_php ) {
-                       $errors[] = sprintf(
-                               /* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
-                               _x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
-                               get_bloginfo( 'version' ),
-                               PHP_VERSION,
-                               $plugin_headers['Name'],
-                               $requirements['requires'],
-                               $requirements['requires_php']
-                       ) . $php_update_message;
-               } elseif ( ! $compatible_php ) {
-                       $errors[] = sprintf(
-                               /* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
-                               _x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
-                               PHP_VERSION,
-                               $plugin_headers['Name'],
-                               $requirements['requires_php']
-                       ) . $php_update_message;
-               } elseif ( ! $compatible_wp ) {
-                       $errors[] = sprintf(
-                               /* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */
-                               _x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ),
-                               get_bloginfo( 'version' ),
-                               $plugin_headers['Name'],
-                               $requirements['requires']
-                       );
-               }
-
-               if ( ! empty( $errors ) ) {
-                       $failed_plugins[ $plugin_file ] = '';
-                       foreach ( $errors as $error ) {
-                               $failed_plugins[ $plugin_file ] .= wp_get_admin_notice(
-                                       $error,
-                                       array(
-                                               'type'        => 'error',
-                                               'dismissible' => true,
-                                       )
-                               );
-                       }
-                       continue;
-               }
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         wp_register_plugin_realpath( $plugin );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $_wp_plugin_file = $plugin;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -595,20 +512,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $plugin, $_wp_plugin_file );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if ( ! empty( $failed_plugins ) ) {
-       add_action(
-               'admin_notices',
-               function () use ( $failed_plugins ) {
-                       global $pagenow;
-
-                       if ( 'index.php' === $pagenow || 'plugins.php' === $pagenow ) {
-                               echo implode( '', $failed_plugins );
-                       }
-               }
-       );
-}
-unset( $failed_plugins );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Load pluggable functions.
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/pluggable.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/pluggable-deprecated.php';
</span></span></pre></div>
<a id="trunktestsphpunittestsadminplugindependenciesbasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/admin/plugin-dependencies/base.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/plugin-dependencies/base.php      2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/tests/phpunit/tests/admin/plugin-dependencies/base.php        2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,6 +32,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'dependency_filepaths'        => null,
</span><span class="cx" style="display: block; padding: 0 10px">                'circular_dependencies_pairs' => null,
</span><span class="cx" style="display: block; padding: 0 10px">                'circular_dependencies_slugs' => null,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                'initialized'                 => false,
</ins><span class="cx" style="display: block; padding: 0 10px">         );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,12 +63,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Resets all static properties to a default value after each test.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function set_up() {
-               parent::set_up();
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function tear_down() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 foreach ( self::$static_properties as $name => $default_value ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->set_property_value( $name, $default_value );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               parent::tear_down();
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span></span></pre></div>
<a id="trunktestsphpunittestsadminplugindependenciesgetDependencyFilepathphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php     2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php       2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,6 +18,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Admin_WPPluginDependencies_GetDependencyFilepath extends WP_PluginDependencies_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tests that false is returned if Plugin Dependencies has not been initialized.
+        *
+        * @ticket 60457
+        */
+       public function test_should_return_false_before_initialization() {
+               // Ensure Plugin Dependencies has not been initialized.
+               $this->assertFalse(
+                       $this->get_property_value( 'initialized' ),
+                       'Plugin Dependencies has been initialized.'
+               );
+
+               $this->assertSame(
+                       self::$static_properties['dependency_slugs'],
+                       $this->get_property_value( 'dependency_slugs' ),
+                       '"dependency_slugs" was not set to its default value.'
+               );
+
+               $this->assertFalse(
+                       self::$instance->get_dependency_filepath( 'dependency' ),
+                       'false was not returned before initialization.'
+               );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Tests that the expected dependency filepaths are retrieved for installed dependencies.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 22316
</span></span></pre></div>
<a id="trunktestsphpunittestsadminplugindependencieshasCircularDependencyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php     2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php       2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,6 +18,44 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Admin_WPPluginDependencies_HasCircularDependency extends WP_PluginDependencies_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tests that false is returned if Plugin Dependencies has not been initialized.
+        *
+        * @ticket 60457
+        */
+       public function test_should_return_false_before_initialization() {
+               $this->set_property_value(
+                       'plugins',
+                       array(
+                               'dependent/dependent.php'   => array(
+                                       'Name'            => 'Dependent',
+                                       'RequiresPlugins' => 'dependency',
+                               ),
+                               'dependency/dependency.php' => array(
+                                       'Name'            => 'Dependency',
+                                       'RequiresPlugins' => 'dependent',
+                               ),
+                       )
+               );
+
+               // Ensure Plugin Dependencies has not been initialized.
+               $this->assertFalse(
+                       $this->get_property_value( 'initialized' ),
+                       'Plugin Dependencies has been initialized.'
+               );
+
+               $this->assertSame(
+                       self::$static_properties['circular_dependencies_slugs'],
+                       $this->get_property_value( 'circular_dependencies_slugs' ),
+                       '"circular_dependencies_slugs" was not set to its default value.'
+               );
+
+               $this->assertFalse(
+                       self::$instance->has_circular_dependency( 'dependency' ),
+                       'false was not returned before initialization.'
+               );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Tests that a plugin with a circular dependency will return true.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 22316
</span></span></pre></div>
<a id="trunktestsphpunittestsadminplugindependenciesinitializephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/admin/plugin-dependencies/initialize.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/plugin-dependencies/initialize.php        2024-02-20 07:09:43 UTC (rev 57657)
+++ trunk/tests/phpunit/tests/admin/plugin-dependencies/initialize.php  2024-02-20 07:25:38 UTC (rev 57658)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,6 +16,68 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Admin_WPPluginDependencies_Initialize extends WP_PluginDependencies_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Tests that initialization runs only once.
+        *
+        * @ticket 60457
+        *
+        * @dataProvider data_static_properties_set_during_initialization
+        *
+        * @param string $property_name The name of the property to check.
+        */
+       public function test_should_only_initialize_once( $property_name ) {
+               $this->assertFalse(
+                       $this->get_property_value( 'initialized' ),
+                       'Plugin Dependencies has already been initialized.'
+               );
+
+               self::$instance->initialize();
+
+               $this->assertTrue(
+                       $this->get_property_value( 'initialized' ),
+                       '"initialized" was not set to true during initialization.'
+               );
+
+               $default_value = self::$static_properties[ $property_name ];
+
+               $this->assertNotSame(
+                       $default_value,
+                       $this->get_property_value( $property_name ),
+                       "\"{$property_name}\" was not set during initialization."
+               );
+
+               // Reset it to its default.
+               $this->set_property_value( $property_name, self::$static_properties[ $property_name ] );
+
+               self::$instance->initialize();
+
+               $this->assertSame(
+                       $default_value,
+                       $this->get_property_value( $property_name ),
+                       "\"{$property_name}\" was set during the second initialization attempt."
+               );
+       }
+
+       /**
+        * Data provider.
+        *
+        * @return array[]
+        */
+       public function data_static_properties_set_during_initialization() {
+               /*
+                * This does not include 'dependency_api_data' as it is only set
+                * on certain pages. This is tested later.
+                */
+               return self::text_array_to_dataprovider(
+                       array(
+                               'plugins',
+                               'dependencies',
+                               'dependency_slugs',
+                               'dependent_slugs',
+                       )
+               );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Tests that `$dependency_api_data` is set on certain screens.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 22316
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -238,99 +300,4 @@
</span><span class="cx" style="display: block; padding: 0 10px">                self::$instance->initialize();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( $expected_slugs, $this->get_property_value( 'dependent_slugs' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       /**
-        * Tests that dependents with unmet dependencies are deactivated.
-        *
-        * @ticket 22316
-        *
-        * @covers WP_Plugin_Dependencies::deactivate_dependents_with_unmet_dependencies
-        * @covers WP_Plugin_Dependencies::has_unmet_dependencies
-        * @covers WP_Plugin_Dependencies::get_active_dependents_in_dependency_tree
-        *
-        * @dataProvider data_should_only_deactivate_dependents_with_unmet_dependencies
-        *
-        * @param array $active_plugins An array of active plugin paths.
-        * @param array $plugins        An array of installed plugins.
-        * @param array $expected       The expected value of 'active_plugins' after initialization.
-        */
-       public function test_should_deactivate_dependents_with_uninstalled_dependencies( $active_plugins, $plugins, $expected ) {
-               update_option( 'active_plugins', $active_plugins );
-
-               $this->set_property_value( 'plugins', $plugins );
-               self::$instance::initialize();
-
-               $this->assertSame( $expected, array_values( get_option( 'active_plugins', array() ) ) );
-       }
-
-       /**
-        * Data provider.
-        *
-        * @return array[]
-        */
-       public function data_should_only_deactivate_dependents_with_unmet_dependencies() {
-               return array(
-                       'a dependent with an uninstalled dependency' => array(
-                               'active_plugins' => array( 'dependent/dependent.php' ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php' => array( 'RequiresPlugins' => 'dependency' ),
-                               ),
-                               'expected'       => array(),
-                       ),
-                       'a dependent with an inactive dependency'    => array(
-                               'active_plugins' => array( 'dependent/dependent.php' ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php'   => array( 'RequiresPlugins' => 'dependency' ),
-                                       'dependency/dependency.php' => array( 'RequiresPlugins' => '' ),
-                               ),
-                               'expected'       => array(),
-                       ),
-                       'a dependent with two dependencies, one uninstalled, one inactive' => array(
-                               'active_plugins' => array( 'dependent/dependent.php' ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php'     => array( 'RequiresPlugins' => 'dependency, dependency2' ),
-                                       'dependency2/dependency2.php' => array( 'RequiresPlugins' => '' ),
-                               ),
-                               'expected'       => array(),
-                       ),
-                       'a dependent with a dependency that is installed and active' => array(
-                               'active_plugins' => array( 'dependent/dependent.php', 'dependency/dependency.php' ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php'   => array( 'RequiresPlugins' => 'dependency' ),
-                                       'dependency/dependency.php' => array( 'RequiresPlugins' => '' ),
-                               ),
-                               'expected'       => array( 'dependent/dependent.php', 'dependency/dependency.php' ),
-                       ),
-                       'one dependent with two dependencies that are installed and active' => array(
-                               'active_plugins' => array(
-                                       'dependent/dependent.php',
-                                       'dependency/dependency.php',
-                                       'dependency2/dependency2.php',
-                               ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php'     => array( 'RequiresPlugins' => 'dependency, dependency2' ),
-                                       'dependency/dependency.php'   => array( 'RequiresPlugins' => '' ),
-                                       'dependency2/dependency2.php' => array( 'RequiresPlugins' => '' ),
-                               ),
-                               'expected'       => array(
-                                       'dependent/dependent.php',
-                                       'dependency/dependency.php',
-                                       'dependency2/dependency2.php',
-                               ),
-                       ),
-                       'two dependents, one with an uninstalled dependency, and one with an active dependency' => array(
-                               'active_plugins' => array(
-                                       'dependent/dependent.php',
-                                       'dependent2/dependent2.php',
-                                       'dependency2/dependency2.php',
-                               ),
-                               'plugins'        => array(
-                                       'dependent/dependent.php'     => array( 'RequiresPlugins' => 'dependency' ),
-                                       'dependent2/dependent2.php'   => array( 'RequiresPlugins' => 'dependency2' ),
-                                       'dependency2/dependency2.php' => array( 'RequiresPlugins' => '' ),
-                               ),
-                               'expected'       => array( 'dependent2/dependent2.php', 'dependency2/dependency2.php' ),
-                       ),
-               );
-       }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>