Zend Framework

getEntry($anEntryLink) doesn't work after updateEntry($anotherEntryObject)

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6
  • Fix Version/s: 1.9.7
  • Component/s: Zend_Gdata
  • Labels:
    None

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://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/1a137ef0bd1517a';
$secondEntryLink = 'http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/9da88df0d0beac0';

// 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'));
  1. ZF-8379.test.patch
    03/Dec/09 3:37 AM
    3 kB
    Alexander Steshenko
  2. ZF-8397.patch
    25/Nov/09 5:17 PM
    2 kB
    Alexander Steshenko

Activity

Hide
Alexander Steshenko added a comment -

Patch that resolves the issue

Show
Alexander Steshenko added a comment - Patch that resolves the issue
Hide
Trevor Johns added a comment -

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.)

Show
Trevor Johns added a comment - 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.)
Hide
Alexander Steshenko added a comment -

Trevor, you are welcome.
Unit test is attached.

Show
Alexander Steshenko added a comment - Trevor, you are welcome. Unit test is attached.
Hide
Trevor Johns added a comment -

Thanks for the patch!

This has been committed and is fixed for the next mini release.

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: http://framework.zend.com/svn/framework/standard/trunk@19510 44c647ce-9c0f-0410-b52a-842ac1e357ba

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: http://framework.zend.com/svn/framework/standard/branches/release-1.9@19513 44c647ce-9c0f-0410-b52a-842ac1e357ba

Show
Trevor Johns added a comment - Thanks for the patch! This has been committed and is fixed for the next mini release.
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: http://framework.zend.com/svn/framework/standard/trunk@19510 44c647ce-9c0f-0410-b52a-842ac1e357ba
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: http://framework.zend.com/svn/framework/standard/branches/release-1.9@19513 44c647ce-9c0f-0410-b52a-842ac1e357ba

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: