Zend getParameters not returning what is in url route

无人久伴 提交于 2020-01-07 02:44:05

问题


I have an iOS application that connects to a Zend application API. When the user is logging in, the url and requests are the following:

url http://www.mydomain.com:82/user/login/user@gmail.com/40.636518/3.632524 <NSMutableURLRequest http://www.mydomain.com:82/user/login/user@gmail.com/40.636518/3.632524>

Where we have user email and latitude and longitude. Also, I send the user password through a parameter:

password=sha1password0123456789&

These are my routes:

routes.userlogin.route = '/user/login/:email/:latitude/:longitude'  
routes.userlogin.defaults.controller = user  
routes.userlogin.defaults.action = login 

And this is the code of the controller:

...
$data = $this->getRequest()->getParams();
/* Here I print the $data object */
...

So, sometimes I'm receiving this as $data (this is OK):

Array(    
    [email] => user@gmail.com    
    [latitude] => 40.636518    
    [longitude] => 3.632524    
    [controller] => user    
    [action] => login    
    [password] => sha1password0123456789)

And some other times, I get this (this makes the login crash):

Array(    
    [controller] => user    
    [action] => login    
    [user@gmail.com] => 40.636301    
    [module] => default    
    [password] => sha1password0123456789)

Am I retrieving the parameters in the right way? The transaction it's done by POST method and I think I'm running ZendFramework-1.11.11.

EDIT: AFAIK this should not be a problem, but the location in the last crash was different from the request that went ok:

http://www.mydomain.com:82/user/login/user@gmail.com/40.636518/3.632524 vs http://www.mydomain.com:82/user/login/user@gmail.com/40.636301/3.632206


回答1:


I've solved the issue and it was a problem with memcached. My application is currently sharing the same test server with others and it seems that it was crashing because the Zend_Cache was lacking the cache_id_prefix attribute.

Adding the following line to the AppPlugin.php solved the problem:

$frontendOpts = array(
            'caching' => true,
            'lifetime' => 1800,
            'automatic_serialization' => true,
            'cache_id_prefix'=>'APPLICATIONNAME_' // This solved the problem
            );
....
$cache = Zend_Cache::factory('Core', 'Memcached', $frontendOpts, $backendOpts);

This line forces all the calls to memcachedfrom APPLICATIONNAME to have an specific prefix and prevents problems between applications living under the same server.



来源:https://stackoverflow.com/questions/12599606/zend-getparameters-not-returning-what-is-in-url-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!