Support » Plugin: Analyticator » Don't unconditionally load old Google SDK

  • Hi,

    This plugin, upon the WordPress ‘init’ action, always loads in the Google SDK – the line doing this is in class.analytics.stats.php:

    require_once ‘google-api-php-client/src/Google_Client.php’;_Client.php’;

    A consequence of this is that this plugin’s Google SDK is always loaded, on every page load (bad for performance); but a much worse consequence is that any other plugin, which also wants to use the Google SDK, will conflict, unless it’s using an internally compatible version. Google Analyticator’s version of the Google SDK is out-of-date, so, pretty much any plugin using a more up-to-date version will conflict (the chain of require() calls inside the Google SDK has been changed, and some class names have changed – so, attempts to use classes that are not in your version of the SDK fail (e.g. Google Drive API)).

    Example: UpdraftPlus (1.9.4) – http://downloads.wordpress.org/plugin/updraftplus.1.9.4.zip – if you activate both plugins at once, and try to do the Google authentication flow in UpdraftPlus, then you get a fatal error. The fatal error comes because the Drive API in UpdraftPlus’s copy of the Google SDK has an incompatible chain of require() calls that can’t be avoided without modifying the SDK internally.

    The conflict is avoided in UpdraftPlus 1.9.5 – http://downloads.wordpress.org/plugin/updraftplus.1.9.5.zip – because it contains code to unhook Google Analyticator’s ‘init’ action, if it detects that it’s not needed and is likely to conflict…. the following code gets called by UpdraftPlus upon plugins_loaded:

    if ((defined(‘DOING_CRON’) && DOING_CRON) || (isset($_GET[‘page’]) && $_GET[‘page’] == ‘updraftplus’)) remove_action(‘init’, ‘ganalyticator_stats_init’);

    That work-around is a bit of an ugly hack, though. Other plugins will have the same problem. The solution on your side would be to not load the Google SDK at all, until a Google API call is about to be made… and even better, also keep your version of the Google SDK up to date.

    Best wishes,
    David

    https://wordpress.org/plugins/google-analyticator/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Don't unconditionally load old Google SDK’ is closed to new replies.