Skip to content

EspoCRM – Open Source CRM Application

Upgrade script fixes

Taras Machyshyn059464e02b6f
diff --git a/upgrades/9.0/scripts/BeforeUpgrade.php b/upgrades/9.0/scripts/BeforeUpgrade.php
index e93c13c653..9d27268d97 100644
--- a/upgrades/9.0/scripts/BeforeUpgrade.php
+++ b/upgrades/9.0/scripts/BeforeUpgrade.php
@@ -64,8 +64,13 @@ class BeforeUpgrade
*/
private function checkBadClasses(array $badList): void
{
+ $skipPathRegexList = [
+ '^custom\/Espo\/Modules\/[^\/]+\/vendor',
+ '^application\/Espo\/Modules\/[^\/]+\/vendor',
+ ];
+
foreach (['custom', 'application/Espo/Modules'] as $dir) {
- $this->loadFromDir($dir);
+ $this->loadFromDir($dir, $skipPathRegexList);
}
$ignoreList = [
@@ -96,17 +101,34 @@ class BeforeUpgrade
}
}
- private function loadFromDir(string $dir): void
+ private function loadFromDir(string $dir, array $skipPathRegexList): void
{
$directory = new \RecursiveDirectoryIterator($dir);
$fullTree = new \RecursiveIteratorIterator($directory);
$phpFiles = new \RegexIterator($fullTree, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
- foreach ($phpFiles as $file) {
- require_once($file[0]);
+ foreach ($phpFiles as $path) {
+ $file = $path[0];
+
+ if ($this->isSkip($file, $skipPathRegexList)) {
+ continue;
+ }
+
+ require_once($file);
}
}
+ private function isSkip(string $file, array $skipPathRegexList): bool
+ {
+ foreach ($skipPathRegexList as $pattern) {
+ if (preg_match('/' . $pattern . '/', $file)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* @throws Error
*/