X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUpgrade%2FForm.php;h=76aa53a26fcb093d173673fded70a44709843a0d;hb=feaa3c58cb1b60d3400c94bb33e7d2f7875220bd;hp=d49776861cf04ff58087e71cced676e64f3f9c6f;hpb=b3cfe9a5fb94b1a15aab2ca4aaac8867d673c610;p=civicrm-core.git diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php index d49776861c..76aa53a26f 100644 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@ -567,6 +567,13 @@ SET version = '$version' 'reset' => TRUE, )); + $task = new CRM_Queue_Task( + array('CRM_Upgrade_Form', 'doFileCleanup'), + array($postUpgradeMessageFile), + "Cleanup old files" + ); + $queue->createItem($task); + $revisions = $upgrade->getRevisionSequence(); foreach ($revisions as $rev) { // proceed only if $currentVer < $rev @@ -603,6 +610,47 @@ SET version = '$version' return $queue; } + /** + * Find any old, orphaned files that should have been deleted. + * + * These files can get left behind, eg, if you use the Joomla + * upgrade procedure. + * + * The earlier we can do this, the better - don't want upgrade logic + * to inadvertently rely on old/relocated files. + * + * @param \CRM_Queue_TaskContext $ctx + * @param string $postUpgradeMessageFile + * @return bool + */ + public static function doFileCleanup(CRM_Queue_TaskContext $ctx, $postUpgradeMessageFile) { + $source = new CRM_Utils_Check_Component_Source(); + $files = $source->findOrphanedFiles(); + $errors = array(); + foreach ($files as $file) { + if (is_dir($file['path'])) { + @rmdir($file['path']); + } + else { + @unlink($file['path']); + } + + if (file_exists($file['path'])) { + $errors[] = sprintf("
  • %s
  • ", htmlentities($file['path'])); + } + } + + if (!empty($errors)) { + file_put_contents($postUpgradeMessageFile, + '

    ' . ts('Some old files could not be removed. Please remove them.') + . '', + FILE_APPEND + ); + } + + return TRUE; + } + /** * Perform an incremental version update. * @@ -720,9 +768,6 @@ SET version = '$version' // Rebuild all triggers and re-enable logging if needed $logging = new CRM_Logging_Schema(); $logging->fixSchemaDifferences(); - - //CRM-16257 update Config.IDS.ini might be an old copy - CRM_Core_IDS::createConfigFile(TRUE); } /**