ZF-11843: Zend_Http_UserAgent DEFAULT_PERSISTENT_STORAGE_ADAPTER invalid constant value causes a Fatal error
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';
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:
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))