Skip to content

Commit d53832d

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2 parents 7569edf + dd3d8ba commit d53832d

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13326,7 +13326,7 @@ parameters:
1332613326
-
1332713327
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
1332813328
identifier: empty.notAllowed
13329-
count: 3
13329+
count: 4
1333013330
path: src/Server/Status/Processes.php
1333113331

1333213332
-

‎psalm-baseline.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8367,8 +8367,9 @@
83678367
<code><![CDATA[0 !== --$sortableColCount]]></code>
83688368
</RedundantCondition>
83698369
<RiskyTruthyFalsyComparison>
8370+
<code><![CDATA[empty($process['Progress'])]]></code>
8371+
<code><![CDATA[empty($process['Progress'])]]></code>
83708372
<code><![CDATA[empty($process['info'])]]></code>
8371-
<code><![CDATA[empty($process['progress'])]]></code>
83728373
<code><![CDATA[empty($process['state'])]]></code>
83738374
</RiskyTruthyFalsyComparison>
83748375
</file>

‎src/Controllers/Database/StructureController.php‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,19 @@ private function getReplicationStatus(array $replicaInfo, string $table): array
594594
$searchDoDBInTruename = array_search($table, $replicaInfo['Do_DB']);
595595
$searchDoDBInDB = array_search(Current::$database, $replicaInfo['Do_DB']);
596596

597-
$do = (is_string($searchDoDBInTruename) && $searchDoDBInTruename !== '')
598-
|| (is_string($searchDoDBInDB) && $searchDoDBInDB !== '')
599-
|| ($nbServReplicaDoDb === 0 && $nbServReplicaIgnoreDb === 0)
600-
|| $this->hasTable($replicaInfo['Wild_Do_Table'], $table);
601-
602597
$searchDb = array_search(Current::$database, $replicaInfo['Ignore_DB']);
603598
$searchTable = array_search($table, $replicaInfo['Ignore_Table']);
604599
$ignored = (is_string($searchTable) && $searchTable !== '')
605600
|| (is_string($searchDb) && $searchDb !== '')
606601
|| $this->hasTable($replicaInfo['Wild_Ignore_Table'], $table);
602+
603+
// Only set do = true if table is not ignored
604+
if (! $ignored) {
605+
$do = (is_string($searchDoDBInTruename) && $searchDoDBInTruename !== '')
606+
|| (is_string($searchDoDBInDB) && $searchDoDBInDB !== '')
607+
|| ($nbServReplicaDoDb === 0 && $nbServReplicaIgnoreDb === 0)
608+
|| $this->hasTable($replicaInfo['Wild_Do_Table'], $table);
609+
}
607610
}
608611

609612
return [$do, $ignored];

‎src/Server/Status/Processes.php‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
use function __;
1212
use function array_change_key_case;
13+
use function array_key_exists;
1314
use function count;
15+
use function number_format;
1416

1517
use const CASE_LOWER;
1618

@@ -30,10 +32,8 @@ public function getList(bool $showExecuting, bool $showFullSql, string $orderByF
3032
$sqlQuery = $showFullSql
3133
? 'SHOW FULL PROCESSLIST'
3234
: 'SHOW PROCESSLIST';
33-
if (
34-
($orderByField !== '' && $sortOrder !== '')
35-
|| $showExecuting
36-
) {
35+
$useIS = $showExecuting || ($orderByField !== '' && $sortOrder !== '');
36+
if ($useIS) {
3737
$urlParams['order_by_field'] = $orderByField;
3838
$urlParams['sort_order'] = $sortOrder;
3939
$urlParams['showExecuting'] = $showExecuting;
@@ -54,6 +54,16 @@ public function getList(bool $showExecuting, bool $showFullSql, string $orderByF
5454
// Array keys need to modify due to the way it has used
5555
// to display column values
5656
$process = array_change_key_case($process, CASE_LOWER);
57+
58+
$progress = ! empty($process['Progress']) ? $process['Progress'] : '---';
59+
if ($useIS && ! empty($process['Progress'])) {
60+
$stage = array_key_exists('Stage', $process) ? (int) $process['Stage'] : null;
61+
$maxStage = array_key_exists('Max_stage', $process) ? (int) $process['Max_stage'] : null;
62+
if ($stage !== null && $maxStage !== null && $maxStage > 1) {
63+
$progress = number_format(($stage - 1) / $maxStage * 100 + ((float) $progress) / $maxStage, 3);
64+
}
65+
}
66+
5767
$rows[] = [
5868
'id' => $process['id'],
5969
'user' => $process['user'],
@@ -62,7 +72,7 @@ public function getList(bool $showExecuting, bool $showFullSql, string $orderByF
6272
'command' => $process['command'],
6373
'time' => $process['time'],
6474
'state' => ! empty($process['state']) ? $process['state'] : '---',
65-
'progress' => ! empty($process['progress']) ? $process['progress'] : '---',
75+
'progress' => $progress,
6676
'info' => ! empty($process['info']) ? Generator::formatSql($process['info'], ! $showFullSql) : '---',
6777
];
6878
}

0 commit comments

Comments
 (0)