Commit 65f42ccf authored by Florian Bogner's avatar Florian Bogner

refactor: Change the way VCS repositories get handled.

parent 453a5d4f
{
"name": "quiqqer/quiqqer",
"type": "quiqqer-system",
"description": "A modular based management system written in JavaScript and PHP",
"version": "dev-dev",
"license": "GPL-3.0+",
"authors": [
{
"name": "Henning Leutz",
"email": "leutz@pcsg.de",
"homepage": "http://www.pcsg.de",
"role": "Developer"
"name": "quiqqer\/quiqqer",
"type": "quiqqer-system",
"description": "A modular based management system written in JavaScript and PHP",
"version": "quiqqer\/Lockclient#3",
"license": "GPL-3.0+",
"authors": [
{
"name": "Henning Leutz",
"email": "leutz@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"role": "Developer"
},
{
"name": "Moritz Scholz",
"email": "scholz@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.quiqqer.com"
},
{
"name": "Moritz Scholz",
"email": "scholz@pcsg.de",
"homepage": "http://www.pcsg.de",
"role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http://www.quiqqer.com"
},
"repositories": [
{
"type": "composer",
"url": "https://update.quiqqer.com"
}
],
"require": {
"php": ">=5.3",
"composer/composer": "1.5.*",
"tedivm/stash": "0.14.*",
"robloach/component-installer": "0.0.12",
"phpmailer/phpmailer": "~6.0",
"symfony/http-foundation": ">=2.3|3.*|4.2.*",
"symfony/console": "~2.7",
"html2text/html2text": "1.0.1",
"intervention/image": "2.*",
"t7systems/blowfish": "1.0.0",
"pcsg/composer-assets": "^1.0.1",
"dusank/knapsack": "8.*",
"league/climate": "3.*",
"ramsey/uuid": "3.*",
"quiqqer/composer": ">=1.3|dev-master|dev-dev",
"quiqqer/controls": "1.*|dev-master|dev-dev",
"quiqqer/dashboard": "1.*|dev-master|dev-dev",
"quiqqer/qui": ">=1|dev-master|dev-dev",
"quiqqer/qui-php": ">=0.12|dev-master|dev-dev",
"quiqqer/smarty3": "1.*|dev-master|dev-dev",
"quiqqer/ckeditor4": "2.*|1.*|dev-master|dev-dev",
"quiqqer/calendar-controls": "1.*|dev-master|dev-dev",
"quiqqer/countries": "1.*|dev-master|dev-dev",
"quiqqer/colorpicker": ">=1.1|dev-master|dev-dev",
"quiqqer/translator": "1.*|dev-master|dev-dev",
"quiqqer/utils": ">=1.9|dev-master|dev-dev",
"quiqqer/cron": "1.*|dev-master|dev-dev",
"quiqqer/log": "1.*|dev-master|dev-dev",
"quiqqer/diashow": ">=0.9|dev-master|dev-dev",
"quiqqer/lockclient": "1.*|dev-master|dev-dev",
"quiqqer/messages": "1.*|dev-master|dev-dev",
"quiqqer/meta": "1.*|dev-master|dev-dev",
"quiqqer/fontawesome": "*",
"quiqqer/backendsearch": "1.*|dev-master|dev-dev",
"quiqqer/requirements": "2.*",
"npm-asset/intl": "1.*",
"npm-asset/nouislider": "*",
"npm-asset/mustache": "2.*",
"npm-asset/urijs": "1.*"
},
"require-dev": {
"mikey179/vfsStream": "1.*",
"phpstan/phpstan": ">=0.5"
},
"scripts": {
"post-install-cmd": [
"QUI\\Update::onInstall"
"repositories": [
{
"type": "composer",
"url": "https:\/\/update.quiqqer.com"
}
],
"post-update-cmd": [
"QUI\\Update::onUpdate"
]
},
"autoload": {
"psr-0": {
"QUI": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"QUI\\Tests\\": "tests/QUI/"
"require": {
"php": ">=5.3",
"composer\/composer": "1.5.*",
"tedivm\/stash": "0.14.*",
"robloach\/component-installer": "0.0.12",
"phpmailer\/phpmailer": "~6.0",
"symfony\/http-foundation": ">=2.3|3.*|4.2.*",
"symfony\/console": "~2.7",
"html2text\/html2text": "1.0.1",
"intervention\/image": "2.*",
"t7systems\/blowfish": "1.0.0",
"pcsg\/composer-assets": "^1.0.1",
"dusank\/knapsack": "8.*",
"league\/climate": "3.*",
"ramsey\/uuid": "3.*",
"quiqqer\/composer": ">=1.3|dev-master|dev-dev",
"quiqqer\/controls": "1.*|dev-master|dev-dev",
"quiqqer\/dashboard": "1.*|dev-master|dev-dev",
"quiqqer\/qui": ">=1|dev-master|dev-dev",
"quiqqer\/qui-php": ">=0.12|dev-master|dev-dev",
"quiqqer\/smarty3": "1.*|dev-master|dev-dev",
"quiqqer\/ckeditor4": "2.*|1.*|dev-master|dev-dev",
"quiqqer\/calendar-controls": "1.*|dev-master|dev-dev",
"quiqqer\/countries": "1.*|dev-master|dev-dev",
"quiqqer\/colorpicker": ">=1.1|dev-master|dev-dev",
"quiqqer\/translator": "1.*|dev-master|dev-dev",
"quiqqer\/utils": ">=1.9|dev-master|dev-dev",
"quiqqer\/cron": "1.*|dev-master|dev-dev",
"quiqqer\/log": "1.*|dev-master|dev-dev",
"quiqqer\/diashow": ">=0.9|dev-master|dev-dev",
"quiqqer\/lockclient": "1.*|dev-master|dev-dev",
"quiqqer\/messages": "1.*|dev-master|dev-dev",
"quiqqer\/meta": "1.*|dev-master|dev-dev",
"quiqqer\/fontawesome": "*",
"quiqqer\/backendsearch": "1.*|dev-master|dev-dev",
"quiqqer\/requirements": "2.*",
"npm-asset\/intl": "1.*",
"npm-asset\/nouislider": "*",
"npm-asset\/mustache": "2.*",
"npm-asset\/urijs": "1.*"
},
"require-dev": {
"mikey179\/vfsStream": "1.*",
"phpstan\/phpstan": ">=0.5"
},
"scripts": {
"post-install-cmd": [
"QUI\\Update::onInstall"
],
"post-update-cmd": [
"QUI\\Update::onUpdate"
]
},
"autoload": {
"psr-0": {
"QUI": "lib\/"
}
},
"autoload-dev": {
"psr-4": {
"QUI\\Tests\\": "tests\/QUI\/"
}
}
}
}
}
\ No newline at end of file
......@@ -37,6 +37,11 @@ class Manager extends QUI\QDOM
{
const CACHE_NAME_TYPES = 'qui/packages/types';
/** @var int The minimum required memory_limit in megabytes of PHP */
const REQUIRED_MEMORY = 128;
/** @var int The minimum required memory_limit of PHP in megabytes, if the user added VCS repositories */
const REQUIRED_MEMORY_VCS = 256;
/**
* Package Directory
*
......@@ -1465,28 +1470,12 @@ class Manager extends QUI\QDOM
{
$Composer = $this->getComposer();
// WEB MODE Check
// Wenn VCS Server eingestellt sind sollte mindestens 256M vorhanden sein.
// Ohne VCS mindestens 128M
$existsVCS = function ($Update) {
/* @var $Update self */
$servers = $Update->getServerList();
foreach ($servers as $server) {
if ($server['type'] === 'vcs') {
return true;
}
}
return false;
};
$needledRAM = $existsVCS($this) ? '256M' : '128M';
$needledRAM = $this->isVCSServerEnabled() ? self::REQUIRED_MEMORY_VCS.'M' : self::REQUIRED_MEMORY.'M';
$limit = QUI\Utils\System::getMemoryLimit();
if (php_sapi_name() != 'cli'
&& $limit != -1
&& $existsVCS
&& $this->isVCSServerEnabled()
&& QUIFile::getBytes($needledRAM) > $limit) {
throw new QUI\Exception(
QUI::getLocale()->get(
......@@ -1622,6 +1611,25 @@ class Manager extends QUI\QDOM
$this->createComposerJSON();
}
/**
* Checks if a VCS update server is configured and active.
* Returns true if at least one VCS server is active and configured. Returns false otherwise.
*
* @return bool
*/
protected function isVCSServerEnabled()
{
$servers = $this->getServerList();
foreach ($servers as $server) {
if ($server['type'] === 'vcs' && $server['active']) {
return true;
}
}
return false;
}
/**
* XML helper
*/
......@@ -1750,25 +1758,34 @@ class Manager extends QUI\QDOM
* @param bool|string - (otional) The packagename which should get updated.
*
* @return string
* @throws QUI\Exception
*/
protected function composerUpdateOrInstall($package)
{
$lockServerEnabled = QUI::conf('globals', 'lockserver_enabled');
$memoryLimit = QUI\Utils\System::getMemoryLimit();
// Disable lockserver if a vcs repository is used
$repositories = $this->getServerList();
foreach ($repositories as $repo) {
if ($repo['type'] === 'vcs') {
// Lockserver can not handle VCS repositories ==> Check if local execution is possible or fail the operation
if ($this->isVCSServerEnabled()) {
if ($memoryLimit > self::REQUIRED_MEMORY_VCS * 1024 * 1024) {
return $this->getComposer()->update();
}
$exceptionLocale = $lockServerEnabled ?
'message.online.update.RAM.insufficient.vcs' : 'message.online.update.RAM.insufficient.vcs.lock';
throw new QUI\Exception([
'quiqqer/quiqqer',
$exceptionLocale
]);
}
if ($this->getComposer()->getMode() != QUI\Composer\Composer::MODE_WEB) {
return $this->getComposer()->update();
}
$lockServerEnabled = QUI::conf("globals", "lockserver_enabled");
$memoryLimit = QUI\Utils\System::getMemoryLimit();
if (!$lockServerEnabled && $memoryLimit != -1 && $memoryLimit < 256 * 1024 * 1024) {
throw new QUI\Exception([
'quiqqer/quiqqer',
......@@ -1816,23 +1833,33 @@ class Manager extends QUI\QDOM
*/
protected function composerRequireOrInstall($packages, $version)
{
// Disable lockserver if a vcs repository is used
$repositories = $this->getServerList();
foreach ($repositories as $repo) {
if ($repo['type'] === 'vcs') {
$memoryLimit = QUI\Utils\System::getMemoryLimit();
$lockServerEnabled = QUI::conf('globals', 'lockserver_enabled');
// Lockserver can not handle VCS repositories ==> Check if local execution is possible or fail the operation
if ($this->isVCSServerEnabled()) {
if ($memoryLimit > self::REQUIRED_MEMORY_VCS * 1024 * 1024) {
return $this->getComposer()->requirePackage($packages, $version);
}
}
$exceptionLocale = $lockServerEnabled ?
'message.online.update.RAM.insufficient.vcs' : 'message.online.update.RAM.insufficient.vcs.lock';
throw new QUI\Exception([
'quiqqer/quiqqer',
$exceptionLocale
]);
}
//
// NO VCS enabled -> continue normal routine
//
if ($this->getComposer()->getMode() != QUI\Composer\Composer::MODE_WEB) {
return $this->getComposer()->requirePackage($packages, $version);
}
$lockServerEnabled = QUI::conf('globals', 'lockserver_enabled');
$memoryLimit = QUI\Utils\System::getMemoryLimit();
if (!$lockServerEnabled && $memoryLimit != -1 && $memoryLimit < 256 * 1024 * 1024) {
if (!$lockServerEnabled && $memoryLimit != -1 && $memoryLimit < self::REQUIRED_MEMORY * 1024 * 1024) {
throw new QUI\Exception([
'quiqqer/quiqqer',
'message.online.update.RAM.insufficient'
......@@ -1844,7 +1871,6 @@ class Manager extends QUI\QDOM
}
$LockClient = new QUI\Lockclient\Lockclient();
try {
$lockContent = $LockClient->requirePackage($this->composer_json, $packages, $version);
} catch (\Exception $Exception) {
......
......@@ -780,6 +780,12 @@
<![CDATA[Für diese Aktion steht Composer nicht genug Arbeitsspeicher zur Verfügung. Bitte erhöhen Sie das Arbeitsspeicher Limit oder führen Sie Composer in der Konsole aus.]]>
</de>
</locale>
<locale name="message.online.update.RAM.insufficient.vcs">
<de><![CDATA[Es steht PHP nicht genug Arbeitsspeicher zur Verfügung, um Pakete mit angeschaltetem VCS Updateserver zu aktualisieren oder zu installieren.]]></de>
</locale>
<locale name="message.online.update.RAM.insufficient.vcs.lock">
<de><![CDATA[Der Lockserver kann nicht verwendet werden, wenn ein VCS Updateserver aktiviert ist und PHP steht nicht genug Arbeitsspeicher zur Verfügung, um die Operation lokal auszuführen.]]></de>
</locale>
<locale name="exception.console.execute.only.in.cli">
<de><![CDATA[System Tools können nur in der CLI ausgeführt werden.]]></de>
</locale>
......
......@@ -777,6 +777,14 @@
<![CDATA[Composer does not have enough memory available for this action. Please increase the memory limit for PHP or execute Composer in the command line]]>
</en>
</locale>
<locale name="message.online.update.RAM.insufficient.vcs">
<en>
<![CDATA[PHP does not have enough memory available to perform this action, while a VCS updateserver is enabled]]></en>
</locale>
<locale name="message.online.update.RAM.insufficient.vcs.lock">
<en>
<![CDATA[It is not possible to use the Lockserver, while a VCS updateserver is active and the system does not have enough memory available to peform this operation locally.]]></en>
</locale>
<locale name="exception.console.execute.only.in.cli">
<en><![CDATA[System tools can only be run in the CLI.]]></en>
</locale>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment