From 4db53472996d5f076849dc2230a8d8042692ae0c Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 15 Mar 2019 18:59:14 +0000 Subject: [PATCH] Privacy: Do not attempt to cleanup personal data export files when the directory does not exist. Checking for the presence of the directory and returning early prevents PHP warnings when attempting to list files in a non-existent directory. Props arena, garrett-eclipse. Fixes #45136. git-svn-id: https://develop.svn.wordpress.org/trunk@44910 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index c4a2b8ed1b..dda32611e4 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -6712,9 +6712,12 @@ function wp_schedule_delete_old_privacy_export_files() { * @since 4.9.6 */ function wp_privacy_delete_old_export_files() { - require_once( ABSPATH . 'wp-admin/includes/file.php' ); + $exports_dir = wp_privacy_exports_dir(); + if ( ! is_dir( $exports_dir ) ) { + return; + } - $exports_dir = wp_privacy_exports_dir(); + require_once( ABSPATH . 'wp-admin/includes/file.php' ); $export_files = list_files( $exports_dir, 100, array( 'index.html' ) ); /**