After we make a migration from one machine to another, for the same instance, some of the configuration files doesnât work any more or they are not fully processed. In our case it is a custom vardef.php used in Custom/modules/Tasks.
The executed process was based on the following instructions:
We have extracted the DB and the file system to another machine, restored the DB, in the new machine, and executed a Quick Build and Repair.
Unfortunately the problem still exist.
Can anyone help us with this problem? Is there any configuration file that we should change to execute de Build and Repair, rather than config.php (that we change to point to the new DB location)?
The objective of this customization is to add the Reminder panel in Task views. After we have migrate and upgrade with fully success, We will share the process started on the following topic:
I donât know, but a couple of things people often overlook, and that you can check:
After a Quick Repair and Rebuild, scroll down to the bottom: if there is a button there to sync database to vardefs, press it.
There is a table in the database called fields_metadata which contains information about fields; when migrating the full DB, this is also be moved to new the instance. Check if that is whatâs intended - or if that is whatâs missing.
For those 4 references I should create an if clause to check if a custom file exists. is that right?
If I am right, another question comes to my mind: If I change those files, are those changes safe upgrade?
Another way that comes to my mind is the if we customize the controller, the one which calls the moduleâs model, and put it on the extension framework, does this closes the issue?
You donât need an if clause because the function get_custom_file_if_exists already does that (see the PR I linked).
If you change those files, those changes are not upgrade-safe, thatâs why I mentioned integrating those changes into the main product - that way they become upgrade-safe, and enable other users to do the same customizations.
If you can get the same results by extending a class and it gets picked up from the custom directory, then you donât need any other mechanism., correct.
I think this is not a good solution because we are replicating the same code for all the beans. Instead, if we had, like it has in case of extending a controller, a place to verify if a bean has a custom file or not, it would be much more efficient.
Exemple -> include/MVC/Controller/ControllerFactory.php
static function getController($module){
$class = ucfirst($module).âControllerâ;
$customClass = âCustomâ . $class;
if(file_exists(âcustom/modules/â.$module.â/controller.phpâ)){
$customClass = âCustomâ . $class;
require_once(âcustom/modules/â.$module.â/controller.phpâ);
if(class_exists($customClass)){
$controller = new $customClass();
}else if(class_exists($class)){
$controller = new $class();
}
}elseif(file_exists(âmodules/â.$module.â/controller.phpâ)){
require_once(âmodules/â.$module.â/controller.phpâ);
if(class_exists($customClass)){
$controller = new $customClass();
}else if(class_exists($class)){
$controller = new $class();
}
}else{
if(file_exists(âcustom/include/MVC/Controller/SugarController.phpâ)){
require_once(âcustom/include/MVC/Controller/SugarController.phpâ);
}
if(class_exists(âCustomSugarControllerâ)){
$controller = new CustomSugarController();
}else{
$controller = new SugarController();
}
}
//setup the controller
$controller->setup($module);
return $controller;
}
I think this should be the same logic for bean extend. I just not found the right place yet.
I donât have time now to consider any such big changes⌠youâre right, of course, that generic mechanisms are better, but I feel that if you really âdivedâ into this issue you would find 95% of such generic mechanisms are already in place.
What I can say is that whenever I find one specific file I canât customize in an upgrade-safe manner, I try to fix the way itâs being loaded. In your case, I would say you can simply try these changes:
That attitude is exactly what this project needs, I am with you on this one.
But I still think my changes are worth taking seriously, even if any other larger fix is attempted. So if you can please test them I would like to put them into the product anyway.
The reason I donât look at this as a âdirty hackâ is that there is a consistency here. Every part of the code already works like that. Sure, that means the mechanism is used in hundreds of places, yes, but they are already there, itâs almost done. And since itâs a key characteristic of the product, and one that every add-on and every customization relies on, itâs really not likely to change anytime soon.
Basically, as a convention, SuiteCRM is supposed to use get_custom_file_if_exists or a similar logic every time it ârequiresâ or âincludesâ something. We should keep striving to make that convention complete across the product, even if we then have other efforts to reduce code repetition (with all the problems it generates) by doing more generic fixes like you suggest.
Thanks for your contribution and your thoughts on this - I hope I defended my case, without attacking yours