Issues

ZF-8397: getEntry($anEntryLink) doesn't work after updateEntry($anotherEntryObject)

Issue Type: Bug Created: 2009-11-25T17:13:25.000+0000 Last Updated: 2009-12-07T16:04:55.000+0000 Status: Resolved Fix version(s): - 1.9.7 (11/Jan/10)

Reporter: Alexander Steshenko (lcf) Assignee: Trevor Johns (tjohns) Tags: - Zend_Gdata

Related issues: Attachments: - ZF-8379.test.patch

Description

Following code will throw 'Zend_Gdata_App_HttpException' exception with message 'Expected response code 200, got 412 Mismatch: etags =' ...

<pre class="highlight">
$client = Zend_Gdata_ClientLogin::getHttpClient('liz%40gmail.com', 'password', 'cp');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(2);

$firstEntryLink = '<a href="http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/1a137ef0bd1517a">http://google.com/m8/feeds/…</a>';
$secondEntryLink = '<a href="http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/9da88df0d0beac0">http://google.com/m8/feeds/…</a>';

// 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:

<pre class="highlight">
        // 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:

<pre class="highlight">
        // 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

ZF-8397: Make sure that any If-Match headers that are present are cleared after performing an HTTP request using Zend_Gdata_App.

This fixes a bug which prevented getEntry() from working after calling updateEntry().

Patch by: Alexander Steshenko (lcf)

git-svn-id: <a rel="nofollow" href="http://framework.zend.com/svn/framework/standard/trunk@19510">http://framework.zend.com/svn/framework/&hellip;</a> 44c647ce-9c0f-0410-b52a-842ac1e357ba

{quote}

{quote} commit f593b29cd792093a13de4a8aba52886b01a4b0a1 Author: tjohns tjohns@44c647ce-9c0f-0410-b52a-842ac1e357ba Date: Tue Dec 8 00:00:51 2009 +0000

Merge r19510 from trunk to release-1.9.

ZF-8397: Make sure that any If-Match headers that are present are cleared after performing an HTTP request using Zend_Gdata_App.

This fixes a bug which prevented getEntry() from working after calling updateEntry().

Patch by: Alexander Steshenko (lcf)

git-svn-id: <a rel="nofollow" href="http://framework.zend.com/svn/framework/standard/branches/release-1.9@19513">http://framework.zend.com/svn/framework/&hellip;</a> 44c647ce-9c0f-0410-b52a-842ac1e357ba

{quote}

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts