ZF-8397: getEntry($anEntryLink) doesn't work after updateEntry($anotherEntryObject)
Description
Following code will throw 'Zend_Gdata_App_HttpException' exception with message 'Expected response code 200, got 412 Mismatch: etags =' ...
$client = Zend_Gdata_ClientLogin::getHttpClient('liz%40gmail.com', 'password', 'cp');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(2);
$firstEntryLink = 'http://google.com/m8/feeds/…';
$secondEntryLink = 'http://google.com/m8/feeds/…';
// Retrieve first entry
$firstEntry = $gdata->getEntry($firstEntryLink);
// Edit first entry and update
$firstEntry->setContent($gdata->newContent('Test content'));
$gdata->updateEntry($firstEntry);
// attempt to retrieve another entry will throw the exception
$secondEntry = $gdata->getEntry($secondEntryLink);
Google Api versions affected: 2,3 (version 1 does not support etags)
When $gdata->updateEntry() is called, 'If-Match' header with entry's current etag is set to the http client adapter. When $gdata->getEntry() is called afterwards http client's headers are reset with the following code:
// Make sure the HTTP client object is 'clean' before making a request
// In addition to standard headers to reset via resetParameters(),
// also reset the Slug header
$this->_httpClient->resetParameters();
$this->_httpClient->setHeaders('Slug', null);
Though, in fact it doesn't make the HTTP client clean and we should manually reset all headers we don't need:
// Make sure the HTTP client object is 'clean' before making a request
// In addition to standard headers to reset via resetParameters(),
// also reset the Slug and If-Match headers
$this->_httpClient->resetParameters();
$this->_httpClient->setHeaders(array('Slug', 'If-Match'));
Comments
Posted by Alexander Steshenko (lcf) on 2009-11-25T17:17:34.000+0000
Patch that resolves the issue
Posted by Trevor Johns (tjohns) on 2009-12-02T00:23:42.000+0000
Alexander, Thanks for the patch, looks good.
One quick request though before I commit this: Would you be able to write a unit test to go along with this? (We require that any new code has 100% test coverage, or as close to that as possible.)
Posted by Alexander Steshenko (lcf) on 2009-12-03T03:37:12.000+0000
Trevor, you are welcome. Unit test is attached.
Posted by Trevor Johns (tjohns) on 2009-12-07T16:04:55.000+0000
Thanks for the patch!
This has been committed and is fixed for the next mini release.
{quote} commit 301c97764025157007af3d42f95b5def81edc478 Author: tjohns <tjohns@44c647ce-9c0f-0410-b52a-842ac1e357ba> Date: Mon Dec 7 23:57:38 2009 +0000
{quote}
{quote} commit f593b29cd792093a13de4a8aba52886b01a4b0a1 Author: tjohns <tjohns@44c647ce-9c0f-0410-b52a-842ac1e357ba> Date: Tue Dec 8 00:00:51 2009 +0000
{quote}