This module is designed to help assist with repairing common issues in a Sugar instance. You should always test the repairs against a cloned enviroment before executing on a production instance. This tool is to be used at your own risk.
This repo is a module loadable package that can be installed to Sugar through the module loader. Once installed repairs can only be run from the command line. By default, all repairs are run in test mode. Test mode will not make any changes to your system and only output information on changes that will be made. To turn off test mode you will need to pass --test false
to the cli command.
When testing mode is off, the repair actions will backup any modified tables to <table name>_srm_<timestamp>
. Any files modified or created will have their contents store in a record under the Sugar Repairs module that you can access through the UI. All log messages will be output to your terminal window as well as stored in the Sugar log file. Any items noted as [Sugar Repairs][<cycle>][<action>][Change]
are information about file rewrites and database updates. Any items noted as [Sugar Repairs][<cycle>][<action>][Action]
will require a manual change to correct from a developer or administrator of the system.
- It is highly recommended to remove the Sugar Repairs module before upgrading.
- This package can not be installed to the Sugar On-Demand envrionment by customers as it will not pass package scanner and you will not have direct access to the command line. If you are experiencing an issue with your instance, please open a support ticket.
To build the installer package, you will need to download the contents on this repository and execute:
php build.php
Once completed, the installer .zip package will be located under ./builds/
.
Repairs will need to be run differently based on your environment and can only be executed from the command line.
For local instances and ION, you will need to change to the supp_SugarRepairs directory and run the cli.php directly.
cd "modules/supp_SugarRepairs/" && php cli.php --repair <action>
cd "modules/supp_SugarRepairs/" && php cli.php --repair <action> --test false
For mothership, you will need to change to the instances directory and run shadow-shell:
$options = array('repair' => '<action>');require_once("./modules/supp_SugarRepairs/cli.php");
$options = array('repair' => '<action>', 'test' => false);require_once("./modules/supp_SugarRepairs/cli.php");
Corrects common language file issues. The various issues addressed are shown below:
cd "modules/supp_SugarRepairs/" && php cli.php --repair lang
cd "modules/supp_SugarRepairs/" && php cli.php --repair lang --test false
-
Health Check Errors:
-
[Health Check Error: Bad vardefs - key] (https://support.sugarcrm.com/Knowledge_Base/Administration/Install/Troubleshooting_Health_Check_Output/Health_Check_Error_Bad_Vardefs_Key/)
-
[Health Check Error: Bad vardefs - multienum] (https://support.sugarcrm.com/Knowledge_Base/Administration/Install/Troubleshooting_Health_Check_Output/Health_Check_Error_Bad_Vardefs_Multienum/)
-
[Health Check Error: Found NULL values in moduleList strings] (https://support.sugarcrm.com/Knowledge_Base/Administration/Install/Troubleshooting_Health_Check_Output/Health_Check_Error_Found_NULL_Values_in_moduleList_Strings/)
-
-
Extra CR/LF issues If there are extra CR/LF characters between the lines of a language file they will be eliminated.
-
Replaces
$GLOBALS
in language files Any language string that is defined as global is rewritten in place. This assures that when duplicates are removed the correct value is left behind. The example being that$GLOBALS['app_list_strings']['key'] = array(…);
will be converted to$app_list_strings['key'] = array(…);
. -
Duplicate Keys If an array key appears more than once in any given language file, only the final one will be retained.
-
Redefined module list arrays If the entire module list array is redefined in the language file, it is then written to individual indexes rather than a redefined array. This prevents the system from having undefined modules and issues when deploying new modules through Module Builder.
$app_list_strings['moduleList'] = array(
'module1' => 'Module 1'
'module2' => 'Module 2'
);
is converted to:
$app_list_strings['moduleList']['module1'] = 'Module 1';
$app_list_strings['moduleList']['module2'] = 'Module 2';
- Flags Errors If a flag is thrown, manual intervention will be required. Scenarios that can throw flags are listed below:
- All language files are tested for syntax errors and are flagged if they don’t pass.
- Any custom logic hook that contains a modified language key will flagged for manual change.
-
Custom Vardef Files are Updated
- If there is a custom vardef that defines a default value for a field that contains a key that needs to be changed then the VarDef file is updated.
-
Other custom PHP files
- If a file contains a string of characters that matches a key that needs to be changed it will be flagged for possible Manual updating in the log.
-
Updates the database keys for enum/multienum fields when a correction is made.
-
Runs the vardef repair.
-
Runs the workflow repair.
-
Runs the report repair.
-
Runs the process author repairs
Corrects common issues with team sets.
cd "modules/supp_SugarRepairs/" && php cli.php --repair team
cd "modules/supp_SugarRepairs/" && php cli.php --repair team --test false
-
Duplicate teams in a team set
- Removes any duplicate team relationships to a team set.
-
Incorrect team counts on team sets
- Correct any team sets with invalid team counts and relationships.
Corrects common issues with workflows.
cd "modules/supp_SugarRepairs/" && php cli.php --repair workflow
cd "modules/supp_SugarRepairs/" && php cli.php --repair workflow --test false
- Workflows with invalid fields
- Disables any workflows with missing or invalid fields.
Corrects common issues with Process Author Definitions.
cd "modules/supp_SugarRepairs/" && php cli.php --repair processAuthor
cd "modules/supp_SugarRepairs/" && php cli.php --repair processAuthor --test false
- Event Criteria with invalid fields.
- Disables any Process Author Definition with criteria referencing missing or invalid fields.
- Works on Start, Wait, and Receive Message events.
- Activities and Actions with invalid fields.
- Disables any Process Author Definition with an activity or action referencing missing or invalid fields.
Corrects common issues with vardefs.
cd "modules/supp_SugarRepairs/" && php cli.php --repair vardef
cd "modules/supp_SugarRepairs/" && php cli.php --repair vardef --test false
-
Enum/Multienum fields with invalid default values.
- Attempts to find a valid default value key. If no value is found, field is left alone.
-
Enum/Multienum fields with invalid visibility gird.
- Attempts to find a valid key. If no key is found, the grid is removed.
Corrects common issues with reports.
cd "modules/supp_SugarRepairs/" && php cli.php --repair reports
cd "modules/supp_SugarRepairs/" && php cli.php --repair reports --test false
- If a report is using a deleted field, it will be marked as broken.
- If a field has a corrected language key, it will be updated.
- If a report is using an invalid language key, it will be marked as broken,
- If a report has a legacy Team Set definition (Bug 72483) in 7.x, it is converted to proper definition.
Corrects common issues with Email Addresses.
cd "modules/supp_SugarRepairs/" && php cli.php --repair emailAddresses
cd "modules/supp_SugarRepairs/" && php cli.php --repair emailAddresses --test false
- Bug 75588 - Any Bean that has at least one email address, and no primary designation will get the oldest email address updated to be the primary.
- Bug 77929 - Opting out from a campaigns does not update opt out email address.
Corrects common issues with Forecast Worksheets by rolling through the user "reports_to" hierarchy and re-commits forecasts in the proper order.
- timeperiod_id -- Required
- Provide the specific timeperiod id to run the commit on
- ALL can be passed to run for all timeperiods
cd "modules/supp_SugarRepairs/" && php cli.php --repair forecasts --timeperiod_id fd480109-081e-3c71-0941-56f032288e4f
cd "modules/supp_SugarRepairs/" && php cli.php --repair forecasts --timeperiod_id fd480109-081e-3c71-0941-56f032288e4f --test false
- Bug 75779 - Forecast worksheets totals are not accurate after making hierarchy changes.
Corrects common issues with metadata files for Sidecar.
cd "modules/supp_SugarRepairs/" && php cli.php --repair metadata
cd "modules/supp_SugarRepairs/" && php cli.php --repair metadata --test false
- Bug 77005 Modules created in 7.6.x, did not have Buttons definitions in RecordView, after upgrades to 7.7+ these modules would no longer have Change Log button. Places Change Log button, and default button definitions back on Record View if missing.
Everyone is welcome to be involved by creating or improving existing Sugar repairs. If you would like to contribute, please make sure to review the [CONTRIBUTOR TERMS](CONTRIBUTOR TERMS.pdf). When you update this README, please check out the contribution guidelines for helpful hints and tips that will make it easier to accept your pull request.
© 2016 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.