SugarCRM SupportHelp ArticlesTroubleshootingTroubleshooting PCRE Issues

Troubleshooting PCRE Issues


Beginning with PCRE version 7.2, PCRE interprets /h as a horizontal whitespace character while prior to 7.2, it was interpreted as the letter "h". For more information regarding the /h character, please refer to the resources. Using PCRE versions prior to 7.2 may cause an issue where characters are not recognized properly. In addition, you may also encounter an error or unexpected behavior in Sugar® such as the page not loading properly due to AJAX or JavaScript errors. This article will go over some possible solutions in troubleshooting PCRE issues.


Upgrading PCRE to 7.2

If you are able to perform an upgrade on your server, the best fix is to upgrade your PCRE to 7.2 or above. You can check what version of PCRE you are running by navigating to the file in your web browser. For more information about PCRE and to obtain the appropriate upgrade file, please refer to

Note: Please create a backup of your file system before performing the upgrade.

Replacing /\h/ With [ \t]

If you are unable to perform an upgrade, you can try replacing /\h/ with [ \t] in ./jssource/Minifier.php as follows: 

diff -c Minifier.php.orig Minifier.php 
*** Minifier.php.orig 
--- Minifier.php 
*** 155,161 **** 

          $js = str_replace("\r\n", "\n", $js); 
          $this->input = str_replace("\r", "\n", $js); 
!         $this->input = preg_replace('/\h/u', ' ', $this->input); 
          $this->a = $this->getReal(); 
--- 155,161 ---- 

          $js = str_replace("\r\n", "\n", $js); 
          $this->input = str_replace("\r", "\n", $js); 
!         $this->input = preg_replace('/[ \t]/u', ' ', $this->input); 
          $this->a = $this->getReal();  

Cleaning Up

Once one of the above corrections has been performed, you will need to repair any invalid JavaScript files. This can be accomplished using one of the two methods shown below.

Creating a JavaScript Repair Script

To repair the files in your instance, you may choose to use Sugar's repair functionality. To accomplish this, we will create the file ./repairJavaScript.php. This file will contain our repair commands and will be run from the command line. It should have the following contents:


if (!defined('sugarEntry')) {
    define('sugarEntry', TRUE);


$from = getcwd();

$minifyUtils = new SugarMinifyUtils();
$minifyUtils->reverseScripts("$from/jssource/src_files", "$from");
$minifyUtils->BackUpAndCompressScriptFiles("$from", "", false);

 Once our file is in place, We will need to run the following commands:

cd <instance root>
php repairJavaScript.php
cd cache/ ; find . -name "*.js" -exec /bin/rm -f {} \;

Note: If you have moved your cache directory in the Sugar config, you will need to replace cache/ with the appropriate path.  

Replacing JavaScript Files from Another Instance

If you would like, you can also extract a clean instance of Sugar matching your exact product and version and run the following command to avoid a reinstall where <sugar clear root> is replaced by the root directory of the clean instance and <sugar dirty root> is replaced by the root directory of your instance with the invalid JavaScript files:

cd ../<sugar clean root> find . -name "*.js" -exec cp {} ../<sugar dirty root>/{} \;

Running this command will copy all of the JavaScript files from your clean, extracted instance over the corrupted JavaScript files. Next, we will need to make sure that we clean out the cached JavaScript so that Sugar can rebuild the file. From your Sugar root, you will need to run the following:

cd cache/ ; find . -name "*.js" -exec /bin/rm -f {} \;

Note: If you have moved your cache directory in the Sugar config, you will need to replace cache/ with the appropriate path. 

Last modified: 2020-01-31 16:57:04