This commit is contained in:
Taylor Dondich
2019-12-09 11:06:29 -08:00
committed by Julio Cesar Laura Avendaño
parent b7f6df7eb5
commit 2b11bc0c80
4 changed files with 65 additions and 12 deletions

View File

@@ -166,8 +166,14 @@ class PmLicenseManager
}
}
if (file_exists(PATH_DATA_SITE . "ee")) {
$aPlugins = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
$eeData = Cache::get(config('system.workspace') . 'enterprise.ee', function () {
if (file_exists(PATH_DATA_SITE . 'ee')) {
return trim(file_get_contents(PATH_DATA_SITE . 'ee'));
}
return null;
});
if ($eeData) {
$aPlugins = unserialize($eeData);
$aDenied = [];
foreach ($aPlugins as $aPlugin) {
$sClassName = substr($aPlugin ['sFilename'], 0, strpos($aPlugin ['sFilename'], '-'));
@@ -210,8 +216,14 @@ class PmLicenseManager
$oPluginRegistry->savePlugin($oDetails->getNamespace());
}
if (file_exists(PATH_DATA_SITE . 'ee')) {
$aPlugins = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
$eeData = Cache::get(config('system.workspace') . 'enterprise.ee', function () {
if (file_exists(PATH_DATA_SITE . 'ee')) {
return trim(file_get_contents(PATH_DATA_SITE . 'ee'));
}
return null;
});
if ($eeData) {
$aPlugins = unserialize($eeData);
foreach ($aPlugins as $aPlugin) {
$sClassName = substr($aPlugin ['sFilename'], 0, strpos($aPlugin ['sFilename'], '-'));

View File

@@ -354,8 +354,14 @@ class AddonsStore extends BaseAddonsStore
$oPluginRegistry = PluginRegistry::loadSingleton();
$aPluginsPP = array();
if (file_exists(PATH_DATA_SITE . 'ee')) {
$aPluginsPP = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
$eeData = Cache::get(config('system.workspace') . 'enterprise.ee', function () {
if (file_exists(PATH_DATA_SITE . 'ee')) {
return trim(file_get_contents(PATH_DATA_SITE . 'ee'));
}
return null;
});
if ($eeData) {
$aPluginsPP = unserialize($eeData);
}
$pmLicenseManagerO = PmLicenseManager::getSingleton();

View File

@@ -1500,8 +1500,14 @@ class adminProxy extends HttpProxyController
//Installed Plugins (license info?)
$arrayAddon = array();
if (file_exists(PATH_DATA_SITE . "ee")) {
$arrayAddon = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee")));
$eeData = Cache::get(config('system.workspace') . 'enterprise.ee', function () {
if (file_exists(PATH_DATA_SITE . 'ee')) {
return trim(file_get_contents(PATH_DATA_SITE . 'ee'));
}
return null;
});
if ($eeData) {
$arrayAddon = unserialize($eeData);
}
$plugins = array();

View File

@@ -1,5 +1,6 @@
<?php
use Illuminate\Support\Facades\Cache;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
@@ -207,15 +208,43 @@ class enterprisePlugin extends PMPlugin
}
}
/**
* Registeres the plugin in the enterprise data
* Note, this utilizes caching to reduce the burden of the file I/O on the ee file. However, this does
* require caching to be enabled.
*/
public function registerEE($pluginFile, $pluginVersion)
{
if (file_exists(PATH_DATA_SITE . "ee")) {
$this->systemAvailable = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee")));
$cacheKey = config('system.workspace') . 'enterprise.ee';
// Fetch the value from cache. If not present, fetch from the filesystem.
$value = Cache::get($cacheKey, function () {
if (file_exists(PATH_DATA_SITE . "ee")) {
return trim(file_get_contents(PATH_DATA_SITE . "ee"));
} else {
return null;
}
});
if ($value) {
$this->systemAvailable = unserialize($value);
} else {
// Handle potential no value
$this->systemAvailable = [];
}
$this->systemAvailable[$pluginFile]["sFilename"] = $pluginFile . "-" . $pluginVersion . ".tar";
file_put_contents(PATH_DATA_SITE . "ee", serialize($this->systemAvailable));
$filename = $pluginFile . '-' . $pluginVersion . '.tar';
// Check to see if update is required
if (
!isset($this->systemAvailable[$pluginFile]) ||
!isset($this->systemAvailable[$pluginFile]['sFilename']) ||
$this->systemAvailable[$pluginFile]['sFilename'] != $filename
) {
// Update required
$this->systemAvailable[$pluginFile]["sFilename"] = $filename;
file_put_contents(PATH_DATA_SITE . "ee", serialize($this->systemAvailable));
// Put in cache as well
Cache::forever($cacheKey, serialize($this->systemAvailable));
}
return true;
}