-
Notifications
You must be signed in to change notification settings - Fork 33
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
geoip2 critical error (getWithPrefixLen) #439
Comments
Hey @ideenmacher, Thank you for opening the issue. Could you please tell me what version of PHP your server is using? Additionally, if you have any steps to reproduce the issue, that would be helpful. Thanks |
Hey @mostafasoufi, its PHP 7.4. Everything worked until i noticed this error message in the logs. I tried to upgrade the databases for geoip. i also disabled both country/city settings, i also downgraded the plugin again, but the error message stays the same. there is a second, slightly different error message which refers to the file /wp-statistics/includes/class-wp-statistics-user-online.php(155): WP_STATISTICS\GeoIP::getCountry() as a temporary solution: is there a way to disable the geoip functionality in the code by setting something to false or commenting something out? Thanks! |
You're correct, I've just fixed it on the development version, can you please test it? daf5b21 Cheers! |
Nice! So can i also upgrade to newest version and just replace your updated file? because development version is some commits behind. And you mean testing it with country/city option enabled or disabled? My current testing would be waiting a few hours and check the logs again. Because it only happens on some user visits i think, so i cant test it myself, or? Any faster idea? |
Let's replace all files since we made a couple of improvements on the previous commits.
The current situation. Also, there is no rush, let's wait and test with some real visitors. Thank you! |
Just to be sure, you mean the current development files oder the newest plugin release + your changed file? The best current situation would be, geoip enabled with city/country and no error. Can a disabled Online-User-Tracking option make a difference? |
Just download the development branch and then replace Its file on the server.
Yeah, you can easily disable it in Statistics → Settings → General |
i did download the dev and replaced it in the morning. but still the same error log, only the line numbers changed: CRITICAL Uncaught Error: Call to undefined method MaxMind\Db\Reader::getWithPrefixLen() in user tracking disabled, geoip country/city enabled. as Reader.php also throws an error log with "class-wp-statistics-user-online.php" i thought it might have something to do with user-online-tracking. but you will know better. tell me, what i can test or how i can assist you further. |
Weird indeed, please make sure the below files are available on your server:
If not, you can download it manually from https://github.com/wp-statistics/GeoLite2-Country and https://github.com/wp-statistics/GeoLite2-City |
the files are on the server and they are the latest. in the logfile at this folder (wp-content/uploads/wp-statistics/) i fount these two types of errors: 2023-08-13 10:55:00: The address 2606:54c0:1e00:b0::30:76 is not in the database. maybe the second one is important? Another question: Do i have to purge the Caching Plugin every time before i wait again? (i did so now) btw, thanks for your support! |
Thank you for testing and your effort. Your efforts are appreciated. You don't need to clear the cache. Let's do some Composer autoloading tests on the site. Do you have the Composer CLI installed on your server? If so, let's try running |
you're welcome. no, i don't. it's a hosting provider for that project, so limited possibilities. these error logs: Duplicate entry 'XX' for key 'page_id' are occurring 20-30 times at the same second with different ids. that might be something, or? what are the PHP version requirements of the plugin and the maxmind library? good news: when geoip options deactivated, after a few hours, there is no error in the logs now! (which is ok but the better solution would be if it works when enabled.) bad news: also i saw, that short statistic now shows 0 visitors/visits for today, which definitely is not correct. maybe the conditional functionality prevents the statistic hits to be triggered, when geoip options are disabled?) |
Not really.
Would be good to use PHP v7.4 ~ PHP v8.0
Wierd indeed, will review again. |
ok, im looking forward to what you will find out. any idea, when you will have time for it? @mostafasoufi |
We've look it on the issue till Monday and will get back to you soon. |
Based on the error, I suspect the host has a version of the |
Good point, I've updated |
@oschwald: thanks for helping us with this. any other idea? |
Sorry, I don't think I phrased my comment well. I was trying to say that the host likely has a very old version of the If this hypothesis is not correct, then I would assume some other WordPress plugin is loading a very old version of In terms of what WP Statistics could do to prevent users from hitting either of these issues, one solution would be to use a tool like PHP-Scoper to namespace all dependencies, preventing collisions with other plugins or installed extensions. This would have the disadvantage of users not getting the performance benefit of the C extension if it is installed. (I don't know how many lookups this plugin does so it is hard for me to say whether that would be a significant issue.) |
thanks again, @oschwald … the get_loaded_extensions() returns these ones, where i cant see your named extension at all: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, fileinfo, filter, ftp, gd, gettext, gmp, SPL, iconv, session, intl, json, mbstring, standard, mysqlnd, mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, imap, shmop, SimpleXML, soap, sodium, exif, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi as you say, it could also be another plugin (maybe like wordfence or woocommerce itself) that prevents something. i hope that the WP Statistic team will find a solution, otherwise i have to test and hopefully downgrade to an older, working plugin version for my setup. |
Hey @ideenmacher To investigate potential conflicts with plugins, we need precise information on the plugins and their versions installed on your website.
Overall, we have concluded that we should fix this issue with the PHP Scoper solution to ensure that we won't have any conflicts with other plugins in the future. @oschwald Thanks for providing the PHP Scoper solution. Yes, we also believe it's the best solution. We use this library in our other products, and it was in our plans to add it to WP Statistics in the future, but it seems like it's time to go ahead with it now. |
Hey @alifallahrn thanks for your support. If your team is done with the PHP Scoper implementation, let me know and i will test it. Maybe then it fixes the error and we dont have to check all plugins and stuff. Any idea, when you will have done this task? |
Soon! Let's mention the issue number |
cant wait to test it :) thanks guys @alifallahrn @mostafasoufi |
i just installed the new development version and i will wait a few hours, if the initial error is fixed. for now it looks good. @alifallahrn ––––––– BUT: in the first minutes i got a new error, which relates to the meta box in admin dashboard. it does not load "top countries" values. and the error message only occurs in the logs, if me as admin visiting the dashboard and the top countries meta box is checked (in the dashboard custom view settings). 2023-10-20T10:53:07+00:00 CRITICAL Uncaught Error: Call to undefined function WP_STATISTICS\MetaBox\wp_date() in …/wp-statistics/includes/admin/meta-box/wp-statistics-meta-box-abstract.php:79 ––––––– at the settings page (/wp-admin/admin.php?page=wps_countries_page) everything seems to be fine with the "top countries". |
Sounds good, thank you for testing! we'll review the error asap. @ideenmacher |
Btw, for testing, you need to build the plugin, but you need to install the PHP-Scoper globally in advance.
Then, build it.
|
do you mean me? i cant do this on my current hosting provider, i just need a ready .zip file. |
I'll send you the build version soon. |
ok, let me know. thanks. |
Update: Seems the build version has some issues, trying to fix it and will get back to you guys. |
Any Idea, how you or your team will have time for it @mostafasoufi? thanks! |
We had trouble organizing the classes, and some urgent tasks came up. I'll work on it and let you know once it's sorted. |
Ok, I understand. I'm looking forward to it. @mostafasoufi |
@mostafasoufi what are the chances that it will fit into your (or your teams) todo list soon? no pressure, just asking. |
Sorry for the late, can you please test this scoped version? https://www.dropbox.com/scl/fi/6kizt2g1osgo0f9oeo8dg/wp-statistics.zip?rlkey=lz12sgdzdz4zh86bn76vk625i&dl=0 |
getWithPrefixLen error still there after few days. also it has thrown this errors often: CRITICAL Uncaught Error: Class 'GeoIp2\Model\Country' not found in …/wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php:188 CRITICAL Uncaught Error: Class 'GeoIp2\Model\Country' not found in …/wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php:188 and this error i saw one time, so far: CRITICAL Uncaught Error: Call to undefined function WP_STATISTICS\MetaBox\wp_date() in …/wp-content/plugins/wp-statistics/includes/admin/meta-box/wp-statistics-meta-box-abstract.php:59 |
It seems a bit difficult to fix this, doesn't it? @mostafasoufi |
Resolving the issue is certainly possible, but it requires a considerable amount of time. This is because we need to test each part thoroughly upon completion, which extends the process somewhat. Therefore, we might need to address this with a bit of a delay and return to this issue later on. |
FYI: Good news, seems there is a new solution called Mozart which this plugin (Built version) used and seems to be good! We probably need to switch to Mozart instead of PhpScoper. |
@mostafasoufi thanks for your info. sounds good. any plans when you and your team could switch to this? looking forward to have this finally solved. thx |
I'll try to finish it next two weeks. @ideenmacher Best |
hope you are doing good? looking forward to the Mozart fix, whenever you have time for it @mostafasoufi |
Thank you for following up. Our team has been busy rolling out new features, such as Event and Author Tracking. We will promptly address the issue with our development team. |
Dear Team,
any idea why this error still can occur? I have the newest Update installed.
according to the logs it only happens every few hours, which may mean that some user (or bot) origins may not be detected correctly? how to solve this?
CRITICAL Uncaught Error: Call to undefined method MaxMind\Db\Reader::getWithPrefixLen() in … /plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php:246
Stack trace:
0 … /plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php(217): GeoIp2\Database\Reader->getRecord()
1 … /plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php(90): GeoIp2\Database\Reader->modelFor()
2 … /plugins/wp-statistics/includes/class-wp-statistics-geoip.php(183): GeoIp2\Database\Reader->country()
3 … /plugins/wp-statistics/includes/class-wp-statistics-exclusion.php(399): WP_STATISTICS\GeoIP::getCountry()
4 …/plugins/wp-statistics/includes/class-wp-statistics-exclusion.php(63): in … /plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Database/Reader.php in row 246
Thanks!
The text was updated successfully, but these errors were encountered: