Hide Errors Hide Warnings

So this is just an informational post.

SugarCRM and SuiteCRM both recommend that you set the error reporting to off in your php.ini. For some of us who use shared hosting (HostGator in my situation) editing the php.ini is not a trivial task.

My solution to this is…

  1. Create a new include in the public_html/custom/include/generic directory (why this directory, I don’t know it just seems smart).
  2. Name it (I named it custom_include.php in case I wanted to use it for something else in the future).
  3. Inside put the following code (I realize we should’ve used a configuration variable, but I did’t go to the work).

<?
// Hide all errors from the user. - drew 9/17/2014
error_reporting(0);
  1. Find /public_html/include/MVC/preDispatch.php and add the following code at the bottom:

// Added by drew 9/17/2014 to include whatever, originally to set error reporting to 0.
include_once('custom/include/generic/custom_include.php');

Q. Is this upgrade proof?
A. I highly doubt it.

Q. Why did you put it in preDispatch.php
A. Because I saw it was included as a call in screens where I needed it, so I knew it would call my code.

Q. Is this really a good idea?
A. No, probably not… but I welcome feedback! It is probably better to set your php.ini if you have access. There are probably better ways to implement my solution… but for now it works :).

Q. What was the need for this?
A. I deployed a custom module that caused a bunch of warnings in the application and I couldn’t do anything to fix it because the warnings caused the application to not render correctly.

sieberta

1 Like

Hi Sieberta,

Thanks for the tip! This will work but as you pointed out isn’t upgrade safe. An alternative would be to create an ‘after_entry_point’ logic hook (docs here). Provided the logic hook is added in an upgrade safe manner this would provide an upgrade safe way of setting the error reporting ini values.

Thanks,
Jim

OK, I’m banging my head over this. Nothing I do will make the deprecated code warnings disappear.

Some posts hint that there is a cache where SuiteCRM actually caches PHP code, so changes I’m making might not even be taking effect. There seems to be no way to “flush the cache.” (And yes, I’ve restarted apache, and I’ve rebooted the server.)

Following the instructions about “logic hooks,” I did the following, which had NO EFFECT WHATSOEVER.

This seems to be a well-documented, long-standing problem (unwanted deprecated-code error messages displaying), suggesting that maybe the code base itself is simply not being updated? Should I abandon my attempts to evaluate SuiteCRM as a possible solution? If I paid for SugarCRM hosted on my server, would things be any different?


Added file: /custom/modules/logic_hooks_no_err_disp.php


<?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class logic_hooks_class { function after_entry_point_method($event, $arguments) { error_reporting(0); } } ?>

Original logic_hooks.php:


<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function $hook_array['after_ui_footer'] = Array(); $hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); $hook_array['after_ui_frame'] = Array(); $hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); $hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); $hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); $hook_array['after_delete'] = array(); $hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); $hook_array['after_restore'] = array(); $hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); ?>

Modified logic_hooks.php


<?php // Do not store anything in this file that is not part of the array or the hook version. This file will // be automatically rebuilt in the future. $hook_version = 1; $hook_array = Array(); // position, file, function $hook_array['after_ui_footer'] = Array(); $hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); $hook_array['after_ui_frame'] = Array(); $hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); $hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); $hook_array['after_save'] = Array(); $hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); $hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); $hook_array['after_delete'] = array(); $hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); $hook_array['after_restore'] = array(); $hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); $hook_array['after_entry_point'] = Array(); $hook_array['after_entry_point'][] = Array(1, 'after_entry_point no_err_disp','custom/modules/logic_hooks_no_err_disp.php', 'logic_hooks_class','after_entry_point_method'); ?>

I’d appreciate any guidance on this. It’s incredibly frustrating to try to evaluate a solution that constantly spurts out error messages.

I’ve also tried other solutions, including replacing the deprecated code, which also didn’t work.

Just to clarify, this is the error message that’s spurting all over the place:

1000ft Cables ext_rest_linkedin

Unknown Error (8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead occurred in /home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.php on line 268 [2015-08-25 17:45:48] display_stack_trace caller, file: /home/hesuitecrm/secure_html/crm/include/utils.php line#: 3254
L:
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.phpL:268
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1491
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1424
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1263
/home/hesuitecrm/secure_html/crm/include/connectors/formatters/default/formatter.phpL:109
/home/hesuitecrm/secure_html/crm/modules/Connectors/connectors/formatters/ext/rest/linkedin/linkedin.phpL:51
/home/hesuitecrm/secure_html/crm/include/connectors/utils/ConnectorHtmlHelper.phpL:79
/home/hesuitecrm/secure_html/crm/include/connectors/utils/ConnectorHtmlHelper.phpL:60
/home/hesuitecrm/secure_html/crm/include/connectors/utils/ConnectorUtils.phpL:769
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugarvar_connector.phpL:85
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%48^48B^48B4C33F%%DetailView.tpl.phpL:58
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:67
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:126
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:162
/home/hesuitecrm/secure_html/crm/include/SugarFields/SugarFieldHandler.phpL:151
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugar_field.phpL:104
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%24^248^248C46CA%%DetailView.tpl.phpL:243
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:115
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:274
/home/hesuitecrm/secure_html/crm/include/EditView/EditView2.phpL:741
/home/hesuitecrm/secure_html/crm/custom/modules/Accounts/views/view.detail.phpL:99
/home/hesuitecrm/secure_html/crm/include/MVC/View/SugarView.phpL:143
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:348
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:295
/home/hesuitecrm/secure_html/crm/include/MVC/SugarApplication.phpL:92
/home/hesuitecrm/secure_html/crm/index.phpL:50

Office Phone:

Unknown Error (8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead occurred in /home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.php on line 268 [2015-08-25 17:45:48] display_stack_trace caller, file: /home/hesuitecrm/secure_html/crm/include/utils.php line#: 3254
L:
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.phpL:268
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1491
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1424
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1263
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:67
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:126
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:162
/home/hesuitecrm/secure_html/crm/include/SugarFields/SugarFieldHandler.phpL:151
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugar_field.phpL:104
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%24^248^248C46CA%%DetailView.tpl.phpL:243
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:115
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:274
/home/hesuitecrm/secure_html/crm/include/EditView/EditView2.phpL:741
/home/hesuitecrm/secure_html/crm/custom/modules/Accounts/views/view.detail.phpL:99
/home/hesuitecrm/secure_html/crm/include/MVC/View/SugarView.phpL:143
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:348
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:295
/home/hesuitecrm/secure_html/crm/include/MVC/SugarApplication.phpL:92
/home/hesuitecrm/secure_html/crm/index.phpL:50

Website:

Unknown Error (8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead occurred in /home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.php on line 268 [2015-08-25 17:45:48] display_stack_trace caller, file: /home/hesuitecrm/secure_html/crm/include/utils.php line#: 3254
L:
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.phpL:268
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1491
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1424
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1263
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:67
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:126
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:162
/home/hesuitecrm/secure_html/crm/include/SugarFields/SugarFieldHandler.phpL:151
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugar_field.phpL:104
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%24^248^248C46CA%%DetailView.tpl.phpL:243
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:115
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:274
/home/hesuitecrm/secure_html/crm/include/EditView/EditView2.phpL:741
/home/hesuitecrm/secure_html/crm/custom/modules/Accounts/views/view.detail.phpL:99
/home/hesuitecrm/secure_html/crm/include/MVC/View/SugarView.phpL:143
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:348
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:295
/home/hesuitecrm/secure_html/crm/include/MVC/SugarApplication.phpL:92
/home/hesuitecrm/secure_html/crm/index.phpL:50

http:// Fax:
Email Address:

Unknown Error (8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead occurred in /home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.php on line 268 [2015-08-25 17:45:48] display_stack_trace caller, file: /home/hesuitecrm/secure_html/crm/include/utils.php line#: 3254
L:
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.phpL:268
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1491
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1424
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1263
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:67
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:266
/home/hesuitecrm/secure_html/crm/include/SugarFields/SugarFieldHandler.phpL:149
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugar_field.phpL:104
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%24^248^248C46CA%%DetailView.tpl.phpL:243
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:115
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:274
/home/hesuitecrm/secure_html/crm/include/EditView/EditView2.phpL:741
/home/hesuitecrm/secure_html/crm/custom/modules/Accounts/views/view.detail.phpL:99
/home/hesuitecrm/secure_html/crm/include/MVC/View/SugarView.phpL:143
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:348
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:295
/home/hesuitecrm/secure_html/crm/include/MVC/SugarApplication.phpL:92
/home/hesuitecrm/secure_html/crm/index.phpL:50

-none-
Billing Address:

Unknown Error (8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead occurred in /home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.php on line 268 [2015-08-25 17:45:48] display_stack_trace caller, file: /home/hesuitecrm/secure_html/crm/include/utils.php line#: 3254
L:
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty_Compiler.class.phpL:268
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1491
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1424
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1263
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Base/SugarFieldBase.phpL:67
/home/hesuitecrm/secure_html/crm/include/SugarFields/Fields/Address/SugarFieldAddress.phpL:86
/home/hesuitecrm/secure_html/crm/include/SugarFields/SugarFieldHandler.phpL:151
/home/hesuitecrm/secure_html/crm/include/Smarty/plugins/function.sugar_field.phpL:104
/home/hesuitecrm/secure_html/crm/cache/smarty/templates_c/%%24^248^248C46CA%%DetailView.tpl.phpL:243
/home/hesuitecrm/secure_html/crm/include/Smarty/Smarty.class.phpL:1265
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:115
/home/hesuitecrm/secure_html/crm/include/TemplateHandler/TemplateHandler.phpL:274
/home/hesuitecrm/secure_html/crm/include/EditView/EditView2.phpL:741
/home/hesuitecrm/secure_html/crm/custom/modules/Accounts/views/view.detail.phpL:99
/home/hesuitecrm/secure_html/crm/include/MVC/View/SugarView.phpL:143
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:348
/home/hesuitecrm/secure_html/crm/include/MVC/Controller/SugarController.phpL:295
/home/hesuitecrm/secure_html/crm/include/MVC/SugarApplication.phpL:92
/home/hesuitecrm/secure_html/crm/index.phpL:50

And now, for something completely different…

I ran repair in the admin tools and now the error messages are gone. (I did this earlier with no result.)

Fingers crossed.

When you do a quick repair and rebuild, it recreates several of the .php files to make sure everything is “included” correctly. Very important step after making code changes. I think you may have found your solution.

Step 1: Change the code to shut down error reporting.
Step 2: Quick Repair&Rebuild

Nice Job!
sieberta

1 Like

Hi,
The logic hook setup you have should do the trick. If you’re having trouble, and your looking at SuiteCRM just for evalutaion purposes you could add the line to the start of the index.php file as a quick fix.

As sierberta mentioned the Quick Repair and Rebuild link in admin will clear out the cache files and generated ext files.

Obviously I’m biased but any large software project is going to have notices, warnings e.t.c. This is something that we need to improve. However a production PHP instance should not have display errors turned on. I’ve posted before about ways to set display_errors: https://suitecrm.com/forum/installation-upgrade-help/5835-error-on-installation-of-suitecrm-on-wampserver#21222

Hope all this helps,
Jim

1 Like

Hi,
I know I’m late responding but I hope this would surely help someone else as well.

I also faced this issue and I just did one thing.
I set display_errors=Off in my xampp php.ini file. And all your warning and error will vanish.
Must restart your xampp server after this. Thanks