duanbicheng3345 2019-08-09 11:43
浏览 28

我们如何限制管理员以外的用户查看所有php错误?

We have errors showing up in some pages. These errors must be shown only for admin users.

I changed the "Error message to display" as none. Still the errors are showing up. I copied status-messages.html.twig to my theme and tried to give is_admin. That is giving me error. Any help would be appreciated.

{% block messages %} 
  {% if message_list is not empty %} 
    {{ attach_library('bartik/messages') }} 
    <div class="messages__wrapper layout-container"> 
      {{ parent() }} 
    </div> 
  {% endif %} 
{% endblock messages %} 
  • 写回答

1条回答 默认 最新

  • douleng3463 2019-08-09 13:49
    关注

    Error display should only be enabled on a development copy of the website. Even if you hide errors from displaying for some users, there is a good chance the errors can be accessed somewhere from within developer tools (and can pose a huge security risk.) So, the option to disable error display is not available by default 'per user', because the standard pattern is to:

    1. Disable showing errors on production site (under Configuration > Logging and Errors.) Review error logs to gain insight into failures.
    2. On your local / dev environment, add the following to sites/default/settings.local.php to have error showing enabled in that environment

    $config['system.logging']['error_level'] = 'verbose';

    This way, when you import your installation into dev from live, error display will be enabled by default without any tinkering. A "set-it and forget it" config.

    A good article on the subject, with details on debugging Twig properly can be found at https://www.drupixels.com/blog/enable-drupal-8-debugging-mode-and-error-reporting-local-development.

    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助