Title: Uncaught ValueError: RecursiveDirectoryIterator
Last modified: May 8, 2026

---

# Uncaught ValueError: RecursiveDirectoryIterator

 *  [robert_t_taylor](https://wordpress.org/support/users/robert_t_taylor/)
 * (@robert_t_taylor)
 * [1 month, 1 week ago](https://wordpress.org/support/topic/uncaught-valueerror-recursivedirectoryiterator/)
 * I was able to get past an error in the archive_dir() function by adding the following
   right before the “// Create recursive directory iterator.” comment:
 *     ```wp-block-code
       // Guard clause: Ensure the path is not empty and exists before iterating.// This prevents a Fatal ValueError in PHP 8.0+.if ( empty( $root_path ) || ! is_string( $root_path ) ) {    error_log( 'SiteGround Migrator: archive_dir got empty directory; aborting. Destination: ' . var_export( $root_path, true ) );    return false;}if ( ! is_dir( $root_path ) ) {    error_log( 'SiteGround Migrator: archive_dir directory does not exist: ' . $root_path );    return false;}
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Funcaught-valueerror-recursivedirectoryiterator%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Support [aleksandardimitrov](https://wordpress.org/support/users/aleksandardimitrov/)
 * (@aleksandardimitrov)
 * [1 month, 1 week ago](https://wordpress.org/support/topic/uncaught-valueerror-recursivedirectoryiterator/#post-18903348)
 * Hello,
 * Thank you for the detailed report and for sharing your fix for the `ValueError:
   RecursiveDirectoryIterator` in the `archive_dir()` function.
 * I have forwarded these details to our developers so they can investigate the 
   root cause and implement an official fix. We appreciate you bringing this to 
   our attention.
 * Best Regards,
 * Aleksandar Dimitrov

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Funcaught-valueerror-recursivedirectoryiterator%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/siteground-migrator/assets/icon.svg?rev=3447692)
 * [SiteGround Migrator](https://wordpress.org/plugins/siteground-migrator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/siteground-migrator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/siteground-migrator/)
 * [Active Topics](https://wordpress.org/support/plugin/siteground-migrator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/siteground-migrator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/siteground-migrator/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [aleksandardimitrov](https://wordpress.org/support/users/aleksandardimitrov/)
 * Last activity: [1 month, 1 week ago](https://wordpress.org/support/topic/uncaught-valueerror-recursivedirectoryiterator/#post-18903348)
 * Status: not resolved