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

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' ) ) );

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

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:


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