Skip to content

Commit 2c7ffa8

Browse files
committed
version 2.3.32
2 parents 97a995b + ae9b233 commit 2c7ffa8

File tree

15 files changed

+48
-55
lines changed

15 files changed

+48
-55
lines changed

http/html.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<link rel="stylesheet"
1212
type="text/css"
1313
href="/css/main.css?v=7fef64d">
14-
<script src="/js/main.js?v=f07adcf"></script>
14+
<script src="/js/main.js?v=eab8500"></script>
1515

1616
</head>
1717
<body id="pk">

http/js/main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

totum/commands/CleanSchemaTmpTables.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
3030
$Conf->setHostSchema(null, $schema);
3131
}
3232
}
33-
33+
$sql = $Conf->getSql();
3434
$plus24 = date_create();
3535
$plus24->modify('-24 hours');
36-
$Conf->getSql()->exec('delete from _tmp_tables where touched<\'' . $plus24->format('Y-m-d H:i') . '\'');
36+
$sql->exec('delete from _tmp_tables where touched<\'' . $plus24->format('Y-m-d H:i') . '\'');
3737

3838
$minus10 = date_create();
3939
$minus10->modify('-10 minutes');
40-
$Conf->getSql()->exec('delete from _tmp_tables where table_name IN (\'_panelbuttons\', \'_linkToButtons\') AND touched<\'' . $minus10->format('Y-m-d H:i') . '\'');
40+
$sql->exec('delete from _tmp_tables where table_name SIMILAR TO \'\_%\' AND touched<\''
41+
. $minus10->format('Y-m-d H:i') . '\'');
42+
43+
$sql->exec('VACUUM _tmp_tables');
4144
}
4245
}

totum/commands/CleanSchemasTmpTables.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ protected function configure()
1919

2020
protected function execute(InputInterface $input, OutputInterface $output)
2121
{
22-
foreach (array_unique(array_values(Conf::getSchemas())) as $schemaName) {
23-
`{$_SERVER['SCRIPT_FILENAME']} clean-schema-tmp-tables $schemaName > /dev/null 2>&1 &`;
22+
$Conf = new Conf();
23+
$sql = $Conf->getSql(withSchema: false);
24+
$plus24 = date_create();
25+
$plus24->modify('-24 hours');
26+
$minus10 = date_create();
27+
$minus10->modify('-10 minutes');
28+
29+
foreach (array_unique(array_values(Conf::getSchemas())) as $schema) {
30+
$sql->exec('delete from "'.$schema.'"._tmp_tables where touched<\'' . $plus24->format('Y-m-d H:i') . '\'');
31+
$sql->exec('delete from "'.$schema.'"._tmp_tables where table_name SIMILAR TO \'\_%\' AND touched<\'' . $minus10->format('Y-m-d H:i') . '\'');
32+
$sql->exec('VACUUM "'.$schema.'"._tmp_tables');
2433
}
2534
}
2635
}

totum/common/Totum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class Totum
2929
{
30-
public const VERSION = '2.3.31';
30+
public const VERSION = '2.3.32';
3131

3232

3333
public const TABLE_CODE_PARAMS = ['row_format', 'table_format'];

totum/common/TotumInstall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ public function updateDataExecCodes($schemaRows, array $categoriesMatches, array
889889
$_tableModel = $this->Totum->getModel($schemaRow['name']);
890890

891891

892-
$getRowId = function ($row) use ($_tableModel) {
892+
$getRowId = function ($row) use ($_tableModel, $schemaRow) {
893893
if (!empty($schemaRow['key_fields']) || (key_exists(
894894
'id',
895895
$row

totum/common/calculates/Calculate.php

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ protected function formStartSections()
134134

135135
protected static function __compare_normalize($n)
136136
{
137+
137138
switch (gettype($n)) {
138139
case 'NULL':
139140
return '';
@@ -143,6 +144,9 @@ protected static function __compare_normalize($n)
143144
case 'double':
144145
case 'string':
145146
if (is_numeric($n)) {
147+
if (str_contains(strval($n), 'E')) {
148+
$n = number_format($n, 12, '.', '');
149+
}
146150
return bcadd($n, 0, 10);
147151
}
148152
return $n;
@@ -172,6 +176,7 @@ protected static function _compare_n_array($operator, $n, array $n2, LangInterfa
172176
$r = false;
173177
break;
174178
case '=':
179+
case '!=':
175180
if (count($n2) === 0) {
176181
if ($isTopLevel && (($n ?? '') === '')) {
177182
$r = true;
@@ -180,55 +185,28 @@ protected static function _compare_n_array($operator, $n, array $n2, LangInterfa
180185
}
181186
} else {
182187
$r = false;
183-
$n = static::__compare_normalize($n);
184188

185189
if (is_null($key)) {
186190
foreach ($n2 as $nItem) {
187-
if ($n === static::__compare_normalize($nItem)) {
191+
if (static::compare('==', $n, $nItem, $Lang)) {
188192
$r = true;
189193
break;
190194
}
191195
}
192196
} else {
193197
$key = strval($key);
194198
foreach ($n2 as $nKey => $nItem) {
195-
if (strval($nKey) === $key && $n === static::__compare_normalize($nItem)) {
199+
if (strval($nKey) === $key && static::compare('==', $n, $nItem, $Lang)) {
196200
$r = true;
197201
break;
198202
}
199203
}
200204
}
201205
}
202-
break;
203-
case '!=':
204-
if (count($n2) === 0) {
205-
if ($isTopLevel && (($n ?? '') === '')) {
206-
$r = true;
207-
} else {
208-
$r = false;
209-
}
210-
} else {
211-
$r = false;
212-
$n = static::__compare_normalize($n);
213206

214-
if (is_null($key)) {
215-
foreach ($n2 as $nItem) {
216-
if ($n === static::__compare_normalize($nItem)) {
217-
$r = true;
218-
break;
219-
}
220-
}
221-
} else {
222-
$key = strval($key);
223-
foreach ($n2 as $nKey => $nItem) {
224-
if (strval($nKey) === $key && $n === static::__compare_normalize($nItem)) {
225-
$r = true;
226-
break;
227-
}
228-
}
229-
}
207+
if ($operator === '!=') {
208+
$r = !$r;
230209
}
231-
$r = !$r;
232210
break;
233211
default:
234212
throw new errorException($Lang->translate('For lists comparisons, only available =, ==, !=, !==.'));
@@ -243,17 +221,13 @@ public static function compare(string $operator, $n, $n2, LangInterface $Lang)
243221
if (count($n) > 0 && (array_keys($n) !== range(0, count($n) - 1))) {
244222
$nIsRow = true;
245223
$nIsArray = false;
246-
} else {
247-
$nIsRow = false;
248224
}
249225
}
250226

251227
if ($n2IsArray = is_array($n2)) {
252228
if (count($n2) > 0 && (array_keys($n2) !== range(0, count($n2) - 1))) {
253229
$n2IsRow = true;
254230
$n2IsArray = false;
255-
} else {
256-
$n2IsRow = false;
257231
}
258232
}
259233

@@ -314,6 +288,12 @@ public static function compare(string $operator, $n, $n2, LangInterface $Lang)
314288
return static::_compare_n_array($operator, $n, $n2, $Lang, null, true);
315289
} elseif ($nIsArray) {
316290
return static::_compare_n_array($operator, $n2, $n, $Lang, null, true);
291+
} elseif ($n2IsRow || $nIsRow) {
292+
$r = match ($operator) {
293+
'!=', '!==' => true,
294+
'==', '=' => false,
295+
default => throw new errorException($Lang->translate('For lists comparisons, only available =, ==, !=, !==.')),
296+
};
317297
} else {
318298
$r = match (static::__compare_normalize($n) <=> static::__compare_normalize($n2)) {
319299
0 => in_array($operator, ['>=', '<=', '=', '==']),

totum/common/calculates/FuncStringsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ protected function funcStrPart(string $params): string
140140
{
141141
$params = $this->getParamsArray($params);
142142

143-
$this->__checkRequiredParams($params, ['str', 'offset'], 'strPart');
143+
$this->__checkRequiredParams($params, ['str'], 'strPart');
144144

145145
if ($params['str']) {
146146
$this->__checkNotArrayParams($params, ['str']);
147147
$str = (string)$params['str'];
148148
} else {
149149
$str = '';
150150
}
151-
if ($params['offset']) {
151+
if ($params['offset'] ?? null) {
152152
$this->__checkNotArrayParams($params, ['offset']);
153153

154154
$offset = (int)$params['offset'];

totum/common/calculates/ParsesTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function parseTotumCond($string): ?bool
214214
\(|\)|
215215
[&]{2}|
216216
[|]{2}|
217+
!==|
217218
==|
218219
!=|
219220
>=|
@@ -302,6 +303,7 @@ protected function parseTotumCond($string): ?bool
302303
case '>':
303304
case '=':
304305
case '==':
306+
case '!==':
305307
case '!=':
306308
case '<=':
307309
case '>=':

totum/common/errorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function criticalException(string|\Exception $error, aTable|Totum|
4040
match (true) {
4141
is_a($contextObject, aTable::class) => $contextObject->getTotum()->transactionRollback(),
4242
is_a($contextObject, Totum::class) => $contextObject->transactionRollback(),
43-
is_a($contextObject, ConfParent::class) => $contextObject->getSql()->transactionRollBack(),
43+
is_a($contextObject, ConfParent::class) => $contextObject->getSql(true, withSchema: false)->transactionRollBack(),
4444
is_a($contextObject, Sql::class) => $contextObject->transactionRollBack(),
4545
};
4646
if (!$path && is_object($error) && method_exists($error, 'getPathMess')) {

0 commit comments

Comments
 (0)