Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site crawl fails with Uncaught TypeError #866

Open
duanejevon opened this issue Apr 7, 2022 · 2 comments
Open

Site crawl fails with Uncaught TypeError #866

duanejevon opened this issue Apr 7, 2022 · 2 comments
Labels

Comments

@duanejevon
Copy link

Description

When running the Crawl process, the following error appears: PHP Fatal error: Uncaught TypeError: WP2Static\Crawler::WP2Static\{closure}(): Argument #1 ($reason) must be of type WP2StaticGuzzleHttp\Exception\RequestException

To Reproduce

  1. From bash, run: "sudo wp wp2static detect". This completes successfully.
  2. run "sudo wp wp2static crawl"
  3. Upon reaching a certain point, the error appears: PHP Fatal error: Uncaught TypeError: WP2Static\Crawler::WP2Static\{closure}(): Argument #1 ($reason) must be of type WP2StaticGuzzleHttp\Exception\RequestException
bitnami@ip-172-31-23-216:~$ sudo wp wp2static detect
[2022-04-07T10:26:28+00:00] Starting to detect WordPress site URLs.
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
PHP Warning:  Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
Warning: Attempt to read property "hierarchical" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 336
PHP Warning:  Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
Warning: Attempt to read property "query_var" on null in /opt/bitnami/wordpress/wp-includes/link-template.php on line 346
[2022-04-07T10:26:35+00:00] Detection complete. 6190 URLs added to Crawl Queue.

bitnami@ip-172-31-23-216:~$ sudo wp wp2static crawl
[2022-04-07T10:27:44+00:00] Starting crawling
[2022-04-07T10:27:44+00:00] Starting to crawl detected URLs.
[2022-04-07T10:27:44+00:00] Using CrawlCache.
[2022-04-07T10:27:52+00:00] 404 for URL /favicon.ico
[2022-04-07T10:27:54+00:00] 404 for URL /robots.txt
[2022-04-07T10:27:55+00:00] Crawling progress: 300 crawled, 0 skipped (cached).
[2022-04-07T10:27:56+00:00] Crawling progress: 600 crawled, 0 skipped (cached).
[2022-04-07T10:27:57+00:00] Crawling progress: 900 crawled, 0 skipped (cached).
[2022-04-07T10:27:58+00:00] Crawling progress: 1200 crawled, 0 skipped (cached).
[2022-04-07T10:27:59+00:00] Crawling progress: 1500 crawled, 0 skipped (cached).
[2022-04-07T10:28:00+00:00] Crawling progress: 1800 crawled, 0 skipped (cached).
[2022-04-07T10:28:01+00:00] Crawling progress: 2100 crawled, 0 skipped (cached).
[2022-04-07T10:28:03+00:00] Crawling progress: 2400 crawled, 0 skipped (cached).
[2022-04-07T10:28:04+00:00] Crawling progress: 2700 crawled, 0 skipped (cached).
[2022-04-07T10:28:05+00:00] Crawling progress: 3000 crawled, 0 skipped (cached).
[2022-04-07T10:28:06+00:00] Crawling progress: 3300 crawled, 0 skipped (cached).
[2022-04-07T10:28:07+00:00] Crawling progress: 3600 crawled, 0 skipped (cached).
[2022-04-07T10:28:08+00:00] Crawling progress: 3900 crawled, 0 skipped (cached).
[2022-04-07T10:28:09+00:00] Crawling progress: 4200 crawled, 0 skipped (cached).
PHP Fatal error:  Uncaught TypeError: WP2Static\Crawler::WP2Static\{closure}(): Argument #1 ($reason) must be of type WP2StaticGuzzleHttp\Exception\RequestException, WP2StaticGuzzleHttp\Exception\ConnectException given in /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php:234
Stack trace:
#0 [internal function]: WP2Static\Crawler->WP2Static\{closure}()
#1 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/EachPromise.php(191): call_user_func()
#2 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(204): WP2StaticGuzzleHttp\Promise\EachPromise->WP2StaticGuzzleHttp\Promise\{closure}()
#3 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(153): WP2StaticGuzzleHttp\Promise\Promise::callHandler()
#4 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/TaskQueue.php(48): WP2StaticGuzzleHttp\Promise\Promise::WP2StaticGuzzleHttp\Promise\{closure}()
#5 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlMultiHandler.php(158): WP2StaticGuzzleHttp\Promise\TaskQueue->run()
#6 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlMultiHandler.php(183): WP2StaticGuzzleHttp\Handler\CurlMultiHandler->tick()
#7 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(248): WP2StaticGuzzleHttp\Handler\CurlMultiHandler->execute()
#8 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(224): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitFn()
#9 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(269): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#10 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(226): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitList()
#11 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(62): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#12 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/EachPromise.php(115): WP2StaticGuzzleHttp\Promise\Promise->wait()
#13 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(248): WP2StaticGuzzleHttp\Promise\EachPromise->WP2StaticGuzzleHttp\Promise\{closure}()
#14 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(224): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitFn()
#15 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(62): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#16 /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php(245): WP2StaticGuzzleHttp\Promise\Promise->wait()
#17 /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php(95): WP2Static\Crawler->crawlSite()
#18 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(307): WP2Static\Crawler::wp2staticCrawl()
#19 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#20 /opt/bitnami/wordpress/wp-includes/plugin.php(474): WP_Hook->do_action()
#21 /bitnami/wordpress/wp-content/plugins/wp2static/src/Controller.php(809): do_action()
#22 /bitnami/wordpress/wp-content/plugins/wp2static/src/CLI.php(729): WP2Static\Controller::wp2staticCrawl()
#23 [internal function]: WP2Static\CLI->crawl()
#24 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#25 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#26 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#27 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(417): WP_CLI\Dispatcher\Subcommand->invoke()
#28 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(440): WP_CLI\Runner->run_command()
#29 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): WP_CLI\Runner->run_command_and_exit()
#30 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#31 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process()
#32 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#33 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/php/boot-phar.php(11): include('...')
#34 /opt/bitnami/wp-cli/bin/wp-cli.phar(4): include('...')
#35 {main}
  thrown in /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php on line 234
Fatal error: Uncaught TypeError: WP2Static\Crawler::WP2Static\{closure}(): Argument #1 ($reason) must be of type WP2StaticGuzzleHttp\Exception\RequestException, WP2StaticGuzzleHttp\Exception\ConnectException given in /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php:234
Stack trace:
#0 [internal function]: WP2Static\Crawler->WP2Static\{closure}()
#1 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/EachPromise.php(191): call_user_func()
#2 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(204): WP2StaticGuzzleHttp\Promise\EachPromise->WP2StaticGuzzleHttp\Promise\{closure}()
#3 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(153): WP2StaticGuzzleHttp\Promise\Promise::callHandler()
#4 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/TaskQueue.php(48): WP2StaticGuzzleHttp\Promise\Promise::WP2StaticGuzzleHttp\Promise\{closure}()
#5 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlMultiHandler.php(158): WP2StaticGuzzleHttp\Promise\TaskQueue->run()
#6 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticguzzle/src/Handler/CurlMultiHandler.php(183): WP2StaticGuzzleHttp\Handler\CurlMultiHandler->tick()
#7 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(248): WP2StaticGuzzleHttp\Handler\CurlMultiHandler->execute()
#8 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(224): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitFn()
#9 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(269): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#10 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(226): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitList()
#11 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(62): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#12 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/EachPromise.php(115): WP2StaticGuzzleHttp\Promise\Promise->wait()
#13 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(248): WP2StaticGuzzleHttp\Promise\EachPromise->WP2StaticGuzzleHttp\Promise\{closure}()
#14 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(224): WP2StaticGuzzleHttp\Promise\Promise->invokeWaitFn()
#15 /bitnami/wordpress/wp-content/plugins/wp2static/vendor/leonstafford/wp2staticpromises/src/Promise.php(62): WP2StaticGuzzleHttp\Promise\Promise->waitIfPending()
#16 /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php(245): WP2StaticGuzzleHttp\Promise\Promise->wait()
#17 /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php(95): WP2Static\Crawler->crawlSite()
#18 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(307): WP2Static\Crawler::wp2staticCrawl()
#19 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#20 /opt/bitnami/wordpress/wp-includes/plugin.php(474): WP_Hook->do_action()
#21 /bitnami/wordpress/wp-content/plugins/wp2static/src/Controller.php(809): do_action()
#22 /bitnami/wordpress/wp-content/plugins/wp2static/src/CLI.php(729): WP2Static\Controller::wp2staticCrawl()
#23 [internal function]: WP2Static\CLI->crawl()
#24 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#25 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#26 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#27 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(417): WP_CLI\Dispatcher\Subcommand->invoke()
#28 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(440): WP_CLI\Runner->run_command()
#29 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): WP_CLI\Runner->run_command_and_exit()
#30 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#31 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/bootstrap.php(78): WP_CLI\Bootstrap\LaunchRunner->process()
#32 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#33 phar:///opt/bitnami/wp-cli/bin/wp-cli.phar/php/boot-phar.php(11): include('...')
#34 /opt/bitnami/wp-cli/bin/wp-cli.phar(4): include('...')
#35 {main}
  thrown in /bitnami/wordpress/wp-content/plugins/wp2static/src/Crawler.php on line 234
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

Log files:

See attached
wp2static-logs.txt

Additional Context
Initial attempts (as shown in the logs) were made using the wp2static 7.1.7 version of the plugin. After experiencing a few bugs and googling them, i found that the latest version resolved these bugs. I composed and upgraded the plugin.

@joelw
Copy link

joelw commented Apr 27, 2022

Not knowing much about modern PHP, I found a way to fix this by removing the type hint entirely:

wp2static/src/Crawler.php:234

-                'rejected' => function ( RequestException $reason, $index ) use ( $urls ) {
+                'rejected' => function ( $reason, $index ) use ( $urls ) {

@jplandry908
Copy link

jplandry908 commented Sep 10, 2022

Hi @joelw. Your fix resolved the issue for me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants