diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-03-24 18:29:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 18:29:45 +0300 |
commit | 1c5769b5770397f85a3e3f644f295f47ebc9b6aa (patch) | |
tree | 45af7dd011280b8b221931f098c234b8076273b5 /core | |
parent | 1713349b9ef31cad5a27f74304220958dea790c2 (diff) |
Build plugin module dependencies if type output does not exist locally, otherwise build will fail. (#18994)
Diffstat (limited to 'core')
-rw-r--r-- | core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php b/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php index f86f7f5102..9ac1edaec7 100644 --- a/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php +++ b/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php @@ -10,6 +10,7 @@ namespace Piwik\AssetManager\UIAssetFetcher; use Piwik\AssetManager\UIAssetFetcher; +use Piwik\Cache; use Piwik\Config; use Piwik\Development; use Piwik\Plugin\Manager; @@ -214,6 +215,26 @@ class PluginUmdAssetFetcher extends UIAssetFetcher return $result; } + public static function getPluginDependencies($plugin) + { + $pluginDir = self::getPluginDirectory($plugin); + $umdMetadata = "$pluginDir/vue/dist/umd.metadata.json"; + + $cache = Cache::getTransientCache(); + $cacheKey = 'PluginUmdAssetFetcher.pluginDependencies.' . $plugin; + + $pluginDependencies = $cache->fetch($cacheKey); + if (!is_array($pluginDependencies)) { + $pluginDependencies = []; + if (is_file($umdMetadata)) { + $pluginDependencies = json_decode(file_get_contents($umdMetadata), true); + $pluginDependencies = $pluginDependencies['dependsOn'] ?? []; + } + $cache->save($cacheKey, $pluginDependencies); + } + return $cache->fetch($cacheKey); + } + private static function visitPlugin($plugin, $keepUnresolved, &$plugins, &$result) { // remove the plugin from the array of plugins to visit @@ -225,17 +246,11 @@ class PluginUmdAssetFetcher extends UIAssetFetcher } // read the plugin dependencies, if any - $pluginDir = self::getPluginDirectory($plugin); - $umdMetadata = "$pluginDir/vue/dist/umd.metadata.json"; - - $pluginDependencies = []; - if (is_file($umdMetadata)) { - $pluginDependencies = json_decode(file_get_contents($umdMetadata), true); - } + $pluginDependencies = self::getPluginDependencies($plugin); - if (!empty($pluginDependencies['dependsOn'])) { + if (!empty($pluginDependencies)) { // visit each plugin this one depends on first, so it is loaded first - foreach ($pluginDependencies['dependsOn'] as $pluginDependency) { + foreach ($pluginDependencies as $pluginDependency) { // check if dependency is not activated if (!in_array($pluginDependency, $plugins) && !in_array($pluginDependency, $result) |