Issues

ZF-11843: Zend_Http_UserAgent DEFAULT_PERSISTENT_STORAGE_ADAPTER invalid constant value causes a Fatal error

Issue Type: Bug Created: 2011-10-26T00:37:35.000+0000 Last Updated: 2011-10-27T18:25:56.000+0000 Status: Open Fix version(s): Reporter: Djordje Mandaric (dmandaric) Assignee: Business&Decision / Interakting (interakting) Tags: - Zend_Http_UserAgent

Related issues: Attachments:

Description

DEFAULT_PERSISTENT_STORAGE_ADAPTER constant is set to 'Session'.

Result:

After getting the user agent object from the bootstrap and making the getDevice() call, the following error is thrown:

Fatal error: Uncaught exception 'ExceptionInvalidSession' with message 'We didn't recognize either your username or password. Try again.'

Expected:

DEFAULT_PERSISTENT_STORAGE_ADAPTER constant is set to 'Zend_Http_UserAgent_Storage_Session' and device object is returned.

Comments

Posted by Djordje Mandaric (dmandaric) on 2011-10-26T00:51:13.000+0000

The issue can be circumvented by overriding the constant by passing in an array of options before making getDevice() call.

E.g:

$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); $userAgent = $bootstrap->getResource('useragent');

$userAgent->setOptions( array( 'storage' => array( 'adapter' => 'Zend_Http_UserAgent_Storage_Session' ) ) );

Posted by Djordje Mandaric (dmandaric) on 2011-10-26T00:54:02.000+0000

I am unable to find how to attach the following diff:

--- src/library/Zend/Http/UserAgent.php +++ src/library/Zend/Http/UserAgent.php @@ -44,7 +44,7 @@ /** * Default persitent storage adapter : Session or NonPersitent */ - const DEFAULT_PERSISTENT_STORAGE_ADAPTER = 'Session'; + const DEFAULT_PERSISTENT_STORAGE_ADAPTER = 'Zend_Http_UserAgent_Storage_Session';

 /**
  * 'desktop' by default if the sequence return false for each item

Posted by Adam Lundrigan (adamlundrigan) on 2011-10-27T18:25:56.000+0000

You can only attach patches to tickets if you've signed a Zend Framework developer CLA.

As for your problem, could you provide code to show how you are using Zend_Http_UserAgent? Specifically, where is the error being raised from:

<pre class="highlight">
Fatal error: Uncaught exception 'ExceptionInvalidSession' with message 'We didn't recognize either your
username or password. Try again.'

AFAIK, that isn't something that Zend Framework would raise/throw.

The default value for DEFAULT_PERSISTENT_STORAGE_ADAPTER is correct, as internally Zend_Http_UserAgent uses a plugin broker to automatically locate the storage adapter based upon that short name (ie: plugin broker prepends 'Zend_Http_UserAgent_Storage_' to that value to get the full class name and then attempts to autoload the class (from Zend/Http/UserAgent/Storage/Session.php))

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