fix: always emit <client> tag in UpdateXmlGenerator, map 0→site 1→administrator
Bulk Repository Sync / Sync Standards to Repositories (push) Successful in 1m16s
Bulk Repository Sync / Sync Standards to Repositories (push) Successful in 1m16s
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
* INGROUP: MokoStandards
|
||||
* REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-API
|
||||
* PATH: /lib/plugins/Joomla/UpdateXmlGenerator.php
|
||||
* VERSION: 04.06.00
|
||||
* VERSION: 04.07.00
|
||||
* BRIEF: Generates and updates Joomla extension updates.xml files
|
||||
*/
|
||||
|
||||
@@ -124,6 +124,20 @@ class UpdateXmlGenerator
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Map numeric client ID to Joomla client name
|
||||
*
|
||||
* @param string $clientId Numeric client ID
|
||||
* @return string Client name for updates.xml
|
||||
*/
|
||||
private function resolveClientName(string $clientId): string
|
||||
{
|
||||
return match ($clientId) {
|
||||
'1' => 'administrator',
|
||||
default => 'site',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an update entry to the XML document
|
||||
*
|
||||
@@ -145,8 +159,22 @@ class UpdateXmlGenerator
|
||||
$this->addElement($dom, $update, 'description', $release['description'] ?? '');
|
||||
$this->addElement($dom, $update, 'element', $this->element);
|
||||
$this->addElement($dom, $update, 'type', $this->extensionType);
|
||||
|
||||
// Folder (for plugins)
|
||||
if (!empty($release['folder'])) {
|
||||
$this->addElement($dom, $update, 'folder', $release['folder']);
|
||||
}
|
||||
|
||||
// Client — always emit for correct extension matching
|
||||
$this->addElement($dom, $update, 'client', $this->resolveClientName($this->clientId));
|
||||
|
||||
$this->addElement($dom, $update, 'version', $release['version']);
|
||||
|
||||
// Creation date
|
||||
if (!empty($release['creation_date'])) {
|
||||
$this->addElement($dom, $update, 'creationDate', $release['creation_date']);
|
||||
}
|
||||
|
||||
// Joomla target platform
|
||||
$infourl = $this->addElement($dom, $update, 'infourl', $release['infourl'] ?? '');
|
||||
if (!empty($release['infourl'])) {
|
||||
@@ -161,6 +189,37 @@ class UpdateXmlGenerator
|
||||
$downloadUrl->setAttribute('type', 'full');
|
||||
$downloadUrl->setAttribute('format', 'zip');
|
||||
|
||||
// Checksums
|
||||
if (!empty($release['sha256'])) {
|
||||
$this->addElement($dom, $update, 'sha256', $release['sha256']);
|
||||
}
|
||||
|
||||
if (!empty($release['sha384'])) {
|
||||
$this->addElement($dom, $update, 'sha384', $release['sha384']);
|
||||
}
|
||||
|
||||
if (!empty($release['sha512'])) {
|
||||
$this->addElement($dom, $update, 'sha512', $release['sha512']);
|
||||
}
|
||||
|
||||
// Tags
|
||||
if (!empty($release['tags'])) {
|
||||
$tags = $dom->createElement('tags');
|
||||
$update->appendChild($tags);
|
||||
foreach ($release['tags'] as $tag) {
|
||||
$this->addElement($dom, $tags, 'tag', $tag);
|
||||
}
|
||||
}
|
||||
|
||||
// Maintainer information
|
||||
if (!empty($release['maintainer'])) {
|
||||
$this->addElement($dom, $update, 'maintainer', $release['maintainer']);
|
||||
}
|
||||
|
||||
if (!empty($release['maintainer_url'])) {
|
||||
$this->addElement($dom, $update, 'maintainerurl', $release['maintainer_url']);
|
||||
}
|
||||
|
||||
// Target platform
|
||||
if (!empty($release['target_platform'])) {
|
||||
$targetPlatform = $dom->createElement('targetplatform');
|
||||
@@ -174,42 +233,6 @@ class UpdateXmlGenerator
|
||||
$this->addElement($dom, $update, 'php_minimum', $release['php_minimum']);
|
||||
}
|
||||
|
||||
// Optional: Tags
|
||||
if (!empty($release['tags'])) {
|
||||
$tags = $dom->createElement('tags');
|
||||
$update->appendChild($tags);
|
||||
foreach ($release['tags'] as $tag) {
|
||||
$this->addElement($dom, $tags, 'tag', $tag);
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Maintainer information
|
||||
if (!empty($release['maintainer'])) {
|
||||
$this->addElement($dom, $update, 'maintainer', $release['maintainer']);
|
||||
}
|
||||
|
||||
if (!empty($release['maintainer_url'])) {
|
||||
$this->addElement($dom, $update, 'maintainerurl', $release['maintainer_url']);
|
||||
}
|
||||
|
||||
// Optional: Client (site or administrator)
|
||||
if ($this->clientId !== '0') {
|
||||
$this->addElement($dom, $update, 'client', $this->clientId);
|
||||
}
|
||||
|
||||
// Optional: Checksums
|
||||
if (!empty($release['sha256'])) {
|
||||
$this->addElement($dom, $update, 'sha256', $release['sha256']);
|
||||
}
|
||||
|
||||
if (!empty($release['sha384'])) {
|
||||
$this->addElement($dom, $update, 'sha384', $release['sha384']);
|
||||
}
|
||||
|
||||
if (!empty($release['sha512'])) {
|
||||
$this->addElement($dom, $update, 'sha512', $release['sha512']);
|
||||
}
|
||||
|
||||
// Add to updates element
|
||||
if ($prepend && $updates->firstChild) {
|
||||
$updates->insertBefore($update, $updates->firstChild);
|
||||
@@ -312,6 +335,11 @@ class UpdateXmlGenerator
|
||||
}
|
||||
}
|
||||
|
||||
// Warn if <client> is missing
|
||||
if ($update->getElementsByTagName('client')->length === 0) {
|
||||
$errors[] = "Missing <client> tag — Joomla may not match this update to the installed extension";
|
||||
}
|
||||
|
||||
// Check for download URL
|
||||
$downloads = $update->getElementsByTagName('downloads');
|
||||
if ($downloads->length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user