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
  • Do you receive any error messages? Package scan should not allow an MLP with commands like unlink. You would, however, see an error message like the one here:

    Let me know what the experience is when you try to install. Are there any messages? does the installation task complete? etc

    Note: If you are installing into a cloud instance (or have Package Scan enabled), you cannot delete files via code. To have files removed, you can submit a case to Sugar Support with a list of files to be removed or request a package approval and provide your module loadable package.

  • I’m stuck trying to figure out what it is you are even trying to do – the first class looks like it would be better handled as an “extends”, and the last class doesn’t look like it has any way to actually interface the first class… unless you’re defining it as a global someplace I’m not seeing PrepaidGiftBalance

  • the issue, it seems, is that we are using "<base_path>" and it should be "<basepath>" without the underscore. I am in the process of updating all of the docs that have this wrong.

  • 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?

Reply
  • 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?

Children
No Data