diff --git a/application/Espo/Core/Console/Commands/SetPassword.php b/application/Espo/Core/Console/Commands/SetPassword.php index e053bc554c..6546cf927b 100644 --- a/application/Espo/Core/Console/Commands/SetPassword.php +++ b/application/Espo/Core/Console/Commands/SetPassword.php @@ -70,6 +70,8 @@ class SetPassword implements Command $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..0fded93cb7 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; + } } } } diff --git a/application/Espo/Jobs/ProcessJobQueueQ0.php b/application/Espo/Jobs/ProcessJobQueueQ0.php index 1eaad252e7..369021bb32 100644 --- a/application/Espo/Jobs/ProcessJobQueueQ0.php +++ b/application/Espo/Jobs/ProcessJobQueueQ0.php @@ -48,7 +48,7 @@ class ProcessJobQueueQ0 implements Job public function run() { - $limit = $this->config->get('jobQ1MaxPortion', 200); + $limit = $this->config->get('jobQ0MaxPortion', 200); $this->cronManager->processPendingJobs('q0', $limit, true, true); } 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; + } } } 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) { diff --git a/tests/unit/Espo/Core/Formula/EvaluatorTest.php b/tests/unit/Espo/Core/Formula/EvaluatorTest.php index 92959207d4..7cdd8a65ef 100644 --- a/tests/unit/Espo/Core/Formula/EvaluatorTest.php +++ b/tests/unit/Espo/Core/Formula/EvaluatorTest.php @@ -193,4 +193,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); + } }