<!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>[45220] trunk/src: Site health, info tab:</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/45220">45220</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/45220","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-04-16 23:01:45 +0000 (Tue, 16 Apr 2019)</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'>Site health, info tab:
- Change `recurse_dirsize()` to accept an array of excluded paths.
- Change so we don't calculate the sizes of dirs in wp-content twice.
- Add the size in bytes to the "debug" into.
- Add a custom DOM event after the dir sizes request is done. Can be used by plugins to "daisy chain" more requests.
- Move "WordPress directory location" and "WordPress directory size" to the top in the "Directories and Sizes" section.
- Move "Theme directory location" to the "Active Theme" section.
- Fix labels capitalization.

Props xkon, afercia, Clorith, azaozz.
Fixes <a href="https://core.trac.wordpress.org/ticket/46707">#46707</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcjs_enqueuesadminsitehealthjs">trunk/src/js/_enqueues/admin/site-health.js</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpdebugdataphp">trunk/src/wp-admin/includes/class-wp-debug-data.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjs_enqueuesadminsitehealthjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/js/_enqueues/admin/site-health.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/admin/site-health.js       2019-04-16 20:29:42 UTC (rev 45219)
+++ trunk/src/js/_enqueues/admin/site-health.js 2019-04-16 23:01:45 UTC (rev 45220)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,6 +276,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Cancel the announcement.
</span><span class="cx" style="display: block; padding: 0 10px">                                window.clearTimeout( timeout );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       $( document ).trigger( 'site-health-info-dirsizes-done' );
</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="trunksrcwpadminincludesajaxactionsphp"></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/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php      2019-04-16 20:29:42 UTC (rev 45219)
+++ trunk/src/wp-admin/includes/ajax-actions.php        2019-04-16 23:01:45 UTC (rev 45220)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4976,7 +4976,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">        $sizes_data = WP_Debug_Data::get_sizes();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $all_sizes  = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $all_sizes  = array( 'raw' => 0 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( $sizes_data as $name => $value ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $name = sanitize_text_field( $name );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4998,6 +4998,10 @@
</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">+                if ( ! empty( $value['raw'] ) ) {
+                       $data['raw'] = (int) $value['raw'];
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $all_sizes[ $name ] = $data;
</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="trunksrcwpadminincludesclasswpdebugdataphp"></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-wp-debug-data.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-debug-data.php       2019-04-16 20:29:42 UTC (rev 45219)
+++ trunk/src/wp-admin/includes/class-wp-debug-data.php 2019-04-16 23:01:45 UTC (rev 45220)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -392,46 +392,42 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $not_calculated = __( 'Not calculated' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $info['wp-paths-sizes']['fields'] = array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'wordpress_path'     => array(
+                               'label' => __( 'WordPress directory location' ),
+                               'value' => untrailingslashit( ABSPATH ),
+                       ),
+                       'wordpress_size'     => array(
+                               'label' => __( 'WordPress directory size' ),
+                               'value' => $not_calculated,
+                               'debug' => 'not calculated',
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                         'uploads_path'       => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Uploads Directory Location' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Uploads directory location' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'value' => $upload_dir['basedir'],
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'uploads_size'       => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Uploads Directory Size' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Uploads directory size' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'value' => $not_calculated,
</span><span class="cx" style="display: block; padding: 0 10px">                                'debug' => 'not calculated',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'themes_path'        => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Themes Directory Location' ),
-                               'value' => trailingslashit( get_theme_root() ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Themes directory location' ),
+                               'value' => get_theme_root(),
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'current_theme_path' => array(
-                               'label' => __( 'Current Theme Directory' ),
-                               'value' => get_template_directory(),
-                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                         'themes_size'        => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Themes Directory Size' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Themes directory size' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'value' => $not_calculated,
</span><span class="cx" style="display: block; padding: 0 10px">                                'debug' => 'not calculated',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugins_path'       => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Plugins Directory Location' ),
-                               'value' => trailingslashit( WP_PLUGIN_DIR ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Plugins directory location' ),
+                               'value' => WP_PLUGIN_DIR,
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'plugins_size'       => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'label' => __( 'Plugins Directory Size' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'label' => __( 'Plugins directory size' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'value' => $not_calculated,
</span><span class="cx" style="display: block; padding: 0 10px">                                'debug' => 'not calculated',
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'wordpress_path'     => array(
-                               'label' => __( 'WordPress Directory Location' ),
-                               'value' => ABSPATH,
-                       ),
-                       'wordpress_size'     => array(
-                               'label' => __( 'WordPress Directory Size' ),
-                               'value' => $not_calculated,
-                               'debug' => 'not calculated',
-                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                         'database_size'      => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'label' => __( 'Database size' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'value' => $not_calculated,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -898,6 +894,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'label' => __( 'Theme features' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'value' => implode( ', ', $theme_features ),
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'theme_path'     => array(
+                               'label' => __( 'Theme directory location' ),
+                               'value' => get_template_directory(),
+                       ),
</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">                // Populate a list of all themes available in the install.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1137,60 +1137,62 @@
</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">                // Go through the various installation directories and calculate their sizes.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $all_sizes = array(
-                       'wordpress_size' => array(
-                               'path' => ABSPATH,
-                               'size' => 0,
-                       ),
-                       'themes_size'    => array(
-                               'path' => trailingslashit( get_theme_root() ),
-                               'size' => 0,
-                       ),
-                       'plugins_size'   => array(
-                               'path' => trailingslashit( WP_PLUGIN_DIR ),
-                               'size' => 0,
-                       ),
-                       'uploads_size'   => array(
-                               'path' => $upload_dir['basedir'],
-                               'size' => 0,
-                       ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // No trailing slashes.
+               $paths = array(
+                       'wordpress_size' => untrailingslashit( ABSPATH ),
+                       'themes_size'    => get_theme_root(),
+                       'plugins_size'   => WP_PLUGIN_DIR,
+                       'uploads_size'   => $upload_dir['basedir'],
</ins><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">+                $exclude = $paths;
+               unset( $exclude['wordpress_size'] );
+               $exclude = array_values( $exclude );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $size_total = 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $all_sizes  = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Loop over all the directories we want to gather the sizes for.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                foreach ( $all_sizes as $name => $attributes ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         foreach ( $paths as $name => $path ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $dir_size = null; // Default to timeout.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        $results  = array(
+                               'path' => $path,
+                               'raw'  => 0,
+                       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $dir_size = recurse_dirsize( $attributes['path'], null, $max_execution_time );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( 'wordpress_size' === $name ) {
+                                       $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
+                               } else {
+                                       $dir_size = recurse_dirsize( $path, null, $max_execution_time );
+                               }
</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">                        if ( false === $dir_size ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                // Error reading.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $all_sizes[ $name ]['size']  = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' );
-                               $all_sizes[ $name ]['debug'] = 'not accessible';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $results['size']  = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' );
+                               $results['debug'] = 'not accessible';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Stop total size calculation.
</span><span class="cx" style="display: block; padding: 0 10px">                                $size_total = null;
</span><span class="cx" style="display: block; padding: 0 10px">                        } elseif ( null === $dir_size ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                // Timeout.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $all_sizes[ $name ]['size']  = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' );
-                               $all_sizes[ $name ]['debug'] = 'timeout while calculating size';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $results['size']  = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' );
+                               $results['debug'] = 'timeout while calculating size';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Stop total size calculation.
</span><span class="cx" style="display: block; padding: 0 10px">                                $size_total = null;
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $is_subdir = ( strpos( $attributes['path'], ABSPATH ) === 0 );
-
-                               // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
-                               if ( null !== $size_total && ( 'wordpress_size' === $name || ! $is_subdir ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( null !== $size_total ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         $size_total += $dir_size;
</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_sizes[ $name ]['size']  = size_format( $dir_size, 2 );
-                               $all_sizes[ $name ]['debug'] = $all_sizes[ $name ]['size'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         $results['raw']   = $dir_size;
+                               $results['size']  = size_format( $dir_size, 2 );
+                               $results['debug'] = $results['size'] . " ({$dir_size} bytes)";
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       $all_sizes[ $name ] = $results;
</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">                if ( $size_db > 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1197,8 +1199,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $database_size = size_format( $size_db, 2 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $all_sizes['database_size'] = array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'raw'   => $size_db,
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'size'  => $database_size,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'debug' => $database_size,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'debug' => $database_size . " ({$size_db} bytes)",
</ins><span class="cx" style="display: block; padding: 0 10px">                         );
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $all_sizes['database_size'] = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1208,11 +1211,13 @@
</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">                if ( null !== $size_total && $size_db > 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $total_size = size_format( $size_total + $size_db, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $total_size = $size_total + $size_db;
+                       $total_size_mb = size_format( $total_size, 2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $all_sizes['total_size'] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'size'  => $total_size,
-                               'debug' => $total_size,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'raw'   => $total_size,
+                               'size'  => $total_size_mb,
+                               'debug' => $total_size_mb . " ({$total_size} bytes)",
</ins><span class="cx" style="display: block; padding: 0 10px">                         );
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $all_sizes['total_size'] = array(
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></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/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php       2019-04-16 20:29:42 UTC (rev 45219)
+++ trunk/src/wp-includes/functions.php 2019-04-16 23:01:45 UTC (rev 45220)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7071,11 +7071,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.3.0 $exclude parameter added.
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.2.0 $max_execution_time parameter added.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $directory Full path of a directory.
- * @param string $exclude   Optional. Full path of a subdirectory to exclude from the total.
- * @param int    $max_execution_time Maximum time to run before giving up. In seconds.
- *                                   The timeout is global and is measured from the moment WordPress started to load.
- * @return int|false|null Size in MB if a valid directory. False if not. Null if timeout.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $directory       Full path of a directory.
+ * @param string|array $exclude   Optional. Full path of a subdirectory to exclude from the total, or array of paths.
+ *                                Expected without trailing slash(es).
+ * @param int $max_execution_time Maximum time to run before giving up. In seconds.
+ *                                The timeout is global and is measured from the moment WordPress started to load.
+ * @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $size = 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7082,10 +7083,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $directory = untrailingslashit( $directory );
</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 ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) || $directory === $exclude ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return false;
</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 (
+               ( is_string( $exclude ) && $directory === $exclude ) ||
+               ( is_array( $exclude ) && in_array( $directory, $exclude, true ) )
+       ) {
+               return false;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         if ( $max_execution_time === null ) {
</span><span class="cx" style="display: block; padding: 0 10px">                // Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( function_exists( 'ini_get' ) ) {
</span></span></pre>
</div>
</div>

</body>
</html>