• Hi again,

    In my ongoing quest to stamp out bugs revealed by PHP 8.0, I found that an included file with Google Analyticator has the wrong order for the implode() function.

    The file is google-api-php-client/src/io/Google_REST.php, and, on line 123, we have:
    $requestUrl .= '?' . implode($queryVars, '&');
    Now this used to be an acceptable syntax, but it became deprecated with PHP 7.4 (throws a warning) and finally removed under PHP 8.0 (throws a fatal error). The correct way of writing this line is:
    $requestUrl .= '?' . implode('&', $queryVars);
    I understand that this bit of code is actually inside an included library, originally developed by Google itself… in 2010 (!), when PHP 5.2 was still in use (!!!).

    Indeed, the page for that library has been archived, and it continues to be maintained by Google in GitHub instead. While Google considers them ‘official’ (in the sense that they are kept up-to-date regarding their current services), the feature set is ‘frozen’ and doesn’t get any further updates. On the other hand, they do some maintenance (bug fixes, addressing security issues, removing obsolete/deprecated code, etc.(, in particular, the library is fully compatible with PHP 8.0. I’ve even checked the very same line on the source code, and, aye, the parameter order for implode() is indeed correctly written: https://github.com/googleapis/google-api-php-client/blob/fa3641c1a6e3e8832d70e70e93b42327c4efab78/src/Service/Resource.php#L303

    Google uses this library for Site Kit, their official plugin for WordPress. People seem to either love it or hate it, so there is still some place for Google Analyticator to ‘compete’ directly with Google. Since you already use their API libraries, all you need to do is to update them! ??

  • The topic ‘Another deprecation issue: implode() with reverse use of parameters’ is closed to new replies.