ZF-9264: Running Gapps class's suspend() or restore() on non-existing accounts results in fatal error

Description

When the suspend() or restore() method in Zend_Gdata_Gapps is run on a non-existing user, a fatal error is thrown.

Test code:

$domain = 'gsatech.com.sg'; $username = "admin_account@$domain"; $password = 'password';

$client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); $gapps = new Zend_Gdata_Gapps($client, $domain);

$nonExistingUser = 'nobodynobody'; $gapps->suspendUser($nonExistingUser);

The above will result in the error:

Fatal error: Call to undefined method stdClass::save() in /home/cheeze/public_html/jotterlab/library/Zend/Gdata/Gapps.php on line 788

A similar problem exists for restoreUser().

A better solution is to throw an exception. The following lines:

if ($user === null) { throw new Zend_Gdata_Gapps_ServiceException(); }

can be placed right after the calling of retrieveUser() in both the functions.

Comments

The attached file is the diff output from svn diff

Fixed by r22511.