pre_execute.php ignored

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.

Parents Reply Children
  • I have corrected base_path into basepath and now something odd happens (most likely unrelated). If I use the silent upgrader .. nothing happens, it is ignored. If I zip the EXACT same package into, without any codechange what so ever and I use the UI and the module loader to install it.. IT WORKS. Do you have any idea why the silent upgrader ignores pre_execute?

  • Do you have any input on my issue? The one described above, package works with module loader from the UI but does not execute pre or post_execute.php if I use command line upgrader. Thanks

  • UPDATE: I have managed to make it work. The module is deleted, all good. I had to manually invoke quick repair in the script, and make it post_execute. Now I have only one small problem: THERE is a leftover somewhere. Meaning if I input #AG_AG_Versions in the addressbar, it loads.. something with a create button and the listview displays "Loading..." forever. If I hit create there is no layout (no fields) but a save button. If I try to save, of course I get a 404 error in the log. I triple checked (even using grep -R) there is no AG_AG_Versions folder in the file system... except this:

    cache/javascript/base/components_6918d1a0a50f1fdc0de67d1bad0d7143.js

    Where is this coming from? I checked fields_meta_data, tag_real_bean in mysql, nothing. Where to look for the leftover reference?