Skip to content
New issue

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

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

Already on GitHub? # to your account

Error after replacing domain name #290

Open
JosKlever opened this issue Feb 21, 2025 · 2 comments
Open

Error after replacing domain name #290

JosKlever opened this issue Feb 21, 2025 · 2 comments

Comments

@JosKlever
Copy link

Today I had to change the domain name of a website, resulting in a path change causing an error in the endpoint.

PHP Warning:  require(/home/username/domains/domain.old/public_html/wp-content/plugins/koko-analytics/src/collect-functions.php): Failed to open stream: No such file or directory in /home/username/domains/domain.new/public_html/koko-analytics-collect.php on line 14

PHP Fatal error:  Uncaught Error: Failed opening required '/home/username/domains/domain.old/public_html/wp-content/plugins/koko-analytics/src/collect-functions.php' (include_path='.:/usr/local/php83/lib/php') in /home/username/domains/domain.new/public_html/koko-analytics-collect.php:14

Stack trace:
#0 {main}
  thrown in /home/username/domains/domain.new/public_html/koko-analytics-collect.php on line 14

So I went to Koko's settings and found a notification that the endpoint file didn't exist (but it did cause the error?!?) and I tried to create it by clicking the appropriate button. That didn't work. I refreshed the page and tried again and this time it worked.

There was no issue with disk space or permissions. So I hope this issue can be detected and automatically fixed. 😄

@dannyvankooten
Copy link
Member

Hi @JosKlever,

The plugin does a "health check" on the endpoint every hour to prevent exactly this kind of issue from occurring for too long. I am afraid I don't know of a way to fix it right away except for running the health check more often, but open to ideas here...

What happened is:

  • You changed path, so the "optimized endpoint file" became invalid and started throwing errors.
  • After a maximum of 1 hour, the plugin did its health check and noticed the optimized endpoint was no longer working. It then proceeded to remove it and reverted to the default endpoint.

I'll think of a way to improve this process or maybe even use relative paths in the optimized endpoint file...

@JosKlever
Copy link
Author

In this case it was still giving errors 8 hours after I changed the domain, so the recreation process didn't work. Only when I tried to recreate it myself if was solved at the second attempt.

There was not much traffic on the website, so could that be an issue in the automated check?

Would it be possible to check if the file exists before requiring it and if it doesn't exist trigger the creation?

This would be something similar to what Wordfence uses in the wordfence-waf.php:

// Before removing this file, please verify the PHP ini setting `auto_prepend_file` does not point to this.

if (file_exists(__DIR__.'/wp-content/plugins/wordfence/waf/bootstrap.php')) {
	define("WFWAF_LOG_PATH", __DIR__.'/wp-content/wflogs/');
	include_once __DIR__.'/wp-content/plugins/wordfence/waf/bootstrap.php';
}

This also uses relative paths, so a change of domain name or server path would not matter, but I'm not sure if that would work with Koko.

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

No branches or pull requests

2 participants