Optimize getTrackingIcon
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
56d19eb4aa
commit
b5ae50454d
@ -242,6 +242,7 @@ class StructureController extends AbstractController
|
||||
$hiddenFields = [];
|
||||
$overallApproxRows = false;
|
||||
$structureTableRows = [];
|
||||
$trackedTables = Tracker::getTrackedTables($GLOBALS['db']);
|
||||
foreach ($this->tables as $currentTable) {
|
||||
// Get valid statistics whatever is the table type
|
||||
|
||||
@ -417,7 +418,7 @@ class StructureController extends AbstractController
|
||||
)
|
||||
)
|
||||
),
|
||||
'tracking_icon' => $this->getTrackingIcon($truename),
|
||||
'tracking_icon' => $this->getTrackingIcon($truename, $trackedTables[$truename] ?? null),
|
||||
'server_replica_status' => $replicaInfo['status'],
|
||||
'table_url_params' => $tableUrlParams,
|
||||
'db_is_system_schema' => $this->dbIsSystemSchema,
|
||||
@ -521,20 +522,20 @@ class StructureController extends AbstractController
|
||||
/**
|
||||
* Returns the tracking icon if the table is tracked
|
||||
*
|
||||
* @param string $table table name
|
||||
* @param string $table table name
|
||||
* @param array|null $trackedTable
|
||||
*
|
||||
* @return string HTML for tracking icon
|
||||
*/
|
||||
protected function getTrackingIcon(string $table): string
|
||||
protected function getTrackingIcon(string $table, $trackedTable): string
|
||||
{
|
||||
$trackingIcon = '';
|
||||
if (Tracker::isActive()) {
|
||||
$isTracked = Tracker::isTracked($this->db, $table);
|
||||
if ($isTracked || Tracker::getVersion($this->db, $table) > 0) {
|
||||
if ($trackedTable !== null) {
|
||||
$trackingIcon = $this->template->render('database/structure/tracking_icon', [
|
||||
'db' => $this->db,
|
||||
'table' => $table,
|
||||
'is_tracked' => $isTracked,
|
||||
'is_tracked' => $trackedTable['active'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -973,4 +973,46 @@ class Tracker
|
||||
|
||||
return $dbi->queryAsControlUser($sqlQuery)->fetchValue() !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* THIS IS TEMPORARY FIX for performance issues in QA 5.2. Do not merge into 6.0!
|
||||
*/
|
||||
public static function getTrackedTables(string $dbName): array
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$trackingEnabled = Cache::get(self::TRACKER_ENABLED_CACHE_KEY, false);
|
||||
if (! $trackingEnabled) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$relation = new Relation($dbi);
|
||||
$trackingFeature = $relation->getRelationParameters()->trackingFeature;
|
||||
if ($trackingFeature === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sqlQuery = sprintf(
|
||||
"SELECT table_name, tracking_active
|
||||
FROM (
|
||||
SELECT table_name, MAX(version) version
|
||||
FROM %s.%s WHERE db_name = %s AND table_name <> ''
|
||||
GROUP BY table_name
|
||||
) filtered_tables
|
||||
JOIN %s.%s USING(table_name, version)",
|
||||
Util::backquote($trackingFeature->database),
|
||||
Util::backquote($trackingFeature->tracking),
|
||||
"'" . $dbi->escapeString($dbName, DatabaseInterface::CONNECT_CONTROL) . "'",
|
||||
Util::backquote($trackingFeature->database),
|
||||
Util::backquote($trackingFeature->tracking)
|
||||
);
|
||||
|
||||
$trackedTables = [];
|
||||
foreach ($dbi->queryAsControlUser($sqlQuery) as $row) {
|
||||
$trackedTable = ['name' => (string) $row['table_name'], 'active' => (bool) $row['tracking_active']];
|
||||
$trackedTables[$trackedTable['name']] = $trackedTable;
|
||||
}
|
||||
|
||||
return $trackedTables;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1115,6 +1115,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Database/StructureController.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getTrackingIcon\\(\\) has parameter \\$trackedTable with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Database/StructureController.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:getValuesForAriaTable\\(\\) has parameter \\$currentTable with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -8555,6 +8560,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Tracker.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tracker\\:\\:getTrackedTables\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Tracker.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tracker\\:\\:parseQuery\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -1777,7 +1777,7 @@
|
||||
<code>$formattedOverhead</code>
|
||||
<code>$formattedSize</code>
|
||||
</InvalidScalarArgument>
|
||||
<MixedArgument occurrences="36">
|
||||
<MixedArgument occurrences="37">
|
||||
<code>$checkTime</code>
|
||||
<code>$checkTimeAll</code>
|
||||
<code>$createTime</code>
|
||||
@ -1811,6 +1811,7 @@
|
||||
<code>$replicaInfo['Wild_Ignore_Table']</code>
|
||||
<code>$sumSize</code>
|
||||
<code>$tableIsView</code>
|
||||
<code>$trackedTables[$truename] ?? null</code>
|
||||
<code>$truename</code>
|
||||
<code>$updateTime</code>
|
||||
<code>$updateTimeAll</code>
|
||||
@ -14038,12 +14039,13 @@
|
||||
<MixedArrayAssignment occurrences="1">
|
||||
<code>self::$trackingCache[$dbName][$tableName]</code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment occurrences="5">
|
||||
<MixedAssignment occurrences="6">
|
||||
<code>$GLOBALS['db']</code>
|
||||
<code>$data</code>
|
||||
<code>$result['tablename']</code>
|
||||
<code>$trackingEnabled</code>
|
||||
<code>$trackingEnabled</code>
|
||||
<code>$trackingEnabled</code>
|
||||
</MixedAssignment>
|
||||
<MixedInferredReturnType occurrences="1">
|
||||
<code>bool</code>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user