Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.4
-
Fix Version/s: 1.8.1
-
Component/s: Zend_Gdata
-
Labels:None
Description
In short: If network connectivity is down after you got Zend_Gdata_Gapps service with valid authentication credentials, then the next Google request fails and throws a fatal error rather than a nice Zend exception.
That can happen e.g. in batch processing, when you use Zend_Gdata_Gapps over several actions, and suddenly your comms go down.
How to duplicate the problem:
<?php
set_include_path( get_include_path() . PATH_SEPARATOR . dirname(_FILE_). "/../library" );
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$client = Zend_Gdata_ClientLogin::getHttpClient("GOOGLE_SERVICE_EMAIL", "GOOGLE_SERVICE_PASS", Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
echo "\nAuthenticated ok. NOW DISCONNECT the network cable";
sleep( 20 );
$service = new Zend_Gdata_Gapps($client, "GOOGLE_DOMAIN");
$service->createUser(
'sleepy.smallelephant',
'Small Elephant', 'Sleepy', 'very secret password', null
);
?>
Trace:
Fatal error: Call to a member function getBody() on a non-object in /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/Gapps.php on line 151
Call Stack:
0.0051 239216 1. {main}() /Users/peterk/google.mytbwa.com/trunk/google_gateway/action/process.php:0
0.0901 3633944 2. process_action_set_status() /Users/peterk/google.mytbwa.com/trunk/google_gateway/action/process.php:745
0.0901 3634496 3. process_action() /Users/peterk/google.mytbwa.com/trunk/google_gateway/action/process.php:307
10.0916 3643920 4. Zend_Gdata_Gapps->retrieveUser() /Users/peterk/google.mytbwa.com/trunk/google_gateway/action/process.php:427
10.0952 3761512 5. Zend_Gdata_Gapps->getUserEntry() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/Gapps.php:754
10.0953 3761784 6. Zend_Gdata->getEntry() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/Gapps.php:465
10.0953 3762072 7. Zend_Gdata_App->getEntry() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata.php:186
10.0953 3762072 8. Zend_Gdata_App->importUrl() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/App.php:219
10.0953 3763024 9. Zend_Gdata_Gapps->get() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/App.php:718
10.1105 4222608 10. Zend_Gdata_Gapps::throwServiceExceptionIfDetected() /Users/peterk/google.mytbwa.com/trunk/google_gateway/library/Zend/Gdata/Gapps.php:205
Proposed solution:
In library/Zend/Gdata/Gapps.php modify throwServiceExceptionIfDetected($e) to use something like following:
$response= $e->getResponse();
if( $response ) {
$error = new Zend_Gdata_Gapps_ServiceException();
$error->importFromString( $response->getBody() );
//var_dump(debug_backtrace());
//debug_print_backtrace();
throw $error;
}
else {
throw new Exception( "Google connection is down or some other serious error." );
}
This is in version 1.7.4 but throwServiceExceptionIfDetected() is same in 1.7.6 so most likely there's the same problem in 1.7.6 and the fix should work for 1.7.6 too.
I've signed the contributor's agreement so it's OK for you to use any of the above. Thx
Patch sent to
Jochen Hartmann for review:
http://codereview.appspot.com/24079