nirajpathak / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
0 stars 0 forks source link

Fatal error: Class name must be a valid object or a string in apiClient.php line 99 #175

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
public function __construct($config = array()) {
    global $apiConfig;
    $apiConfig = array_merge((array)$apiConfig, (array)$config);
  99  self::$cache = new $apiConfig['cacheClass']();
  100  self::$auth = new $apiConfig['authClass']();
  101  self::$io = new $apiConfig['ioClass']();
  }

Why is it giving such an error?

Original issue reported on code.google.com by samuel.o...@covenantuniversity.edu.ng on 16 Aug 2012 at 9:26

GoogleCodeExporter commented 8 years ago
I am getting the exact same error, but only on my production server, not on my 
development or staging server. All servers are running the same version of PHP.

Original comment by j...@qccreative.com on 22 Aug 2012 at 12:56

GoogleCodeExporter commented 8 years ago
Also $apiConfig contains NULL and I get a notice on line 98 for attempting to 
array_merge() a null value.

Original comment by j...@qccreative.com on 22 Aug 2012 at 12:58

GoogleCodeExporter commented 8 years ago
Have you made any changes to src/config.php? I was also wondering if you're 
using the latest version of the Google APIs PHP Client on trunk.

Original comment by chirags@google.com on 27 Aug 2012 at 8:56

GoogleCodeExporter commented 8 years ago

Original comment by ianbar...@google.com on 22 Mar 2013 at 3:15

GoogleCodeExporter commented 8 years ago
I get the exact same error and I'm using the latest version.

Original comment by cv.johan...@gmail.com on 1 Jul 2013 at 11:27

GoogleCodeExporter commented 8 years ago
I found a way to fix this bug.
Add this to line 108 in Google_Client.php:

    if (!isset($apiConfig)) {

        // hack around with the include paths a bit so the library 'just works'
        set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());

        require "config.php";

        // If a local configuration file is found, merge it's values with the default configuration
        if (file_exists(dirname(__FILE__)  . '/local_config.php')) {
            $defaultConfig = $apiConfig;
            require_once (dirname(__FILE__)  . '/local_config.php');
            $apiConfig = array_merge($defaultConfig, $apiConfig);
        }

    }

Somehow the global variable $apiConfig is cleared after one Google Api Request 
and with this code
the variable is set for every request rather than just the first one.

Original comment by cv.johan...@gmail.com on 1 Jul 2013 at 11:40

GoogleCodeExporter commented 8 years ago
Can you please help? I added the above code still this is not working.

Original comment by sudharsh...@gmail.com on 29 Dec 2014 at 11:55