From 0b218833af114ff470126cbf14d56e79a4b297c2 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 16 Jun 2020 15:44:32 +0300 Subject: [PATCH 1/5] fix q0 queue --- application/Espo/Jobs/ProcessJobQueueQ0.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Jobs/ProcessJobQueueQ0.php b/application/Espo/Jobs/ProcessJobQueueQ0.php index a423e66dd4..a5f505b4e4 100644 --- a/application/Espo/Jobs/ProcessJobQueueQ0.php +++ b/application/Espo/Jobs/ProcessJobQueueQ0.php @@ -35,7 +35,7 @@ class ProcessJobQueueQ0 extends \Espo\Core\Jobs\Base { public function run() { - $limit = $this->getConfig()->get('jobQ1MaxPortion', 200); + $limit = $this->getConfig()->get('jobQ0MaxPortion', 200); $cronManager = new \Espo\Core\CronManager($this->getContainer()); From 70a374004d9810fae6c259a91072ab67361e8e7b Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 22 Jun 2020 13:02:08 +0300 Subject: [PATCH 2/5] fix navbar verical scroll issue --- client/src/views/site/navbar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/views/site/navbar.js b/client/src/views/site/navbar.js index 14ae5dd304..eb2505cc96 100644 --- a/client/src/views/site/navbar.js +++ b/client/src/views/site/navbar.js @@ -462,6 +462,8 @@ define('views/site/navbar', 'view', function (Dep) { updateSizeForVertical(); this.$el.find('.notifications-badge-container').insertAfter(this.$el.find('.quick-create-container')); + + this.adjustBodyMinHeight(); }, getNavbarHeight: function () { @@ -479,7 +481,7 @@ define('views/site/navbar', 'view', function (Dep) { }, adjustBodyMinHeightVertical: function () { - var minHeight = this.$tabs.height() + this.getStaticItemsHeight(); + var minHeight = this.$tabs.get(0).scrollHeight + this.getStaticItemsHeight(); var moreHeight = 0; this.$more.find('> li:visible').each(function (i, el) { From 0f2a26b744c5c1807c85f080b809864c2bf117da Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 22 Jun 2020 21:26:51 +0300 Subject: [PATCH 3/5] formula comments fix --- .../Core/Console/Commands/SetPassword.php | 2 + application/Espo/Core/Formula/Parser.php | 94 ++++++++++++------ .../unit/Espo/Core/Formula/EvaluatorTest.php | 96 +++++++++++++++++++ 3 files changed, 162 insertions(+), 30 deletions(-) diff --git a/application/Espo/Core/Console/Commands/SetPassword.php b/application/Espo/Core/Console/Commands/SetPassword.php index b019a51a90..b43e9ad511 100644 --- a/application/Espo/Core/Console/Commands/SetPassword.php +++ b/application/Espo/Core/Console/Commands/SetPassword.php @@ -58,6 +58,8 @@ class SetPassword extends Base $password = $this->ask(); + $password = trim($password); + if (!$password) { $this->out("Password can not be empty.\n"); die; diff --git a/application/Espo/Core/Formula/Parser.php b/application/Espo/Core/Formula/Parser.php index 34b852afe8..ebcbb97b83 100644 --- a/application/Espo/Core/Formula/Parser.php +++ b/application/Espo/Core/Formula/Parser.php @@ -109,6 +109,8 @@ class Parser { $isString = false; $isSingleQuote = false; + $isComment = false; + $isLineComment = false; $modifiedString = $string; @@ -116,27 +118,31 @@ class Parser for ($i = 0; $i < strlen($string); $i++) { $isStringStart = false; - if ($string[$i] === "'" && ($i === 0 || $string[$i - 1] !== "\\")) { - if (!$isString) { - $isString = true; - $isSingleQuote = true; - $isStringStart = true; - } else { - if ($isSingleQuote) { - $isString = false; + + if (!$isLineComment && !$isComment) { + if ($string[$i] === "'" && ($i === 0 || $string[$i - 1] !== "\\")) { + if (!$isString) { + $isString = true; + $isSingleQuote = true; + $isStringStart = true; + } else { + if ($isSingleQuote) { + $isString = false; + } } - } - } else if ($string[$i] === "\"" && ($i === 0 || $string[$i - 1] !== "\\")) { - if (!$isString) { - $isString = true; - $isStringStart = true; - $isSingleQuote = false; - } else { - if (!$isSingleQuote) { - $isString = false; + } else if ($string[$i] === "\"" && ($i === 0 || $string[$i - 1] !== "\\")) { + if (!$isString) { + $isString = true; + $isStringStart = true; + $isSingleQuote = false; + } else { + if (!$isSingleQuote) { + $isString = false; + } } } } + if ($isString) { if ($string[$i] === '(' || $string[$i] === ')') { $modifiedString[$i] = '_'; @@ -144,24 +150,51 @@ class Parser $modifiedString[$i] = ' '; } } else { - if ($string[$i] === '(') { - $braceCounter++; - } - if ($string[$i] === ')') { - $braceCounter--; - } + if (!$isLineComment && !$isComment) { - if ($braceCounter === 0) { - if (!is_null($splitterIndexList)) { - if ($string[$i] === ';') { - $splitterIndexList[] = $i; + if (!$isComment) { + if ($i && $string[$i] === '/' && $string[$i - 1] === '/') { + $isLineComment = true; } } - if ($intoOneLine) { - if ($string[$i] === "\r" || $string[$i] === "\n" || $string[$i] === "\t") { - $string[$i] = ' '; + + if (!$isLineComment) { + if ($i && $string[$i] === '*' && $string[$i - 1] === '/') { + $isComment = true; } } + + if ($string[$i] === '(') { + $braceCounter++; + } + if ($string[$i] === ')') { + $braceCounter--; + } + + if ($braceCounter === 0) { + if (!is_null($splitterIndexList)) { + if ($string[$i] === ';') { + $splitterIndexList[] = $i; + } + } + if ($intoOneLine) { + if ($string[$i] === "\r" || $string[$i] === "\n" || $string[$i] === "\t") { + $string[$i] = ' '; + } + } + } + } + + if ($isLineComment) { + if ($string[$i] === "\n") { + $isLineComment = false; + } + } + + if ($isComment) { + if ($string[$i - 1] === "*" && $string[$i] === "/") { + $isComment = false; + } } } } @@ -181,6 +214,7 @@ class Parser $this->processStrings($expression, $modifiedExpression, $splitterIndexList, true); + //echo $modifiedExpression; $this->stripComments($expression, $modifiedExpression); foreach ($splitterIndexList as $i => $index) { diff --git a/tests/unit/Espo/Core/Formula/EvaluatorTest.php b/tests/unit/Espo/Core/Formula/EvaluatorTest.php index f84f2417cd..f0a0f655f8 100644 --- a/tests/unit/Espo/Core/Formula/EvaluatorTest.php +++ b/tests/unit/Espo/Core/Formula/EvaluatorTest.php @@ -188,4 +188,100 @@ class EvaluatorTest extends \PHPUnit\Framework\TestCase $this->assertEquals([0, 1, 2], $vars->target); } + + public function testComment1() + { + $expression = " + // test + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment2() + { + $expression = " + // test'test + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment3() + { + $expression = " + // test\"test + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment4() + { + $expression = " + // test)(test + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment5() + { + $expression = " + /* test'test + */ + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment6() + { + $expression = " + /* test(test + */ + \$test = '1'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('1', $vars->test); + } + + public function testComment7() + { + $expression = " + \$test = '/* 1 */'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('/* 1 */', $vars->test); + } + + public function testComment8() + { + $expression = " + \$test = '// 1 */'; + "; + + $vars = (object) []; + $this->evaluator->process($expression, null, $vars); + $this->assertEquals('// 1 */', $vars->test); + } } From bf410b2258fc4becc2071c2b46ef5b85c196912b Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 24 Jun 2020 09:02:23 +0300 Subject: [PATCH 4/5] cleanup --- application/Espo/Core/Formula/Parser.php | 1 - 1 file changed, 1 deletion(-) diff --git a/application/Espo/Core/Formula/Parser.php b/application/Espo/Core/Formula/Parser.php index ebcbb97b83..0fded93cb7 100644 --- a/application/Espo/Core/Formula/Parser.php +++ b/application/Espo/Core/Formula/Parser.php @@ -214,7 +214,6 @@ class Parser $this->processStrings($expression, $modifiedExpression, $splitterIndexList, true); - //echo $modifiedExpression; $this->stripComments($expression, $modifiedExpression); foreach ($splitterIndexList as $i => $index) { From 94008f5a53e38c15325502b069eec65e9d11118f Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 25 Jun 2020 08:35:47 +0300 Subject: [PATCH 5/5] fix metadata service null acl check --- application/Espo/Services/Metadata.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/Espo/Services/Metadata.php b/application/Espo/Services/Metadata.php index a6f4323a09..a375d03ecf 100644 --- a/application/Espo/Services/Metadata.php +++ b/application/Espo/Services/Metadata.php @@ -102,11 +102,14 @@ class Metadata extends \Espo\Core\Services\Base } $foreignEntityType = $defs['entity'] ?? null; - if ($this->getAcl()->check($foreignEntityType)) continue; - if ($this->getUser()->isPortal()) { - if ($foreignEntityType === 'Account' || $foreignEntityType === 'Contact') { - continue; + if ($foreignEntityType) { + if ($this->getAcl()->check($foreignEntityType)) continue; + + if ($this->getUser()->isPortal()) { + if ($foreignEntityType === 'Account' || $foreignEntityType === 'Contact') { + continue; + } } }