为什么我会看到 CheckMX 已弃用警告? [英] Why am I seeing CheckMX deprecated warning?

查看:31
本文介绍了为什么我会看到 CheckMX 已弃用警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 symfony 的分析器中看到以下警告:

I am seeing the following warning in symfony's profiler:

用户已弃用:自 Symfony 4.2 起不推荐使用checkMX"选项.

User Deprecated: The "checkMX" option is deprecated since Symfony 4.2.

我想知道如何消除警告,谢谢.

I would like to know how to get rid of the warning, thanks.

我不清楚这是从哪里来的?在跟踪中,它指向我的存储库之一中的以下代码.

I am not clear where this is coming from? In the trace it points to the following code in one of my repositories.

    /**
     * @return Ride[] Returns an array of Ride objects
     */
    public function findRidesByYear($year)
    {
        return $this->createQueryBuilder('r')
            ->andWhere('r.date >= :year')
            ->setParameter('year', $year)
            ->orderBy('r.date', 'ASC')
            ->getQuery()
            ->getResult()
        ;
    }

具体来说,它突出显示了 getResult() 函数,如屏幕截图所示:

Specifically it is highlighting the getResult() function as shown in the screenshot:

推荐答案

这是在 Symfony 4.2 中针对 @Assert\Email 验证引入的弃用,您可能正在使用它.请参阅:https://symfony.com/doc/current/reference/constraints/Email.html#checkmx

This a deprecation that was introduced in Symfony 4.2 on the @Assert\Email validation, which you are probably using. See: https://symfony.com/doc/current/reference/constraints/Email.html#checkmx

文档中给出了弃用的原因:

The reason for the deprecation are given in the docs:

这个选项不可靠,因为它取决于网络条件,一些有效的服务器拒绝响应这些请求.

This option is not reliable because it depends on the network conditions and some valid servers refuse to respond to those requests.

您可以通过从断言使用中删除选项来修复弃用,例如在你的实体中.相反,您可以使用 strict 选项,该选项使用不同的库 egulias/email-validator 对电子邮件地址执行严格验证.

You can fix the deprecation by removing the option from the assertion usage, e.g. in your entities. Instead you can use the strict option that uses a different library egulias/email-validator to perform a strict validation for the email address.

这篇关于为什么我会看到 CheckMX 已弃用警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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