This commit is contained in:
2026-02-02 23:08:53 +01:00
parent 2e53e7e238
commit c063fa695b
2 changed files with 13 additions and 2 deletions

View File

@@ -2266,6 +2266,7 @@ class ApiKernel
$htmlCol = $itemCols['html'];
$jsonCol = $itemCols['json'];
$craftCol = $itemCols['craft'];
$settingsCol = $itemCols['settings'];
$versionsTable = $this->contentVersionsTable();
$versionCols = ($this->tableExists($versionsTable)) ? $this->resolveContentVersionColumns($versionsTable) : null;
@@ -2273,11 +2274,13 @@ class ApiKernel
$versionJsonCol = $versionCols['json'] ?? null;
$versionCraftCol = $versionCols['craft'] ?? null;
$versionActiveCol = $versionCols['is_active'] ?? null;
$versionSettingsCol = $versionCols['settings'] ?? null;
$select = "i.`id` AS id, i.`name` AS name";
if ($htmlCol) $select .= ", i.`$htmlCol` AS item_html";
if ($jsonCol) $select .= ", i.`$jsonCol` AS item_json";
if ($craftCol) $select .= ", i.`$craftCol` AS item_craft";
if ($settingsCol) $select .= ", i.`$settingsCol` AS item_settings";
$join = '';
$hasVersionJoin = $versionActiveCol && ($versionHtmlCol || $versionJsonCol || $versionCraftCol);
if ($hasVersionJoin) {
@@ -2292,6 +2295,9 @@ class ApiKernel
if ($versionCraftCol && $versionActiveCol) {
$select .= ", v.`$versionCraftCol` AS version_craft";
}
if ($versionSettingsCol && $versionActiveCol) {
$select .= ", v.`$versionSettingsCol` AS version_settings";
}
$sql = "SELECT $select FROM `$itemsTable` i $join WHERE i.`customer_id` = :cid AND i.`section_id` = :sid AND i.`id` <> :id";
$stmt = $this->pdo->prepare($sql);
$stmt->execute([':cid' => $customerId, ':sid' => (int)$section['id'], ':id' => $templateId]);
@@ -2305,6 +2311,8 @@ class ApiKernel
(string)($row['item_json'] ?? ''),
(string)($row['version_craft'] ?? ''),
(string)($row['item_craft'] ?? ''),
(string)($row['version_settings'] ?? ''),
(string)($row['item_settings'] ?? ''),
];
$found = false;
foreach ($blobs as $blob) {
@@ -2329,13 +2337,15 @@ class ApiKernel
$htmlCol = $this->firstExisting($allCols, ['html', 'body', 'markup', 'content']);
$jsonCol = $this->firstExisting($allCols, ['json_content']);
$craftCol = $this->firstExisting($allCols, ['craft_json', 'craft_content', 'craft_data']);
if ($htmlCol || $jsonCol || $craftCol) {
$settingsCol = $this->firstExisting($allCols, ['settings_json', 'settings']);
if ($htmlCol || $jsonCol || $craftCol || $settingsCol) {
$nameCol = $this->conf['columns']['templates']['name'] ?? ($this->firstExisting($allCols, ['name']) ?: $idCol);
[$tw, $tp] = $this->tenantWhere(['customer_id' => $customerId]);
$select = "`$idCol` AS id, `$nameCol` AS name";
if ($htmlCol) $select .= ", `$htmlCol` AS html";
if ($jsonCol) $select .= ", `$jsonCol` AS json";
if ($craftCol) $select .= ", `$craftCol` AS craft";
if ($settingsCol) $select .= ", `$settingsCol` AS settings";
$sql = "SELECT $select FROM `$table` WHERE `$idCol` <> :id" . $tw;
$stmt = $this->pdo->prepare($sql);
$stmt->bindValue(':id', $templateId, PDO::PARAM_INT);
@@ -2347,6 +2357,7 @@ class ApiKernel
(string)($row['html'] ?? ''),
(string)($row['json'] ?? ''),
(string)($row['craft'] ?? ''),
(string)($row['settings'] ?? ''),
];
$found = false;
foreach ($blobs as $blob) {