Uncaught UnexpectedValueException RecursiveDirectoryIterator

Hi,
I hope this message finds everyone well! I am trying to add WP2Static to an already existing WP site but I have been coming across some issues. The current issue is that the required folders in uploads are not being created when pressing the “Generate static site” button. I have tried creating the folders manually but it seems that they are still not being populated with the necessary files. I have confirmed that 1317 URLs have been found but 0 are crawled. I have also tried running the jobs manually but had the same result. This results in the following error:

[09-Jun-2022 08:29:02 UTC] PHP Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator::_construct(/shared/httpd/mysite/wordpress.git/wp-content/uploads/wp2static-processed-site): Failed to open directory: No such file or directory in /shared/httpd/ mysite/wordpress.git/wp-content/plugins/wp2static-addon-zip/src/ZipArchiver.php:30 Stack trace: #0 /shared/httpd/mysite/wordpress.git/wp-content/plugins/wp2static-addon-zip/src/ZipArchiver.php(30): RecursiveDirectoryIterator->__construct(7shared/httpd/m…‘, 4096) #1 /shared/httpd/mysite/wordpress.git/wp-content/plugins/wp2static-addon-zip/src/Controller.php(87): WP2StaticZip\ZipArchiver->generateArchive(7shared/httpd/m…’) #2 /shared/httpd/mysite/wordpress.git/wp-includes/class-wp-hook.php(307): WP2StaticZip\Controller->generateZip(7shared/httpd/m…', ‘wp2static-addon…’) #3 /shared/httpd/mysite/wordpress.git/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(“, Array) #4 /shared/httpd/mysite/wordpress.git/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #5 /shared/httpd/mysite/wordpress.git/wp-content/plugins/wp2static/src/Controller.php(707): do_action('wp2static_deplo…, ‘/shared/httpd/m…’, 'wp2static-addon…) #6 /shared/httpd/mysite/wordpress.git/wp-content/plugins/wp2static/src/Controller.php(799): WP2Static\Controller::wp2staticHeadless() #7 /shared/httpd/mysite/wordpress.git/wp-includes/class-wp-hook.php(305): WP2Static\Controller::wp2staticRun() #8 /shared/httpd/mysite/wordpress.git/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(”, Array) #9 /shared/httpd/mysite/wordpress.git/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #10 /shared/httpd/mysite/wordpress.git/wp-admin/admin-ajax.php(188): do_action(‘wp_ajax_wp2stat…’) #11 {main} thrown in /shared/httpd/mysite/wordpress.git/wp-content/plugins/wp2static-addon-zip/src/ZipArchiver.php on line 30

These are the logs from the plugin itself:

I look forward to your reply!
Regards
Sean

Hi @Sean.Anastasi,

Sorry to see you’ve encountered this issue.

Could you please share as much info about your setup as possible - where this is hosted, what type of server, anything particular about the directory you’ve got WordPress in (any symlinks or network volumes?).

It feels like an environmental issue to me (ie, something specific to your setup). It may still be a bug in the software for not supporting this particular setup, but if you have an alternate hosting you can clone your site to to try, that would be a good way for us to isolate the cause.

Hi @leonstafford,

Thanks for your reply, Currently the site is working locally in a docker container through Devilbox using nginx and php 8.1. I had tried the WP2Static 7.1.7 version that is on the wp2static.com website and did not have this issue (although I had some other issues related to chained redirects). The current github version fixed the redirect issue but in turn is having issues with creating folders and files.

I hope this is enough information to pinpoint the issue

Hi @Sean.Anastasi OK, that’s good news - glad you’re able to use it with DevilBox, cool project!

So, what may have changed in that setup, is going from the zip to a git clone - maybe file permissions got messed up/became to restricted during the process?

If you run some ls -la commands from your terminal in say the wp2static plugin directory, then another, non-git plugin directory, then at the parent plugin directory above those 2, please see if the owner and groups permissions differ at all. Hopefully, it’s something like that, else, we’ll need to dig further.

Also, what is your host OS that you’re running DevilBox in? If macOS, I may be able to reproduce your setup.

Hi @leonstafford Im adding some screenshots to show file and folder permissions. Im on windows 10 but running devilbox in ubuntu 16.04 with WSL2. I also forgot to note that all plugins shown here are disabled besides Advanced Custom Fields (ACF), WP2Static and the zip addon. I left ACF on since it was giving some errors which made debugging difficult when disabled

WP2Static
image

Plugins

wp-content
image

uploads
image

That all looks fine. Could you try switching back to the wp2static.com downloaded ZIP and confirm that still works (besides the other issue)?

When installing the downloaded ZIP it still works fine with 1317 URLs detected and 34 URLs crawled and saved (I assume that’s up until it finds the chained redirects). I also checked the logs and it shows the redirect issue again. I noticed that previously I was using the git version of the plugin but the downloaded version of the ZIP addon. Could this be the reason it wasn’t working well?

hmm, possibly. Depending on versions, there may be some changes that require the latest of zip to work with latest of core…

Please give that a shot if you can, if still not working, I’ll try to reproduce the issue here with DevilBox.

Also, can you try an alternative on Windows to DevilBox and see if same issue persists?

Hi, I tried using the latest version from github and had the same issues. I also tried with a different docker environment without devilbox but I had a seperate issue which had brought me to change to devilbox initially

Hi good morning,

Just as a small update to this, I tried generating the static files again today, the logs still showed 0 crawled 0 skipped but some files seem to have been created although no styling was included. I did nothing different from my end so I find it quite confusing as to how it worked this time.

The styling issue was my fault, I left the deployment url to the wrong URL. All my issues have been sorted now. Thank you for the help @leonstafford! Hope you have a good day