AnsweredAssumed Answered

pre_execute.php ignored

Question asked by Nagy Zoltan on Mar 10, 2020
Latest reply on Mar 26, 2020 by Nagy Zoltan

Hello. I am trying to remove a custom module of ours from a 9.0.2 installation, called AG_AG_Version. I updated the code in the files using the module, that part is working. BUT, I also have to remove the module folder itself and a file generated by the module. I am using this as base: https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.0/Cookbook/Module_Loadable_Packages/R… 

 

This is the content of pre_execute.php:

echo "In pre_execute";
if (isset($this->installdefs['remove_files'])) {
foreach($this->installdefs['remove_files'] as $relpath){
if (SugarAutoloader::fileExists($relpath)) {
SugarAutoloader::unlink($relpath);
}
}
}
function deleteDir($dirPath) {
if (! is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
deleteDir($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}
echo "Deleting custom/modules/AG_AG_Versions";
deleteDir('custom/modules/AG_AG_Versions');
echo "Deleting modules/AG_AG_Versions";
deleteDir('modules/AG_AG_Versions')

 

The manifest.php's relevant part looks like this (inside installdefs array):

'pre_execute' => [
'<base_path>/Files/pre_execute.php'
],
'remove_files'=>[
'custom/modules/logic_hooks.php'
]

 

Any idea why those echo messages from pre_execute.php appears nowhere in the logs and .. nothing is deleted. Like the file is completly ignored.

Outcomes