Mitigate cache-related patching errors (#2206)

* Adjustments to the patcher to reduce chances of errors

* Fixed spelling
This commit is contained in:
Belle Aerni authored and GitHub committed 2024-03-26 06:52:59 -07:00
1 parent a89fc342a7
commit ab176a4e38
2 files changed
+23 -6

No files matched your search

+14 -5
View File
@@ -247,19 +247,28 @@ class Update implements InjectionAwareInterface
throw new Exception('Failed to extract file, please check file and folder permissions. Further details are available in the error log.');
}
// Apply system patches and migrate configuration file.
// Create the update patcher
$patcher = new UpdatePatcher();
$patcher->setDi($this->di);
$patcher->applyCorePatches();
// Apply configuration file patches.
// Clear the cache folder to reduce chances of errors
try {
$filesystem = new Filesystem();
$filesystem->remove(PATH_CACHE);
$filesystem->mkdir(PATH_CACHE, 0755);
} catch (\Exception) {
// This step is rarely important, we can safely ignore an error here
}
// Now run the patches
$patcher->applyCorePatches();
$patcher->applyConfigPatches();
// Clear cache and remove install folder.
// Clear cache and remove the install folder.
try {
$filesystem = new Filesystem();
$filesystem->remove([PATH_CACHE, PATH_ROOT . '/install']);
$filesystem->mkdir(PATH_CACHE, 0777);
$filesystem->mkdir(PATH_CACHE, 0755);
} catch (IOException $e) {
error_log($e->getMessage());
+9 -1
View File
@@ -372,9 +372,12 @@ class UpdatePatcher implements InjectionAwareInterface
},
42 => function () {
// This patch will migrate previous currency exchange rate data provider settings to the new ones
// @see https://github.com/FOSSBilling/FOSSBilling/pull/2189
$ext_service = $this->di['mod_service']('extension');
$config = $ext_service->getConfig('mod_currency');
$pairs = $this->di['db']->getAssoc('SELECT `param`, `value` FROM setting');
$config = $ext_service->getConfig('mod_currency');
$config['ext'] = 'mod_currency'; // This should automatically be set, but some appear to be having cache issues that causes it to not be
// Migrate the old currency exchange rate sync settings
$key = $pairs['currencylayer'] ?? '';
@@ -399,6 +402,11 @@ class UpdatePatcher implements InjectionAwareInterface
return array_filter($patches, fn ($key) => $key > $patchLevel, ARRAY_FILTER_USE_KEY);
}
/**
* If we end up needing a newly introduced package during the update process, composer's autoloader won't have it until the next load.
* As a workaround, we can register AntLoader and point it at the Vendor folder which will then act as fallback to find the needed classes.
* This isn't particularly fast though as it'll scan the entire vendor, so only use it if we know a needed class is missing.
*/
private function registerFallbackAutoloader()
{
$loader = new \AntCMS\AntLoader([