Zend_validate isValid() 卡住 fatalError 最大执行时间超过 30 秒 /library/Zend/Validate/Hostname.php 第 608 行

发布于 2024-11-28 12:20:07 字数 2013 浏览 1 评论 0 原文

我深受 Zend_validate 的困扰,每当我编写表单并尝试添加验证器时,如果我提交没有值的表单,唯一对我有用的东西,它会显示错误消息,但如果我提交好的值,它会卡住一段时间然后给出致命错误消息,说明 /Applications/MAMP/htdocs/MyApplicationFolderName/library/Zend/Validate/Hostname.php 在线超过了最大执行时间 30 秒608
请帮助我的控制器操作代码是

public function createAction()
  {
    // action body

    $roleService=new User_Service_RoleService($this->em);



    $userForm=new User_Form_UserForm($roleService->listAllRoleNames());
    $userForm->startForm();

    $userForm->setAction('create');
    $userForm->setMethod('post');



    if($this->getRequest()->isPost() )
    {
        if($userForm->isValid($this->getRequest()->getPost()))
        {
        $this->userAccountService->createUser($this->getRequest()->getParams());
        $this->_forward('confirm');
        }

    }





    $this->view->form=$userForm;



}

,我的表单类代码是

class User_Form_UserForm extends Zend_Form {
//put your code here

private $roles;

public function __construct($options = null) {
    parent::__construct($options);


    $this->roles=$options;


}


public function startForm()
{

    $idForm=new Zend_Form_Element_Hidden('id');
    $this->addElement($idForm);

     ///////////          
    $userEmailForm=new Zend_Form_Element_Text('email');
    $userEmailForm->setRequired(TRUE);
    $userEmailForm->setLabel('Email');

    $emailValidator=new Zend_Validate_EmailAddress();

   // $emailValidator->setOptions(array('domain' => FALSE));


    $userEmailForm->addValidator($emailValidator,false);

    $userEmailForm->setAttrib('size', 25);

    $userEmailForm->setFilters(array(new Zend_Filter_StringToLower(),
                                     new Zend_Filter_StringTrim())

                               );

    $this->addElement($userEmailForm);



}



 }

这是我表单的一小部分,它如此简单但不起作用我使用 MAMP PHP 5.3.5 因为 Doctrine2 和名称空间

请任何帮助将非常感激。

注意我还尝试了其他验证器,例如字符串长度,并且显示了相同的错误。

Iam suffering from Zend_validate ,when ever I write a form and try to add validators , the only thing that works for me if I submit the form with no values , it will show error msg , but if I submit good values it will stuck for sometime and then give fatal error msg saying Maximum execution time 30 seconds is exceeded in /Applications/MAMP/htdocs/MyApplicationFolderName/library/Zend/Validate/Hostname.php on line 608
Please help my controller action code is

public function createAction()
  {
    // action body

    $roleService=new User_Service_RoleService($this->em);



    $userForm=new User_Form_UserForm($roleService->listAllRoleNames());
    $userForm->startForm();

    $userForm->setAction('create');
    $userForm->setMethod('post');



    if($this->getRequest()->isPost() )
    {
        if($userForm->isValid($this->getRequest()->getPost()))
        {
        $this->userAccountService->createUser($this->getRequest()->getParams());
        $this->_forward('confirm');
        }

    }





    $this->view->form=$userForm;



}

and my form class code is

class User_Form_UserForm extends Zend_Form {
//put your code here

private $roles;

public function __construct($options = null) {
    parent::__construct($options);


    $this->roles=$options;


}


public function startForm()
{

    $idForm=new Zend_Form_Element_Hidden('id');
    $this->addElement($idForm);

     ///////////          
    $userEmailForm=new Zend_Form_Element_Text('email');
    $userEmailForm->setRequired(TRUE);
    $userEmailForm->setLabel('Email');

    $emailValidator=new Zend_Validate_EmailAddress();

   // $emailValidator->setOptions(array('domain' => FALSE));


    $userEmailForm->addValidator($emailValidator,false);

    $userEmailForm->setAttrib('size', 25);

    $userEmailForm->setFilters(array(new Zend_Filter_StringToLower(),
                                     new Zend_Filter_StringTrim())

                               );

    $this->addElement($userEmailForm);



}



 }

This is small part of my form its so simple but not working Iam using MAMP PHP 5.3.5 because of Doctrine2 and name spaces

Please any help will be really appreciated .

Note I also tried other validators like string length and the same error showed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2024-12-05 12:20:07

“实际上我刚刚找到了这个问题的答案:

随 MAMP 一起提供的 PHP 5.3 版本有一个错误
iconv_strlen() 会导致“do { ... } while (false);”循环中
验证器无限运行。我刚刚将 PHP 版本切换到 5.2,如下
无论如何,它更接近生产,并且有效。如果您需要 5.3,
不过,您必须升级 MAMP 中的 PHP 安装。我
还没有尝试过,但强烈推荐以下链接:

http://www.davidgolding.net/cakephp/upgrading- php-in-mamp.html

希望一切有帮助。”

来源:http://forum.mamp.info/viewtopic.php?f=2&t =12189

"I actually just found the answer to this one:

The version of PHP 5.3 that ships with MAMP has a bug in
iconv_strlen() that causes a "do { ... } while (false);" loop in the
validator to run infinitely. I just switched my PHP version to 5.2, as
it's closer to production anyway, and it works. If you need the 5.3,
though, you will have to upgrade your PHP installation in MAMP. I
haven't tried it, but the following link was highly recommended:

http://www.davidgolding.net/cakephp/upgrading-php-in-mamp.html

Hope that all helps."

Source: http://forum.mamp.info/viewtopic.php?f=2&t=12189

幸福%小乖 2024-12-05 12:20:07

我通过不使用 mamp 解决了这个问题,并开始使用 Zendserver CE 免费版 http: //www.zend.com/en/products/server-ce/downloads
,并完成此链接中描述的步骤 http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-xa-guide-for-the-terminal-timid/
我可以将 zend 服务器的根文档编辑到 USERS/sites/
我运行 Zendframework 验证,效果很好,我喜欢 mamp,但我在 Zend 上开发,zend 使用 iconv_strlen() ,

解决此问题的另一种方法是安装 PHP,但我发现这不是一个简单的解决方案,或者您可以使用 macports 和我不想走那条路,因为我使用 zendframework 我需要与之相关的东西,所以我使用 zendServer 这是迄今为止最干净的解决方案。

I worked out the problem by not using mamp , and start using Zendserver CE free Edition http://www.zend.com/en/products/server-ce/downloads
, and by going through the steps described on this link http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/
I could edit my root document for zend server to USERS/sites/
I run Zendframework validation and it worked nicely , I like mamp but I develope on Zend and zend use iconv_strlen() ,

the other way to solve this issue is by installing PHP but I found that not an easy solution , or you can use macports and I didnot want to go that way, since Iam using zendframework I needed something related to it so I used zendServer which is so far the cleanest solution .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文