mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
CoreImage: Ignore old plugins and themes
Otherwise, the admin may be confused by why File Inspector wants their no-longer-core plugins and themes to be deleted.
This commit is contained in:
29
.github/workflows/build-release/CoreImage.php
vendored
29
.github/workflows/build-release/CoreImage.php
vendored
@@ -14,6 +14,12 @@ abstract class CoreImage
|
|||||||
'robots.txt'
|
'robots.txt'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const EXCLUDED_PATHS_REMOVED = [
|
||||||
|
...self::EXCLUDED_PATHS,
|
||||||
|
'e107_plugins/',
|
||||||
|
'e107_themes/',
|
||||||
|
];
|
||||||
|
|
||||||
protected function create_image($exportFolder, $tempFolder, $currentVersion)
|
protected function create_image($exportFolder, $tempFolder, $currentVersion)
|
||||||
{
|
{
|
||||||
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
|
||||||
@@ -39,7 +45,7 @@ abstract class CoreImage
|
|||||||
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
|
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
|
||||||
|
|
||||||
if (empty($relativePath) || $relativePath == $absolutePath) continue;
|
if (empty($relativePath) || $relativePath == $absolutePath) continue;
|
||||||
if ($this->isExcluded($relativePath)) continue;
|
if ($this->isExcluded($relativePath, self::EXCLUDED_PATHS)) continue;
|
||||||
|
|
||||||
$checksum = $this->checksumPath($absolutePath);
|
$checksum = $this->checksumPath($absolutePath);
|
||||||
$this->insertChecksumIntoDatabase($relativePath, $checksum, $currentVersion);
|
$this->insertChecksumIntoDatabase($relativePath, $checksum, $currentVersion);
|
||||||
@@ -114,7 +120,6 @@ abstract class CoreImage
|
|||||||
/**
|
/**
|
||||||
* @param array $tags
|
* @param array $tags
|
||||||
* @param $timeMachineFolder
|
* @param $timeMachineFolder
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
protected function generateRemovedChecksumsFromTags($tags, $timeMachineFolder)
|
protected function generateRemovedChecksumsFromTags($tags, $timeMachineFolder)
|
||||||
{
|
{
|
||||||
@@ -132,7 +137,7 @@ abstract class CoreImage
|
|||||||
);
|
);
|
||||||
foreach ($removedFiles as $removedFilePath)
|
foreach ($removedFiles as $removedFilePath)
|
||||||
{
|
{
|
||||||
if ($this->isExcluded($removedFilePath)) continue;
|
if ($this->isExcluded($removedFilePath, self::EXCLUDED_PATHS_REMOVED)) continue;
|
||||||
|
|
||||||
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
|
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
|
||||||
$this->insertChecksumIntoDatabase($removedFilePath, $checksum, $version);
|
$this->insertChecksumIntoDatabase($removedFilePath, $checksum, $version);
|
||||||
@@ -168,11 +173,23 @@ abstract class CoreImage
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the provided relative path should make it into the generated integrity database
|
* Determines whether the provided relative path should make it into the generated integrity database
|
||||||
* @param $relativePath string Relative path candidate
|
* @param string $relativePath Relative path candidate
|
||||||
|
* @param string[] $excludedPaths The list of paths to exclude
|
||||||
* @return bool TRUE if the relative path should not be added to the integrity database; FALSE otherwise
|
* @return bool TRUE if the relative path should not be added to the integrity database; FALSE otherwise
|
||||||
*/
|
*/
|
||||||
protected function isExcluded($relativePath)
|
protected function isExcluded($relativePath, $excludedPaths = self::EXCLUDED_PATHS)
|
||||||
{
|
{
|
||||||
return in_array($relativePath, self::EXCLUDED_PATHS);
|
$excludedFolders = array_filter($excludedPaths, function ($excludedPath)
|
||||||
|
{
|
||||||
|
$needle = '/';
|
||||||
|
return substr($excludedPath, -strlen($needle)) === $needle;
|
||||||
|
});
|
||||||
|
foreach ($excludedFolders as $excludedFolder)
|
||||||
|
{
|
||||||
|
if (substr($relativePath, 0, strlen($excludedFolder)) === $excludedFolder) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$excludedFiles = array_diff($excludedPaths, $excludedFolders);
|
||||||
|
return in_array($relativePath, $excludedFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user