Google_Client loaded even if already exists in codepath
-
I use various Google APIs in my codebase via the official Google Client. When I activated wp2yt today it threw the following fatal:
[02-Feb-2016 21:37:33 UTC] PHP Fatal error: Cannot redeclare class Google_Client in /srv/www/wp-content/plugins/wp2yt-uploader/inc/Google/Client.php on line 37
[02-Feb-2016 21:37:33 UTC] PHP Stack trace:
[02-Feb-2016 21:37:33 UTC] PHP 1. {main}() /srv/www/wp-admin/plugins.php:0
[02-Feb-2016 21:37:33 UTC] PHP 2. plugin_sandbox_scrape() /srv/www/wp-admin/plugins.php:164
[02-Feb-2016 21:37:33 UTC] PHP 3. include() /srv/www/wp-admin/includes/plugin.php:1964
[02-Feb-2016 13:37:33 America/Los_Angeles] CaughtError: /srv/www/wp-content/plugins/wp2yt-uploader/inc/Google/Client.php:37 -> Cannot redeclare class Google_ClientThe simple workaround:
if (!class_exists('Google_Client')) {
/** Require YouTube API Files */
require_once YT4WP_PATH.'inc/Google/Client.php';
}I believe this issue may explain possible interaction problems with other Google plugins.
- The topic ‘Google_Client loaded even if already exists in codepath’ is closed to new replies.