views:

1295

answers:

1

Hey everyone,

I have looked up this error, and it seems the common issue is caused by not putting include()'s or require()'s BEFORE session_start().

However, this is not the case for me.

I am getting the following error:

Fatal error: Zend_Http_Client::request() [zend-http-client.request]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Zend_Http_Client_Adapter_Socket" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/content/b/e/h/behrk2/html/ZendGdata-1.8.4PL1/library/Zend/Http/Client.php on line 865

Any idea why?

Here are the three relevant files: login.php, members.php, and functions.php...

login.php:

 $newIncludePath = array();
 $newIncludePath[] = '../ZendGdata-1.8.4PL1/library';
 $newIncludePath = implode($newIncludePath);
 set_include_path($newIncludePath);

 // load classes
 require_once 'Zend/Loader.php';
 Zend_Loader::loadClass('Zend_Gdata');
 Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
 Zend_Loader::loadClass('Zend_Gdata_Calendar');
 Zend_Loader::loadClass('Zend_Http_Client');
 Zend_Loader::loadClass('Zend_Gdata_AuthSub');

 session_start();


 $serviceName = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name ('cl') for calendar
 $applicationName = 'yourCompany-yourAppName-v1';

 // Create an authenticated HTTP client
 $httpClient = Zend_Gdata_ClientLogin::getHttpClient('*****@gmail.com', '*****', $serviceName, null, $applicationName);
 $client = new Zend_Gdata_Calendar($httpClient, $applicationName); // Create an instance of the Calendar service

 $_SESSION['gdataCal'] = $client;

members.php:

 $newIncludePath = array();
 $newIncludePath[] = '../ZendGdata-1.8.4PL1/library';
 $newIncludePath = implode($newIncludePath);
 set_include_path($newIncludePath);

 // load classes
 require_once 'Zend/Loader.php';
 Zend_Loader::loadClass('Zend_Gdata');
 Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
 Zend_Loader::loadClass('Zend_Gdata_Calendar');
 Zend_Loader::loadClass('Zend_Http_Client');
 Zend_Loader::loadClass('Zend_Gdata_AuthSub');

 session_start();

 $g_url = add_gcal($_SESSION['gdataCal'], $_SESSION['title'].....etc.);

functions.php:

 <?php

 $newIncludePath = array();
 $newIncludePath[] = '../ZendGdata-1.8.4PL1/library';
 $newIncludePath = implode($newIncludePath);
 set_include_path($newIncludePath);

 // load classes
 require_once 'Zend/Loader.php';
 Zend_Loader::loadClass('Zend_Gdata');
 Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
 Zend_Loader::loadClass('Zend_Gdata_Calendar');
 Zend_Loader::loadClass('Zend_Http_Client');

session_start();

function add_gcal($gdataCal, $title....etc.){

try {

 $newEvent = $gdataCal->newEventEntry();

 $newEvent->title = $gdataCal->newTitle($title);
 $newEvent->where = array($gdataCal->newWhere($where));
 $newEvent->content = $gdataCal->newContent("$desc");

 $when = $gdataCal->newWhen();
 $when->startTime = $date;
 $when->endTime = $date; 
 $newEvent->when = array($when);

 $createdEvent = $gdataCal->insertEvent($newEvent);
 return $createdEvent->id->text;

  } catch (Zend_Gdata_App_Exception $e) {
  return NULL;
  }

}
+1  A: 

Hi,

You get this message :

Please ensure that the class definition "Zend_Http_Client_Adapter_Socket" of the object you are trying to operate on was loaded before unserialize() gets called

So, I suppose you have something in session (which means store in a serialized form) that is an instance of Zend_Http_Client_Adapter_Socket

So, before the session_start, you should load that class, using, for instance, something like this :

Zend_Loader::loadClass('Zend_Http_Client_Adapter_Socket');

This should solve this problem... But, as Zend Framework has lots of classes that rely on each others, you might run into another one...


A way to get rid of those errors for ever would be to use Zend Framework's autoloader : instead of locading classes yourself with Zend_Loader::loadClass, you could just register/activate the autoloader, and it will automatically load classes for you, whenever they are needed.

Of couse, that too would have to be done before the call to session_start :-)

For more informations about ZF's autoloader, you can take a look at this page of the manual.

Pascal MARTIN
that fixed it, thanks!
behrk2