elementor / elementor/static-html-output
Consider doing Sanity check before attempt of crawling & deployment
- Dominant language
- PHP
- Stars
- 128
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
A user (like me) who want to accept guest post and comment wont hesitate keeping http-auth/IP protected development area and proxied with CF, there are some areas where things can improve
### 1. WP2Static should check if Development Area is reachable or not
**For Cloudflare proxied Development Site**
- If dev site HTTP response indicate Server: Cloudflare? Ask user to whitelist development Server IP in Cloudflare Firewall rule
(But, why? There are chances when CF WAF settings can prevent crawling.
If I am not wrong, they use Maxmind IP geo data.

It was considering Russia but my original Server Location was **Singapore**.
And, I had a rule to force JavaScript validation for all Russian visitors because so many incoming spam.
**Result**: I accidently blocked my server and caused failure of crawling message. Intrestingly, crawling was still in the progress (as I seen NGINX logs, it was just browser end failure of loading ajax requests)

or, this can be avoided by hardcoded IP in the hosts file.
Hinting user to set up whitelist will allow free-road for crawling.

- Suggest user do not use `ignore query string` cache level because the plugin uses query string while making ajax request, or ask the user to add a page rule to bypass the cache for
`*example.com/wp-content/uploads/WP-STATIC-PROGRESS.txt*`

### 2. Is development site HTTP Auth protected?
- If the response is not 200 but 401 (Unauthorised) due to HTTP-Auth? Hint user to fill HTTP auth details.
- If 500, return an error
- Also, do check either entry are correct or wrong because Chrome saved pass can forcefully add /wp-login.php credential and cause an error. Some user won't even realize what caused until they would check HTTP web server log (`tail -f /var/log/nginx/error.log`)
### 3. Validate Deployment Credential before starting 'crawling ...' before user click on "Deploy" button
- After clicking Deploy, the first thing shouldn't be crawling initial file list instead 'validate credentials' to prevent showing 'Failure to deploy' at last due to user mistake.
- After this, there is no need of "Test" button.
### 4. Validate Permission to ensure "Delete button" works
- Uncertain if this is already covered partially or fully.
### 5. Introduce better error message when unable to deploy
- For example, Selected Deployment mode Bunny had an issue with their storage
- I got some error like Failed to deploy, that was unclear what's happening.
- I checked log got below kind of message
```
root@example:/var/log/nginx# tail -f error.log
502 Bad Gateway
ngin (truncated...)
in /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create()
#1 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}()
#2 /var/www/wordpress/wp-content/plugins/static-html-output-plugin/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler()
#3 /var/www/wordpress/wp-content/plugins/static-html-ou" while reading response header from upstream, client: MY.IP.ADD.RESS, server: example.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/wp-admin/admin.php?page=statichtmloutput"
2020/08/25 20:24:30 [error] 45280#45280: *212 FastCGI sent in stderr: "PHP message: WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query INSERT INTO flyingpress_statichtmloutput_crawl_log (url, note, status) VALUES made by do_action('wp_ajax_wp_static_html_output_ajax'), WP_Hook->do_action, WP_Hook->apply_filters, static_html_output_ajax, StaticHTMLOutput\Controller->prepare_for_export, StaticHTMLOutput\Exporter->generateModifiedFileList, StaticHTMLOutput\CrawlLog::addUrlsPHP message: WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query INSERT INTO flyingpress_statichtmloutput_urls (url) VALUES made by do_action('wp_ajax_wp_static_html_output_ajax'), WP_Hook->do_action, WP_Hook->apply_filters, static_html_output_ajax, StaticHTMLOutput\Controller->prepare_for_export, StaticHTMLOutput\Exporter->generateModifiedFileList, StaticHTMLOutput\CrawlQueue::addUrls" while reading response header from upstream, client: MY.IP.ADD.RESS, server: example.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/wp-admin/admin.php?page=statichtmloutput"
```
- I think there should be a better error handling method if unable to reach the storage / CDN at any point
I feel this suggestion will help beginners to avoid client and proxy side common pitfalls.
Thanks
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.