Zend getParameters 不返回 url 路由中的内容 [英] Zend getParameters not returning what is in url route

查看:27
本文介绍了Zend getParameters 不返回 url 路由中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到 Zend 应用程序 API 的 iOS 应用程序.用户登录时,url和请求如下:

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

我们有用户电子邮件以及纬度和经度的地方.另外,我通过一个参数发送用户密码:

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

password=sha1password0123456789&

这些是我的路线:

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

这是控制器的代码:

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

所以,有时我会以 $data 的形式收到它(这没问题):

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)

我是否以正确的方式检索参数?它通过 POST 方法完成的事务,我想我正在运行 ZendFramework-1.11.11.

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.

AFAIK 这应该不是问题,但上次崩溃的位置与正常的请求不同:

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对比http://www.mydomain.com:82/user/login/user@gmail.com/40.636301/3.632206

推荐答案

我已经解决了这个问题,它是 memcached 的问题.我的应用程序当前与其他人共享同一个测试服务器,它似乎崩溃了,因为 Zend_Cache 缺少 cache_id_prefix 属性.

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.

AppPlugin.php 中添加以下行解决了问题:

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

此行强制所有从 APPLICATIONNAMEmemcached 的调用具有特定前缀,并防止位于同一服务器下的应用程序之间出现问题.

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

这篇关于Zend getParameters 不返回 url 路由中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆