elementor / static-html-output

Static HTML Output Plugin for WordPress
https://statichtmloutput.com
The Unlicense
124 stars 33 forks source link

Wrong CURL Domain #157

Closed marcussacana closed 1 year ago

marcussacana commented 3 years ago

For some reason the plugin isn't putting a / after the domain when he try download the page The LOG:

CLICK ME

``` 2020-11-25 07:31:25 2020-11-25 10:31:25 PHP VERSION 7.4.9 OS VERSION Linux marcus-pc 5.8.0-29-generic #31-Ubuntu SMP Fri Nov 6 12:37:59 UTC 2020 x86_64 WP VERSION 5.5.3 WP URL http://localhost WP SITEURL http://localhost WP HOME http://localhost WP ADDRESS http://localhost PLUGIN VERSION 6.6.23 VIA WP-CLI? STATIC EXPORT URL http://example.com PERMALINK STRUCTURE /%postname%/ SERVER SOFTWARE lighttpd/1.4.55 2020-11-25 07:31:25 WP Site Info: 2020-11-25 07:31:25 Site Path: /var/www/html/ WP Uploads URL: http://localhost/wp-content/uploads WP Uploads Path: /var/www/html/wp-content/uploads WP Uploads ??: /wp-content/uploads WP Site Path: /var/www/html/ WP Site Subdirectory: Uploads URL: http://localhost/wp-content/uploads Site URL: http://localhost Parent Theme URL: http://localhost/wp-content/themes/agama Parent Theme Path: /var/www/html/wp-content/themes/agama Child Theme Path: /var/www/html/wp-content/themes/agama-blue Child Theme Active: 1 Theme Root Path: /var/www/html/wp-content/themes Themes ??: /wp-content/themes Active Theme ??: /wp-content/themes/agama WP Content URL: http://localhost/wp-content WP Content Path: /var/www/html/wp-content WP Content ??: /var/www/html/wp-content Plugins Path: /var/www/html/wp-content/plugins WP Plugins ??: /wp-content/plugins WP Includes Path: /var/www/html/wp-includes Permalink Structure: /%postname%/ WP Inc Path: /wp-includes Subdirectory install?: 2020-11-25 07:31:26 Active plugins: 2020-11-25 07:31:26 disqus-comment-system/disqus.php 2020-11-25 07:31:26 everest-tab-lite/everest-tab-lite.php 2020-11-25 07:31:26 static-html-output/static-html-output.php 2020-11-25 07:31:26 svg-support/svg-support.php 2020-11-25 07:31:26 wp2static-addon-zip/wp2static-addon-zip.php 2020-11-25 07:31:26 wp2static/wp2static.php 2020-11-25 07:31:26 Plugin options: 2020-11-25 07:31:27 additionalUrls: 2020-11-25 07:31:27 baseUrl: 2020-11-25 07:31:27 baseUrl-bitbucket: 2020-11-25 07:31:27 baseUrl-bunnycdn: 2020-11-25 07:31:27 baseUrl-github: 2020-11-25 07:31:27 baseUrl-gitlab: 2020-11-25 07:31:27 baseUrl-netlify: 2020-11-25 07:31:27 baseUrl-s3: 2020-11-25 07:31:28 baseUrl-zip: 2020-11-25 07:31:28 basicAuthPassword: ******************* 2020-11-25 07:31:28 basicAuthUser: 2020-11-25 07:31:28 bbBranch: 2020-11-25 07:31:28 bbRepo: 2020-11-25 07:31:28 bbToken: ******************* 2020-11-25 07:31:28 bunnycdnStorageZoneAccessKey: ******************* 2020-11-25 07:31:28 bunnycdnPullZoneAccessKey: ******************* 2020-11-25 07:31:28 bunnycdnPullZoneID: 2020-11-25 07:31:29 bunnycdnStorageZoneName: 2020-11-25 07:31:29 bunnycdn_api_host: ******************* 2020-11-25 07:31:29 cfDistributionId: 2020-11-25 07:31:29 completionEmail: 2020-11-25 07:31:29 crawl_delay: 0 2020-11-25 07:31:29 crawl_increment: 5 2020-11-25 07:31:29 crawlPort: 2020-11-25 07:31:29 delayBetweenAPICalls: 0 2020-11-25 07:31:29 deployBatchSize: 1 2020-11-25 07:31:30 excludeURLs: 2020-11-25 07:31:30 ghBranch: 2020-11-25 07:31:30 ghCommitMessage: 2020-11-25 07:31:30 ghRepo: 2020-11-25 07:31:30 ghToken: ******************* 2020-11-25 07:31:30 glBranch: 2020-11-25 07:31:30 glProject: 2020-11-25 07:31:30 glToken: ******************* 2020-11-25 07:31:30 netlifyHeaders: 2020-11-25 07:31:31 netlifyPersonalAccessToken: ******************* 2020-11-25 07:31:31 netlifyRedirects: 2020-11-25 07:31:31 netlifySiteID: 2020-11-25 07:31:31 removeConditionalHeadComments: 1 2020-11-25 07:31:31 removeHTMLComments: 1 2020-11-25 07:31:31 removeWPLinks: 1 2020-11-25 07:31:31 removeWPMeta: 1 2020-11-25 07:31:31 rewrite_rules: 2020-11-25 07:31:31 rename_rules: 2020-11-25 07:31:32 s3Bucket: 2020-11-25 07:31:32 s3Key: 2020-11-25 07:31:32 s3Region: 2020-11-25 07:31:32 s3Secret: ******************* 2020-11-25 07:31:32 selected_deployment_option: zip 2020-11-25 07:31:32 targetFolder: 2020-11-25 07:31:32 useBasicAuth: 2020-11-25 07:31:32 Installed extensions: 2020-11-25 07:31:32 Core,date,libxml,openssl,pcre,zlib,filter,hash,pcntl,Reflection,SPL,session,standard,sodium,cgi-fcgi,curl,mysqlnd,PDO,xml,calendar,ctype,dom,mbstring,FFI,fileinfo,ftp,gd,gettext,gmp,iconv,intl,json,exif,mysqli,pdo_mysql,pdo_sqlite,Phar,posix,readline,shmop,SimpleXML,sockets,sqlite3,sysvmsg,sysvsem,sysvshm,tokenizer,xmlreader,xmlwriter,xsl,zip,Zend OPcache 2020-11-25 07:31:33 cURL error:Could not resolve host: localhost2020 2020-11-25 07:31:33 BAD RESPONSE STATUS (0): /2020/ 2020-11-25 07:31:34 cURL error:Could not resolve host: localhost2020 2020-11-25 07:31:34 BAD RESPONSE STATUS (0): /2020/11/ 2020-11-25 07:31:34 cURL error:Could not resolve host: localhost2020 2020-11-25 07:31:34 BAD RESPONSE STATUS (0): /2020/11/23/ 2020-11-25 07:31:34 cURL error:Could not resolve host: localhostads.txt 2020-11-25 07:31:34 BAD RESPONSE STATUS (0): /ads.txt 2020-11-25 07:31:35 cURL error:Could not resolve host: localhostagama-blue 2020-11-25 07:31:35 BAD RESPONSE STATUS (0): /agama-blue/ 2020-11-25 07:31:35 cURL error:Could not resolve host: localhostauthor 2020-11-25 07:31:35 BAD RESPONSE STATUS (0): /author/admin/ 2020-11-25 07:31:35 cURL error:Could not resolve host: localhostcomments 2020-11-25 07:31:35 BAD RESPONSE STATUS (0): /comments/feed/ 2020-11-25 07:31:36 cURL error:Could not resolve host: localhostfavicon.ico 2020-11-25 07:31:36 BAD RESPONSE STATUS (0): /favicon.ico 2020-11-25 07:31:36 cURL error:Could not resolve host: localhostfeed 2020-11-25 07:31:36 BAD RESPONSE STATUS (0): /feed/ 2020-11-25 07:31:36 cURL error:Could not resolve host: localhostgeneros 2020-11-25 07:31:37 BAD RESPONSE STATUS (0): /generos/uncategorized/ 2020-11-25 07:31:37 cURL error:Could not resolve host: localhosthello-world 2020-11-25 07:31:37 BAD RESPONSE STATUS (0): /hello-world/ 2020-11-25 07:31:37 cURL error:Could not resolve host: localhostrobots.txt 2020-11-25 07:31:37 BAD RESPONSE STATUS (0): /robots.txt 2020-11-25 07:31:37 cURL error:Could not resolve host: localhostsample-page 2020-11-25 07:31:38 BAD RESPONSE STATUS (0): /sample-page/ 2020-11-25 07:31:38 cURL error:Could not resolve host: localhostsitemap.xml 2020-11-25 07:31:38 BAD RESPONSE STATUS (0): /sitemap.xml 2020-11-25 07:31:38 cURL error:Could not resolve host: localhostwp-content 2020-11-25 07:31:38 BAD RESPONSE STATUS (0): /wp-content/plugins/everest-tab-lite/assets/css/animate.css 2020-11-25 07:31:38 cURL error:Could not resolve host: localhostwp-content 2020-11-25 07:31:39 BAD RESPONSE STATUS (0): /wp-content/plugins/everest-tab-lite/assets/css/available_icons/font-awesome/font-awesome.min.css 2020-11-25 07:31:39 cURL error:Could not resolve host: localhostwp-content 2020-11-25 07:31:39 BAD RESPONSE STATUS (0): /wp-content/plugins/everest-tab-lite/assets/css/et-style.css 2020-11-25 07:31:39 cURL error:Could not resolve host: localhostwp-content 2020-11-25 07:31:41 BAD RESPONSE STATUS (0): /wp-content/plugins/everest-tab-lite/assets/js/frontend/et-frontend-script.js 2020-11-25 07:31:41 cURL error:Could not resolve host: localhostwp-content 2020-11-25 07:31:43 BAD RESPONSE STATUS (0): /wp-content/themes/agama-blue/assets/js/agama-blue.js : Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/static-html-output/static-html-output.php:45) in on line : Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/static-html-output/static-html-output.php:45) in on line : Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/plugins/static-html-output/static-html-output.php:45) in on line ```

joeldebruijn commented 3 years ago

Same here, fresh install etc. First export. Misses the "/ ".

image

leonstafford commented 3 years ago

@marcussacana, @joeldebruijn let me dive into this. Perhaps regression issue since last release. In meantime, if you can try this release 2 prior and let me know if that's better:

static-html-output-plugin-6.6.21.zip

leonstafford commented 3 years ago

here's the main diff between 6.6.21 and .23, with some changes to support Windows filepaths and I think some other path related changes, I'll review. They didn't get detected in the unit tests, unfortunately, but I/we should be able to spot the issue:

main diff 6.6.21 to 6.6.23 ```diff diff --git a/readme.txt b/CHANGELOG.md similarity index 84% rename from readme.txt rename to CHANGELOG.md index 7b5ded3d..295083b7 100755 --- a/readme.txt +++ b/CHANGELOG.md @@ -1,132 +1,8 @@ diff --git a/src/ArchiveProcessor.php b/src/ArchiveProcessor.php index 4b294798..cd125464 100755 --- a/src/ArchiveProcessor.php +++ b/src/ArchiveProcessor.php @@ -184,15 +184,18 @@ class ArchiveProcessor extends StaticHTMLOutput { foreach ( $iterator as $filename => $file_object ) { $base_name = basename( $filename ); if ( $base_name != '.' && $base_name != '..' ) { - $realpath = realpath( $filename ); + $realpath = wp_normalize_path( (string) realpath( $filename ) ); + $archive_path = wp_normalize_path( $this->archive->path ); + $filename = wp_normalize_path( $filename ); if ( ! $realpath ) { + Logger::l( "No realpath for filename: $filename" ); continue; } if ( ! $zip_archive->addFile( $realpath, - str_replace( $this->archive->path, '', $filename ) + str_replace( $archive_path, '', $filename ) ) ) { Logger::l( 'Could not add file: ' . $filename ); diff --git a/src/CLI.php b/src/CLI.php index 4ed7a360..f381426e 100755 --- a/src/CLI.php +++ b/src/CLI.php @@ -19,7 +19,7 @@ class CLI { $environmental_info = [ [ 'key' => 'PLUGIN VERSION', - 'value' => Controller::VERSION, + 'value' => STATICHTMLOUTPUT_VERSION, ], [ 'key' => 'PHP_VERSION', diff --git a/src/Controller.php b/src/Controller.php index ca566405..0c443118 100755 --- a/src/Controller.php +++ b/src/Controller.php @@ -28,7 +28,6 @@ class Controller { */ public $wp_site; - const VERSION = '6.6.21'; const OPTIONS_KEY = 'statichtmloutput-options'; const HOOK = 'statichtmloutput'; @@ -96,8 +95,8 @@ class Controller { public function setDefaultOptions() : void { if ( null === $this->options->getOption( 'version' ) ) { $this->options - ->setOption( 'version', self::VERSION ) - ->setOption( 'static_export_settings', self::VERSION ) + ->setOption( 'version', STATICHTMLOUTPUT_VERSION ) + ->setOption( 'static_export_settings', STATICHTMLOUTPUT_VERSION ) // set default options ->setOption( 'rewriteWPPaths', '1' ) ->setOption( 'removeConditionalHeadComments', '1' ) @@ -173,7 +172,7 @@ class Controller { self::HOOK . '-admin', $plugins_url . 'statichtmloutput.css', [], - self::VERSION + STATICHTMLOUTPUT_VERSION ); } @@ -224,7 +223,9 @@ class Controller { if ( $instance->options->selected_deployment_option === 'folder' ) { $instance->options->selected_deployment_option = 'zip'; + // @phpstan-ignore-next-line if ( $instance->options->{'baseUrl-folder'} ) { + // @phpstan-ignore-next-line $instance->options->{'baseUrl-zip'} = $instance->options->{'baseUrl-folder'}; } } @@ -341,7 +342,7 @@ class Controller { 'WP SITEURL ' . get_option( 'siteurl' ), 'WP HOME ' . get_option( 'home' ), 'WP ADDRESS ' . get_bloginfo( 'wpurl' ), - 'PLUGIN VERSION ' . $this::VERSION, + 'PLUGIN VERSION ' . STATICHTMLOUTPUT_VERSION, 'VIA WP-CLI? ' . defined( 'WP_CLI' ), 'STATIC EXPORT URL ' . $this->exporter->settings['baseUrl'], 'PERMALINK STRUCTURE ' . get_option( 'permalink_structure' ), @@ -353,6 +354,12 @@ class Controller { Logger::l( implode( PHP_EOL, $info ) ); + Logger::l( 'WP Site Info:' ); + + $wpsite = new WPSite(); + + Logger::l( (string) $wpsite ); + Logger::l( 'Active plugins:' ); $active_plugins = get_option( 'active_plugins' ); diff --git a/src/FileWriter.php b/src/FileWriter.php index 1c71d0e8..35455e36 100755 --- a/src/FileWriter.php +++ b/src/FileWriter.php @@ -54,6 +54,11 @@ class FileWriter extends StaticHTMLOutput { // url decode dirname $directory_in_archive = urldecode( $directory_in_archive ); + // TODO: test force fix for Win filepath issue + if ( $directory_in_archive === '\\' ) { + $directory_in_archive = ''; + } + if ( ! empty( $this->settings['wp_site_subdir'] ) ) { $directory_in_archive = str_replace( $this->settings['wp_site_subdir'], @@ -65,8 +70,10 @@ class FileWriter extends StaticHTMLOutput { $file_dir = $archive_dir . ltrim( $directory_in_archive, '/' ); // set filename to index if no extension && base and filename are same - if ( empty( $path_info['extension'] ) && - $path_info['basename'] === $path_info['filename'] ) { + if ( + empty( $path_info['extension'] ) && + $path_info['basename'] === $path_info['filename'] + ) { $file_dir .= '/' . urldecode( $path_info['basename'] ); $path_info['filename'] = 'index'; } @@ -83,6 +90,8 @@ class FileWriter extends StaticHTMLOutput { $file_extension = 'html'; } elseif ( $this->file_type == 'xml' ) { $file_extension = 'html'; + } elseif ( $this->file_type == 'json' ) { + $file_extension = 'json'; } $filename = ''; @@ -106,6 +115,9 @@ class FileWriter extends StaticHTMLOutput { '.' . $file_extension; } + // TODO: note force rm double slashes + $filename = str_replace( '//', '/', $filename ); + $file_contents = $this->content; if ( $file_contents ) { diff --git a/src/FilesHelper.php b/src/FilesHelper.php index c4af1ae0..3e34c79c 100755 --- a/src/FilesHelper.php +++ b/src/FilesHelper.php @@ -461,7 +461,7 @@ class FilesHelper { $category_links = []; foreach ( $taxonomies as $taxonomy ) { - if ( ! isset( $taxonomy->name ) ) { + if ( ! $taxonomy->name ) { continue; } diff --git a/src/Options.php b/src/Options.php index f21f2f5a..0ec6f892 100755 --- a/src/Options.php +++ b/src/Options.php @@ -30,7 +30,6 @@ class Options { 'baseUrl-netlify', 'baseUrl-s3', 'baseUrl-zip', - 'baseUrl-zip', 'basicAuthPassword', 'basicAuthUser', 'bbBranch', @@ -88,7 +87,6 @@ class Options { 'baseUrl-netlify', 'baseUrl-s3', 'baseUrl-zip', - 'baseUrl-zip', 'basicAuthUser', 'bbBranch', 'bbRepo', diff --git a/src/WPSite.php b/src/WPSite.php index a859a5da..8e35fbb4 100755 --- a/src/WPSite.php +++ b/src/WPSite.php @@ -8,6 +8,10 @@ class WPSite { * @var string */ public $uploads_url; + /** + * @var string + */ + public $home; /** * @var string */ @@ -123,14 +127,14 @@ class WPSite { $this->site_url = get_home_url() . '/'; $this->parent_theme_url = get_template_directory_uri(); $this->wp_content_url = content_url(); - $this->site_path = ABSPATH; - $this->plugins_path = $this->getWPDirFullPath( 'plugins' ); - $this->wp_uploads_path = $this->getWPDirFullPath( 'uploads' ); - $this->wp_includes_path = $this->getWPDirFullPath( 'wp-includes' ); - $this->wp_content_path = $this->getWPDirFullPath( 'wp-content' ); - $this->theme_root_path = $this->getWPDirFullPath( 'theme-root' ); - $this->parent_theme_path = $this->getWPDirFullPath( 'parent-theme' ); - $this->child_theme_path = $this->getWPDirFullPath( 'child-theme' ); + $this->site_path = wp_normalize_path( ABSPATH ); + $this->plugins_path = wp_normalize_path( $this->getWPDirFullPath( 'plugins' ) ); + $this->wp_uploads_path = wp_normalize_path( $this->getWPDirFullPath( 'uploads' ) ); + $this->wp_includes_path = wp_normalize_path( $this->getWPDirFullPath( 'wp-includes' ) ); + $this->wp_content_path = wp_normalize_path( $this->getWPDirFullPath( 'wp-content' ) ); + $this->theme_root_path = wp_normalize_path( $this->getWPDirFullPath( 'theme-root' ) ); + $this->parent_theme_path = wp_normalize_path( $this->getWPDirFullPath( 'parent-theme' ) ); + $this->child_theme_path = wp_normalize_path( $this->getWPDirFullPath( 'child-theme' ) ); $this->child_theme_active = $this->parent_theme_path !== $this->child_theme_path; @@ -138,7 +142,7 @@ class WPSite { $this->wp_inc = '/' . WPINC; - $this->wp_content = WP_CONTENT_DIR; + $this->wp_content = wp_normalize_path( WP_CONTENT_DIR ); $this->wp_uploads = str_replace( ABSPATH, '/', $this->wp_uploads_path ); $this->wp_plugins = str_replace( ABSPATH, '/', WP_PLUGIN_DIR ); @@ -146,7 +150,8 @@ class WPSite { $this->wp_active_theme = str_replace( home_url(), '', get_template_directory_uri() ); - $this->detect_base_url(); + $this->site_url = get_option( 'siteurl' ); + $this->home = get_option( 'home' ); $this->subdirectory = $this->isSiteInstalledInSubDirectory(); @@ -161,18 +166,46 @@ class WPSite { $this->curl_enabled = $this->hasCurlSupport(); } + public function __toString() { + return implode( + PHP_EOL, + [ + "Site Path: {$this->site_path}", + "WP Uploads URL: {$this->wp_uploads_url}", + "WP Uploads Path: {$this->wp_uploads_path}", + "WP Uploads ??: {$this->wp_uploads}", + "WP Site Path: {$this->wp_site_path}", + "WP Site Subdirectory: {$this->wp_site_subdir}", + "Uploads URL: {$this->uploads_url}", + "Site URL: {$this->site_url}", + "Parent Theme URL: {$this->parent_theme_url}", + "Parent Theme Path: {$this->parent_theme_path}", + "Child Theme Path: {$this->child_theme_path}", + "Child Theme Active: {$this->child_theme_active}", + "Theme Root Path: {$this->theme_root_path}", + "Themes ??: {$this->wp_themes}", + "Active Theme ??: {$this->wp_active_theme}", + "WP Content URL: {$this->wp_content_url}", + "WP Content Path: {$this->wp_content_path}", + "WP Content ??: {$this->wp_content}", + "Plugins Path: {$this->plugins_path}", + "WP Plugins ??: {$this->wp_plugins}", + "WP Includes Path: {$this->wp_includes_path}", + "Permalink Structure: {$this->permalink_structure}", + "WP Inc Path: {$this->wp_inc}", + "Subdirectory install?: {$this->subdirectory}", + ] + ) . PHP_EOL; + } + public function isSiteInstalledInSubDirectory() : string { $parsed_site_url = parse_url( rtrim( $this->site_url, '/' ) ); - if ( ! is_array( $parsed_site_url ) ) { + if ( ! is_array( $parsed_site_url ) || ! array_key_exists( 'path', $parsed_site_url ) ) { return ''; } - if ( array_key_exists( 'path', $parsed_site_url ) ) { - return $parsed_site_url['path']; - } - - return ''; + return $parsed_site_url['path']; } public function uploadsPathIsWritable() : bool { @@ -187,11 +220,6 @@ class WPSite { return strlen( get_option( 'permalink_structure' ) ) > 0; } - public function detect_base_url() : void { - $site_url = get_option( 'siteurl' ); - $home = get_option( 'home' ); - } - /* Function below assumes people may have changed the default paths for WP directories @@ -279,11 +307,7 @@ class WPSite { public function getWPContentSubDirectory() : string { $parsed_url = parse_url( $this->parent_theme_url ); - if ( ! is_array( $parsed_url ) ) { - return ''; - } - - if ( ! array_key_exists( 'path', $parsed_url ) ) { + if ( ! is_array( $parsed_url ) || ! array_key_exists( 'path', $parsed_url ) ) { return ''; } @@ -300,11 +324,10 @@ class WPSite { */ - if ( count( $path_segments ) === 5 ) { - return $path_segments[1] . '/'; - } else { + if ( count( $path_segments ) !== 5 ) { return ''; } + + return $path_segments[1] . '/'; } } - diff --git a/static-html-output-plugin.php b/static-html-output.php similarity index 88% rename from static-html-output-plugin.php rename to static-html-output.php index 3d020fb0..49e4e4e9 100755 --- a/static-html-output-plugin.php +++ b/static-html-output.php @@ -1,22 +1,22 @@ time \t $log_row->log \t" . PHP_EOL; } - die(); - return null; + return; } if ( $crawl_log ) { @@ -75,7 +74,6 @@ if ( $crawl_log ) { } die(); - return null; } if ( $crawl_queue ) { @@ -91,7 +89,6 @@ if ( $crawl_queue ) { echo implode( $detected_urls, PHP_EOL ); die(); - return null; } if ( $crawl_progress ) { @@ -124,6 +121,12 @@ if ( $deploy_progress ) { wp_send_json( $json_response, 200 ); } +/** + * Define Settings link for plugin + * + * @param string[] $links array of links + * @return string[] modified array of links + */ function static_html_output_action_links( $links ) { $settings_link = 'Settings'; array_unshift( $links, $settings_link ); @@ -131,34 +134,17 @@ function static_html_output_action_links( $links ) { return $links; } -function wp_static_html_output_server_side_export() { - $plugin = Controller::getInstance(); - $plugin->doExportWithoutGUI(); - wp_die(); - return null; -} - -add_action( - 'static_html_output_server_side_export_hook', - 'static_html_output_server_side_export', - 10, - 0 -); - - - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'static_html_output_action_links' ); add_action( 'wp_ajax_wp_static_html_output_ajax', 'static_html_output_ajax' ); -function static_html_output_ajax() { +function static_html_output_ajax() : void { $valid_referer = check_ajax_referer( 'statichtmloutput', 'nonce' ); if ( ! $valid_referer ) { wp_die(); - return null; } $ajax_method = filter_input( INPUT_POST, 'ajax_action' ); @@ -175,10 +161,14 @@ function static_html_output_ajax() { if ( in_array( $ajax_method, $controller_methods ) ) { $class = StaticHTMLOutput\Controller::getInstance(); - call_user_func( [ $class, $ajax_method ] ); + + $callback = [ $class, $ajax_method ]; + + if ( is_callable( $callback ) ) { + call_user_func( $callback ); + } wp_die(); - return null; } elseif ( strpos( $ajax_method, 'crawl' ) !== false ) { $class = new StaticHTMLOutput\SiteCrawler(); } elseif ( strpos( $ajax_method, 'bitbucket' ) !== false ) { @@ -201,7 +191,6 @@ function static_html_output_ajax() { } wp_die(); - return null; } elseif ( strpos( $ajax_method, 'gitlab' ) !== false ) { $class = new StaticHTMLOutput\GitLab(); @@ -223,7 +212,6 @@ function static_html_output_ajax() { } wp_die(); - return null; } elseif ( strpos( $ajax_method, 'github' ) !== false ) { $class = new StaticHTMLOutput\GitHub(); @@ -244,7 +232,6 @@ function static_html_output_ajax() { } wp_die(); - return null; } elseif ( strpos( $ajax_method, 'netlify' ) !== false ) { $class = new StaticHTMLOutput\Netlify(); @@ -261,7 +248,6 @@ function static_html_output_ajax() { } wp_die(); - return null; } elseif ( strpos( $ajax_method, 's3' ) !== false ) { $class = new StaticHTMLOutput\S3(); @@ -285,7 +271,6 @@ function static_html_output_ajax() { } wp_die(); - return null; } elseif ( strpos( $ajax_method, 'cloudfront' ) !== false ) { $class = new StaticHTMLOutput\S3(); } elseif ( strpos( $ajax_method, 'bunny' ) !== false ) { @@ -311,22 +296,23 @@ function static_html_output_ajax() { } wp_die(); - return null; } else { wp_die(); - return null; } - call_user_func( [ $class, $ajax_method ] ); + $callback = [ $class, $ajax_method ]; + + if ( is_callable( $callback ) ) { + call_user_func( $callback ); + } wp_die(); - return null; } remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); -function wp_static_html_output_deregister_scripts() { +function wp_static_html_output_deregister_scripts() : void { wp_deregister_script( 'wp-embed' ); wp_deregister_script( 'comment-reply' ); } @@ -335,6 +321,6 @@ add_action( 'wp_footer', 'wp_static_html_output_deregister_scripts' ); remove_action( 'wp_head', 'wlwmanifest_link' ); if ( defined( 'WP_CLI' ) ) { - WP_CLI::add_command( 'statichtmloutput', 'StaticHTMLOutput\CLI' ); - WP_CLI::add_command( 'statichtmloutput options', [ 'StaticHTMLOutput\CLI', 'options' ] ); + WP_CLI::add_command( 'statichtmloutput', StaticHTMLOutput\CLI::class ); + WP_CLI::add_command( 'statichtmloutput options', [ StaticHTMLOutput\CLI::class, 'options' ] ); } ```
leonstafford commented 3 years ago

debugging 6.6.21 (ignore the crawl errors on port 443 - that's expected on this particular test env today)

detected urls ``` / /2020/ /2020/06/ /2020/06/12/ /ads.txt /category/uncategorized/ /favicon.ico /hello-world/ /robots.txt /sample-page/ /sitemap.xml ```
export log ``` 2020-12-06 10:47:01 2020-12-06 10:47:01 PHP VERSION 7.4.13 OS VERSION Linux ip-10-0-54-255 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 WP VERSION 5.5.3 WP URL https://twilight-dew-7735.staticweb.io WP SITEURL https://twilight-dew-7735.staticweb.io WP HOME https://twilight-dew-7735.staticweb.io WP ADDRESS https://twilight-dew-7735.staticweb.io PLUGIN VERSION 6.6.21 VIA WP-CLI? STATIC EXPORT URL https://example.com PERMALINK STRUCTURE /%postname%/ SERVER SOFTWARE nginx/1.14.2 2020-12-06 10:47:01 Active plugins: ... 2020-12-06 10:47:01 cURL error:Failed to connect to twilight-dew-7735.staticweb.io port 443: Connection refused 2020-12-06 10:47:01 BAD RESPONSE STATUS (0): / 2020-12-06 10:47:01 cURL error:Failed to connect to twilight-dew-7735.staticweb.io port 443: Connection refused 2020-12-06 10:47:01 BAD RESPONSE STATUS (0): /2020/ ... ```
crawl log ``` Pending / Note: initial_crawl_list Pending /2020/ Note: initial_crawl_list Pending /2020/06/ Note: initial_crawl_list Pending /2020/06/12/ Note: initial_crawl_list Pending /ads.txt Note: initial_crawl_list Pending /category/uncategorized/ Note: initial_crawl_list Pending /favicon.ico Note: initial_crawl_list Pending /hello-world/ Note: initial_crawl_list Pending /robots.txt Note: initial_crawl_list Pending /sample-page/ Note: initial_crawl_list Pending /sitemap.xml Note: initial_crawl_list ```
leonstafford commented 3 years ago

comparing with 6.6.23:

detected urls ``` / /2020/ /2020/06/ /2020/06/12/ /ads.txt /category/uncategorized/ /favicon.ico /hello-world/ /robots.txt /sample-page/ /sitemap.xml ```
export log ``` 2020-12-06 10:52:24 2020-12-06 10:52:24 PHP VERSION 7.4.13 OS VERSION Linux ip-10-0-54-255 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 WP VERSION 5.5.3 WP URL https://twilight-dew-7735.staticweb.io WP SITEURL https://twilight-dew-7735.staticweb.io WP HOME https://twilight-dew-7735.staticweb.io WP ADDRESS https://twilight-dew-7735.staticweb.io PLUGIN VERSION 6.6.23 VIA WP-CLI? STATIC EXPORT URL https://example.com PERMALINK STRUCTURE /%postname%/ SERVER SOFTWARE nginx/1.14.2 2020-12-06 10:52:24 WP Site Info: 2020-12-06 10:52:24 Site Path: /home/staticweb/wordpress/ WP Uploads URL: https://twilight-dew-7735.staticweb.io/wp-content/uploads WP Uploads Path: /home/staticweb/wordpress/wp-content/uploads WP Uploads ??: /wp-content/uploads WP Site Path: /home/staticweb/wordpress/ WP Site Subdirectory: Uploads URL: https://twilight-dew-7735.staticweb.io/wp-content/uploads Site URL: https://twilight-dew-7735.staticweb.io Parent Theme URL: https://twilight-dew-7735.staticweb.io/wp-content/themes/twentytwenty Parent Theme Path: /home/staticweb/wordpress/wp-content/themes/twentytwenty Child Theme Path: /home/staticweb/wordpress/wp-content/themes/twentytwenty Child Theme Active: Theme Root Path: /home/staticweb/wordpress/wp-content/themes Themes ??: /wp-content/themes Active Theme ??: /wp-content/themes/twentytwenty WP Content URL: https://twilight-dew-7735.staticweb.io/wp-content WP Content Path: /home/staticweb/wordpress/wp-content WP Content ??: /home/staticweb/wordpress/wp-content Plugins Path: /home/staticweb/wordpress/wp-content/plugins WP Plugins ??: /wp-content/plugins WP Includes Path: /home/staticweb/wordpress/wp-includes Permalink Structure: /%postname%/ WP Inc Path: /wp-includes Subdirectory install?: 2020-12-06 10:52:24 Active plugins: ... 2020-12-06 10:52:24 cURL error:Failed to connect to twilight-dew-7735.staticweb.io port 443: Connection refused 2020-12-06 10:52:24 BAD RESPONSE STATUS (0): / 2020-12-06 10:52:24 cURL error:Could not resolve host: twilight-dew-7735.staticweb.io2020 2020-12-06 10:52:24 BAD RESPONSE STATUS (0): /2020/ ... 2020-12-06 10:52:25 cURL error:Could not resolve host: twilight-dew-7735.staticweb.iositemap.xml 2020-12-06 10:52:25 BAD RESPONSE STATUS (0): /sitemap.xml ```
crawl log ``` Pending / Note: initial_crawl_list Pending /2020/ Note: initial_crawl_list Pending /2020/06/ Note: initial_crawl_list Pending /2020/06/12/ Note: initial_crawl_list Pending /ads.txt Note: initial_crawl_list Pending /category/uncategorized/ Note: initial_crawl_list Pending /favicon.ico Note: initial_crawl_list Pending /hello-world/ Note: initial_crawl_list Pending /robots.txt Note: initial_crawl_list Pending /sample-page/ Note: initial_crawl_list Pending /sitemap.xml Note: initial_crawl_list ```
leonstafford commented 3 years ago

OK, so, looks like 6.6.21 should still be fine, so please use that attached one.

I'm going to do an unrelated PHP8 compatibility fix, but will do like I did with WP2Static last night and replace a lot of the current cURL request code with the Guzzle library to simplify things along the way.

I'll be testing against this issue as I go and hopefully have it sorted tonight (fingers crossed!). Else, I'll need to switch the DL version on statichtmloutput.com back to 6.6.21 if it will take me longer to fix this.

marcussacana commented 3 years ago

I tested the old version and really worked here.

leonstafford commented 3 years ago

Many thanks, @marcussacana and sorry for the breakage!

I reverted to 6.6.21 for download from website for now and will work on the fix tonight or by tomorrow.

I was making some sloppy mistakes for a while, with a few other personal/productivity issues happening, but last few days, have been getting back into my groove, so quality will tighten up!

marcussacana commented 3 years ago

No problem, we always have that moment when things get complicated in life.

joeldebruijn commented 3 years ago

Appreciate the effort, thnx!

joeldebruijn commented 3 years ago

Just new to this, but wondering if the same code is used in WP2Static as well? Tried that one first yesterday, but timed out. Switched to this plugin.

leonstafford commented 3 years ago

Regarding this issue, it shouldn't be the same code.

There is a small percentage of similar code left between the 2 plugins now, but majority differs quite a lot. That's why I decided to keep the 2 projects continuing separately, as the approaches differ quite a lot. There's a little talk on the forum about how they differ, but I can explain that in more length later once I catchup on where I want these plugins to be feature/quality-wise.

Please feel free to post any issues to that repo, too. There's some export logs available in WP2Staic, too (the ones in here are currently a little nicer 😄 ).

loganmarchione commented 3 years ago

@marcussacana, @joeldebruijn let me dive into this. Perhaps regression issue since last release. In meantime, if you can try this release 2 prior and let me know if that's better:

static-html-output-plugin-6.6.21.zip

I had the same issue missing the "/" character and the linked zip fixed it. Thanks!

joeldebruijn commented 3 years ago

Im on 6.6.21 and works like a charm! image

leonstafford commented 3 years ago

Thanks all for your patience as I play catch-up with quality control on these projects (working specifically on improvements in that area to speed things up and avoid any further regression bugs like this).

(Thanks also for the donations which are helping to keep my head above water! Got yours today, @loganmarchione, thanks! And yours, @joeldebruijn, thanks! Sorry if I missed anyone, but appreciate all!).

Thanks also for supporting each other here and in the forum, it's great to know y'all have got my back when I'm slow to respond!

I'm due for a recent development/life update on my Patreon blog soon. A lot of interesting things and some new supporting projects in development the past 2 weeks!