Skip to content

Commit 3ffe5ff

Browse files
committed
adds logging for get_filelist
1 parent e7611ac commit 3ffe5ff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

admin/class-boldgrid-backup-admin-core.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,31 +1379,45 @@ private function restore_database( $db_dump_filepath, $db_prefix = null, $db_enc
13791379
public function get_filelist( $dirpath ) {
13801380

13811381
// If this is a node_modules folder, do not iterate through it.
1382+
$this->logger->add( 'before node_modules folder check' );
13821383
if ( false !== strpos( $dirpath, '/node_modules' ) ) {
13831384
return [];
13841385
}
1386+
$this->logger->add( 'after node_modules folder check' );
13851387

13861388
// Connect to the WordPress Filesystem API.
1389+
$this->logger->add( 'before $wp_filesystem global' );
13871390
global $wp_filesystem;
1391+
$this->logger->add( 'after $wp_filesystem global' );
13881392

13891393
// Validate input.
1394+
$this->logger->add( 'before validate input' );
13901395
if ( empty( $dirpath ) || ! $wp_filesystem->is_readable( $dirpath ) ) {
13911396
return [];
13921397
}
1398+
$this->logger->add( 'after validate input' );
13931399

13941400
// Remove any training slash in dirpath.
1401+
$this->logger->add( 'before remove trailing slash dirpath' );
13951402
$dirpath = untrailingslashit( $dirpath );
1403+
$this->logger->add( 'after remove trailing slash dirpath' );
13961404

13971405
// Mark the base directory, if not set (the first run).
1406+
$this->logger->add( 'before mark the base directory' );
13981407
if ( empty( $this->filelist_basedir ) ) {
13991408
$this->filelist_basedir = $dirpath;
14001409
}
1410+
$this->logger->add( 'after mark the base directory' );
14011411

14021412
// Get the non-recursive directory listing for the specified path.
1413+
$this->logger->add( 'before get-nonrecursive directory listing' );
14031414
$dirlist = $wp_filesystem->dirlist( $dirpath, true, false );
1415+
$this->logger->add( 'after get-nonrecursive directory listing' );
14041416

14051417
// Initialize $filelist.
1418+
$this->logger->add( 'before initialize $filelist' );
14061419
$filelist = [];
1420+
$this->logger->add( 'after initialize $filelist' );
14071421

14081422
/*
14091423
* Add empty directory.
@@ -1414,6 +1428,7 @@ public function get_filelist( $dirpath ) {
14141428
* Previously we used Boldgrid_Backup_Admin_Compressor_Php_Zip::add_dirs
14151429
* to add all empty directories, but that method is no longer needed.
14161430
*/
1431+
$this->logger->add( 'before add empty directory' );
14171432
if ( empty( $dirlist ) ) {
14181433
$filelist[] = [
14191434
$dirpath,
@@ -1423,8 +1438,10 @@ public function get_filelist( $dirpath ) {
14231438
'd',
14241439
];
14251440
}
1441+
$this->logger->add( 'after add empty directory' );
14261442

14271443
// Sort the dirlist array by filename.
1444+
$this->logger->add( 'before sort dirlist array by filename' );
14281445
uasort(
14291446
$dirlist,
14301447
function ( $a, $b ) {
@@ -1439,33 +1456,45 @@ function ( $a, $b ) {
14391456
return 0;
14401457
}
14411458
);
1459+
$this->logger->add( 'after sort dirlist array by filename' );
14421460

14431461
// Perform conversion.
1462+
$this->logger->add( 'before perform conversion' );
14441463
foreach ( $dirlist as $fileinfo ) {
14451464
// If item is a directory, then recurse, merge, and continue.
1465+
$this->logger->add( 'before if item is a directory' );
14461466
if ( 'd' === $fileinfo['type'] ) {
14471467
$filelist_add = $this->get_filelist( $dirpath . '/' . $fileinfo['name'] );
14481468

14491469
$filelist = array_merge( $filelist, $filelist_add );
14501470

14511471
continue;
14521472
}
1473+
$this->logger->add( 'after if item is a directory' );
14531474

14541475
// Get the file path.
1476+
$this->logger->add( 'before get the file path' );
14551477
$filepath = $dirpath . '/' . $fileinfo['name'];
1478+
$this->logger->add( 'after get the file path' );
14561479

14571480
// The relative path inside the ZIP file.
1481+
$this->logger->add( 'before relative path in ZIP' );
14581482
$relative_path = substr( $filepath, strlen( $this->filelist_basedir ) + 1 );
1483+
$this->logger->add( 'after relative path in ZIP' );
14591484

14601485
// For files, add to the filelist array.
1486+
$this->logger->add( 'before add files to filelist array' );
14611487
$filelist[] = [
14621488
$filepath,
14631489
$relative_path,
14641490
$fileinfo['size'],
14651491
];
1492+
$this->logger->add( 'before add files to filelist array' );
14661493
}
1494+
$this->logger->add( 'before perform conversion' );
14671495

14681496
// Return the array.
1497+
$this->logger->add( 'before array return' );
14691498
return $filelist;
14701499
}
14711500

0 commit comments

Comments
 (0)