/** * Callback for a common operation for upgrade * * @param string $path File short path * @param boolean $isTestMode If in test mode * * @return void */ protected function deleteFileCallback($path, $isTestMode) { if ($isTestMode) { if (!\Includes\Utils\FileManager::isDirWriteable($this->manageFile($path, 'getDir'))) { $this->addFileErrorMessage('File\'s directory is not writable', $path, false); $this->wrongPermissions[] = $this->manageFile($path, 'getDir'); } } elseif ($this->manageFile($path, 'deleteFile')) { $this->addFileInfoMessage('File is deleted', $path, true); // Remove the parent directory if upgrade process removes all files in it $dir = dirname($path); if (\Includes\Utils\FileManager::isEmptyDir($dir)) { \Includes\Utils\FileManager::unlinkRecursive($dir); if (!\Includes\Utils\FileManager::isExists($dir)) { $this->addFileInfoMessage('Directory is deleted', $dir, true); } else { $this->addFileInfoMessage('Unable to delete directory', $dir, true); } } } else { $this->addFileErrorMessage('Unable to delete file', $path, true); } }