Changeset 65190
- Timestamp:
- 11/02/2026 03:54:19 PM (2 days ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/includes/bootstrap.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/bootstrap.php
r65177 r65190 331 331 } 332 332 333 /* 334 * Delete the wp-content/test-suite-uploads folder before WordPress loads. 335 * 336 * Plugins and themes may call wp_upload_dir() while loading, which creates the folder and 337 * caches it as created. Deleting it afterwards would leave a cached path that no longer exists. 338 * WordPress functions are not available yet, so this uses plain PHP. 339 */ 340 if ( ! empty( $delete_tests_uploads_dir ) ) { 341 $uploads_test_run_dir = ABSPATH . UPLOADS; 342 343 if ( is_dir( $uploads_test_run_dir ) ) { 344 try { 345 $uploads_test_run_files = new RecursiveIteratorIterator( 346 new RecursiveDirectoryIterator( $uploads_test_run_dir, FilesystemIterator::SKIP_DOTS ), 347 RecursiveIteratorIterator::CHILD_FIRST 348 ); 349 350 foreach ( $uploads_test_run_files as $uploads_test_run_file ) { 351 // Windows removes symlinks to directories with rmdir(), not unlink(). 352 if ( $uploads_test_run_file->isDir() && ( ! $uploads_test_run_file->isLink() || 'Windows' === PHP_OS_FAMILY ) ) { 353 rmdir( $uploads_test_run_file->getPathname() ); 354 } else { 355 unlink( $uploads_test_run_file->getPathname() ); 356 } 357 } 358 359 rmdir( $uploads_test_run_dir ); 360 } catch ( UnexpectedValueException $uploads_test_run_exception ) { 361 echo 'Could not delete the test uploads directory: ' . $uploads_test_run_exception->getMessage() . PHP_EOL; 362 } 363 } 364 365 unset( $uploads_test_run_dir, $uploads_test_run_files, $uploads_test_run_file, $uploads_test_run_exception ); 366 } 367 unset( $delete_tests_uploads_dir ); 368 333 369 // Load WordPress. 334 370 require_once ABSPATH . 'wp-settings.php'; 335 336 // Process delete wp-content/test-suite-uploads folder.337 if ( ! empty( $delete_tests_uploads_dir ) ) {338 $uploads_test_run_dir = ABSPATH . UPLOADS;339 340 if ( is_dir( $uploads_test_run_dir ) ) {341 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';342 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';343 344 // Use the direct transport, as WP_Filesystem() may pick FTP and fail without credentials.345 $uploads_test_run_fs = new WP_Filesystem_Direct( null );346 $uploads_test_run_fs->delete( $uploads_test_run_dir, true );347 }348 349 unset( $uploads_test_run_dir, $uploads_test_run_fs );350 }351 unset( $delete_tests_uploads_dir );352 371 353 372 // Override the PHPMailer.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)