public function run() { if (empty($this->state['files_to_delete'])) { return; } foreach ($this->state['files_to_delete'] as $file) { $file = SugarAutoLoader::normalizeFilePath($file); // If we're using a case-insensitive file-system and the // file is not present as we specified it, don't remove it. if ($this->upgrader->context['case_insensitive_fs'] && !in_array($file, glob("{$file}*"))) { continue; } $this->backupFile($file); $this->log("Removing {$file}"); if (is_dir($file)) { $this->removeDir($file); } else { $this->unlink($file); } } }
/** * Internal function used to merge extensions for a module from both core * and custom sources. * @param string $module_path Path to the module's directory. * @param string $ext_path Path for the extension used. * @param string $name Name of file to output to. * @param string $filter Filter for extension filename for languages. */ protected function mergeModuleFiles($module_path, $ext_path, $name, $filter) { if (stristr($ext_path, '__PH_SUBTYPE__')) { $this->mergeExtensionFiles($module_path); return; } else { if ($module_path == 'application') { $paths = array($ext_path); $cache_path = 'custom/application/' . $ext_path; } else { $paths = array($module_path . '/' . $ext_path); $cache_path = 'custom/' . $module_path . '/' . $ext_path; } $paths[] = 'custom/Extension' . '/' . $module_path . '/' . $ext_path; } $files = array(); foreach ($paths as $path) { if (is_dir($path)) { $dir = dir($path); while (false !== ($entry = $dir->read())) { if ($entry == '.' || $entry == '..') { continue; } $fullpath = SugarAutoLoader::normalizeFilePath("{$path}/{$entry}"); $filterCheck = empty($filter) || substr_count($entry, $filter) > 0; $isPHPFile = strtolower(substr($entry, -4)) == ".php"; if (is_file($fullpath) && $filterCheck && $isPHPFile) { $GLOBALS['log']->debug(__METHOD__ . ": found {$path}{$entry}"); $files[] = $fullpath; } } } } $this->cacheExtensionFiles($files, $cache_path . '/' . $name); }