Static WordPress Community

Crawling not working

Hi,

I have installed WP2Static on my local WP installation (MAMP on MacOS). I tried different ways to create the static pages but none of them work. I first tried with manually queuing the jobs and then surfing on the website / calling wp-cron.php

Didn’t work at all

Then I tried with WP-CLI like described in the docs

  1. wp wp2static detect which worked but detected URLS are not being stored in crawl cache
  2. wp wp2static crawl (not working)

I also tried wp wp2static process_queue which kind of worked but also neither crawled nor created the pages.

Do you have any idea? I am using latest Version 7.

@rkleinert if detect is not adding things to CrawlCache, that’s very suspicious.

Anything in your MAMP error logs? If you open PHPMyAdmin via MAMP, can you check the wp2static_urls (CrawlQueue) table that it exists and is empty?

@leonstafford
thanks for your reply.

No errors in log and wp2static_urls exists and is empty.

In Plugin logs I see

Detection complete. 19852 URLs added to Crawl Queue. But when I crawl, nothing happens.

One thing I noticed that I have some PHP notices on the command line:

    wp wp2static process_queue
    PHP Notice:  Undefined index: SERVER_NAME in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 28
    PHP Notice:  Constant WP_DEBUG already defined in phar:///usr/local/Cellar/wp-cli/2.4.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 42
     Processing 4 jobs
    PHP Notice:  Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    Notice: Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    PHP Notice:  Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    Notice: Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    PHP Notice:  Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    Notice: Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    PHP Notice:  Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    Notice: Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    PHP Notice:  Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    Notice: Trying to get property 'hierarchical' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 282
    PHP Notice:  Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    Notice: Trying to get property 'query_var' of non-object in /Users/robertkleinert/Projects/CMS/wp-includes/link-template.php on line 292
    PHP Notice:  Undefined index: SERVER_NAME in /Users/robertkleinert/Projects/CMS/wp-includes/pluggable.php on line 331
    Notice: Undefined index: SERVER_NAME in /Users/robertkleinert/Projects/CMS/wp-includes/pluggable.php on line 331
    Success: Done processing queue

Are these related to the plugin not working?

Thanks!

Thanks for including those @rkleinert.

It looks like 2 or 3 issues. The first, about SERVER_NAME being undefined is about how when running with WP_CLI, we’re not going through the webserver, so don’t see the SERVER_NAME variable defined. I need to check on the best way to recommend to do that. Oops, looks like I swept it under the rug last time I encountered it: https://github.com/WP2Static/wp2static/issues/230

I’ve seen suggestions of how to dynamically set that in wp-config.php when it’s not found, that may be worth a little searching and checking your own wp-config.php in case there’s any existing lines around it.

The WP_DEBUG already defined is a bit odd, maybe also double-check it’s not defined twice within your wp-config.php, else it’s probably being set somewhere else.

Those query related issues I have seen, IIRC, only when WooCommerce was installed - is that your case? It’s something off in the URL detection queries I need to get back to. They shouldn’t be blocking the URL detection/crawling at all, so I’d work on clearing the first 2 notices first. Maybe try disabling all other plugins and re-running, then turn on one by one to isolate if it appears to be coming from a plugin/theme.

Sorry this isn’t a very conclusive solution yet!

If you don’t get any luck, I can try to reproduce your setup on a Mac I have here.

I haven’t run into this issue with SERVER_NAME, but you can try something like this in wp-config.php:

if ( defined( 'WP_CLI' ) ) {
    $_SERVER['HTTP_HOST'] = 'localhost';
    $_SERVER['SERVER_NAME'] = 'localhost';
}

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');
3 Likes

Thanks @leonstafford and @john-shaffer.

I tried all hints. The Server and WP-Debug thing is solved. I also disabled all plugins and custom post types. Now when I run wp wp2static detect I am getting these link-template.php notes even more often. So not sure what it is. And I am still not getting any urls crawled or processed :frowning:

Hi @rkleinert, I’ve put a new GitHub issue to track this:

It may take a little while for me to get to it. If you’re able to help fast-track the isolation of the issue, could you please try a new, completely vanilla WP site within the same MAMP setup and confirm if you get these notices when WP2Static is the only installed plugin?

If that’s so, then if you can list out your plugins/theme that you have on the site showing the notices, I can more quickly reproduce and then fix the issue.

Cheers,

Leon

Hi @leonstafford,
on a fresh WP with same PHP version on MAMP it is working without any problems…

Please find plugins in attached screenshots

Thanks,

Robert

Bildschirmfoto 2020-06-16 um 10.18.10 Bildschirmfoto 2020-06-16 um 10.17.56 Bildschirmfoto 2020-06-16 um 10.17.45

@leonstafford ok now it’s getting weird.

i did detect via cli, got all these notices regarding link-template.php, then ran crawl and this time it seems to work…I didn’t change anything…

@rkleinert indeed - it’s an elusive issue, but hopefully will track it down once I’m back focused on v7/WP2Static (currently in hopefully final stages of V6/Static HTML Output updating).