Support

Admin Tools

#26120 Admintools GeoIP plugin conflict

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by Stuckshutter on Wednesday, 21 September 2016 09:50 CDT

Stuckshutter
 I rely on Admintools to help keep the "vermin" out of my sites and block certain countries who are really problematic. I recently installed Corejoomla's Community Surveys component and ran into a problem with it.

We added the bcmath php library to the php version which it required.
But we were getting an error "Call to undefined function MaxMind\Db\Reader\bcadd()"

The developer looked into it and got back to us with this information:
"This turns out to be the issu created by AkeebaBackup plugin System - Akeeba GeoIP provider plugin . When the plugin is enabled, it is overriding the MaxMind library of its own, but that has faulty implementation. Disabling this plugin solves the issue but will also disable geoip capability of your akeebabackup. Please ask its developer."

Can you provide any help or suggestions on how to resolve this issue?

Thanks for any help, much appreciated.

Stuck

tampe125
Akeeba Staff
Hello James,

we included our custom function only if the function bcadd() is not defined on your server.
Usually with the error there's a line number and file, can you please post them?

Davide Tampellini

Developer and Support Staff

🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Stuckshutter
Thanks for the help but are still stumped. There is no line number or file associated with the error.

We asked Corejoomla, the developers if they used any direct php calls and said this is the call they use to load the maxmimd database:
$reader = new GeoIp2\Database\Reader(JPATH_ROOT.'/media/com_cjlib/geoip/GeoLite2-City.mmdb');

To be sure nothing in Admin tools was blocking access, we went into the .htaccess maker and allowed direct access to media/com_cjlib/geoip/GeoLite2-City.mmdb and the .gz version of it just for kicks.

It still behaves the same way.

I've disabled the survey component for now pending finding out if you have any suggestions we could look at. Corejoomla has stopped responding. If you do not have any further suggestions, I'll just remove this and go for a different solution.

Thank you in advance for any assistance you can provide.

nicholas
Akeeba Staff
Manager
Unfortunately Corejoomla doesn't know what they are talking about.

Like us, they are also using the third party MaxMind GeoIP API library. We are both using the same third party code. As a result their argument that our implementation is buggy is invalid by definition.

However, we DO work around an issue with the requirements of that library (bcmath) that they do not.

The MaxMind library has a requirement on the bcmath PHP library. As we found out a long time ago, some servers do not have the bcmath library enabled by default. On servers using PHP 5.x this simply results in a PHP fatal error saying that bcadd doesn't exist. PHP 7, when confronted with a function name it cannot find, tries to find said function in the current namespace. The file in question is the maxmind-dp/reader/src/MaxMind/Db/Reader/Decoder.php file with the MaxMind\Db\Reader namespace. Therefore PHP 7 is now looking for the MaxMind\Db\Reader\bcadd function which, of course, doesn't exist therefore throwing the confusing error message. Any developer who's used PHP 7 should be able to understand this issue and figure otu that the problem is with the server environment, not someone else's code.

This is an issue that we do work around. When you are loading our copy of the library –through the Akeeba GeoIP provide plugin– we run a check to see if bcmath is enabled. This check happens as soon as Joomla loads our plugin, namely in plugins/system/akgeoip/akgeoip.php lines 26 to 29. If bcmath's functions are not available we load our plugins/system/akgeoip/fakebcmath.php file which implements the missing bcmath functions using pure PHP code. This is why using our plugin always works. We detect if your server is missing a MaxMind library requirement and work around it using custom code.

The problem you have is that you are not actually loading the bcmath library and the plugin from Corejoomla is loaded before our plugin. So their plugin tries to access the MaxMind API library which crashes because it cannot find the bcmath extension. If you load our GeoIP plugin first –meaning that it will register the workaround for the missing bcmath functions– you'll see that Corejoomla's code is "magically" fixed. So, the first thing you should do is change the order of the plugins so our GeoIP plugin loads first.

However, the actual issue is that the bcmath library is not really enabled for your version of PHP. Remember that installing the bcmatch library is not enough. It has to be enabled in the php.ini as well. Furthermore, you need to restart the FastCGI and the web server (Apache, NginX, ...) for the changes to have any effect. This is due to the fact that FastCGI has already created a bunch of PHP processes using the old php.ini. Restarting both, FastCGI first, web server second, is the way to do it.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Stuckshutter
Hi Nicholas,
Thank you very much for such an in depth and helpful response. Moving the plugin did the trick. Your expertise and know how is worth the price of the subscription to your great components... even with out the components!
Your help should be the standard that all Joomla developers aspire to.
This one is now 'Fixed".
Thanks you again.
"Un-Stuck"

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!