2 Commits

Author SHA1 Message Date
jmiller 8e18c887c4 refactor(installer): replace hardcoded extension list with dynamic manifest verification
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Failing after 4s
Universal: PR Check / Secret Scan (pull_request) Successful in 4s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 8s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Read package manifest via $adapter->getParent()->getManifest() to discover
children dynamically instead of maintaining a hardcoded EXPECTED_EXTENSIONS
array. Fail-open pattern wraps verification in try/catch. Only the success
path (plugin enables, license warning) is gated; unconditional housekeeping
(DLID restore) runs regardless.

Claude-Session: https://claude.ai/code/session_01CwLGvFJPjoPTp9BEnSjtJf
2026-07-06 10:46:02 -05:00
jmiller 4462063e10 feat: add post-install verification to detect failed sub-extensions
Universal: PR Check / Branch Policy (pull_request) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Failing after 5s
Universal: PR Check / Secret Scan (pull_request) Successful in 8s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 42s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Checks that all expected component and plugins registered in
#__extensions after install. Disables the package entry and shows
an error if any sub-extension failed to install.

Claude-Session: https://claude.ai/code/session_01CwLGvFJPjoPTp9BEnSjtJf
2026-07-05 22:32:57 -05:00
11 changed files with 70 additions and 79 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
# FILE INFORMATION # FILE INFORMATION
# DEFGROUP: Gitea.Workflow # DEFGROUP: Gitea.Workflow
# INGROUP: mokocli.Automation # INGROUP: mokocli.Automation
# VERSION: 01.00.40 # VERSION: 01.00.36
# BRIEF: Auto-create feature branch when an issue is opened # BRIEF: Auto-create feature branch when an issue is opened
name: "Universal: Issue Branch" name: "Universal: Issue Branch"
-3
View File
@@ -9,9 +9,6 @@
## [Unreleased] ## [Unreleased]
### Fixed
- **Honest install success** — the package installer no longer shows the license / next-steps message when a bundled child extension failed to install. A fail-open manifest verifier confirms every child extension landed in `#__extensions` and reports any that are missing.
### Added ### Added
- **Package Manifest** — `pkg_mokosuiterealty.xml` with dlid and updateservers - **Package Manifest** — `pkg_mokosuiterealty.xml` with dlid and updateservers
- **Plugin Manifest** — `mokosuiterealty.xml` with config fieldsets (listing defaults, search settings) - **Plugin Manifest** — `mokosuiterealty.xml` with config fieldsets (listing defaults, search settings)
+1 -1
View File
@@ -14,7 +14,7 @@
DEFGROUP: Template-Joomla DEFGROUP: Template-Joomla
INGROUP: Template-Joomla.Documentation INGROUP: Template-Joomla.Documentation
REPO: https://github.com/mokoconsulting-tech/Template-Joomla/ REPO: https://github.com/mokoconsulting-tech/Template-Joomla/
VERSION: 01.00.40 VERSION: 01.00.36
PATH: ./CODE_OF_CONDUCT.md PATH: ./CODE_OF_CONDUCT.md
BRIEF: Community expectations and enforcement guidelines BRIEF: Community expectations and enforcement guidelines
NOTE: Adapted with attribution from the Contributor Covenant v2.1 NOTE: Adapted with attribution from the Contributor Covenant v2.1
+1 -1
View File
@@ -19,7 +19,7 @@
DEFGROUP: mokoconsulting-tech.Template-Joomla DEFGROUP: mokoconsulting-tech.Template-Joomla
INGROUP: MokoStandards.Governance INGROUP: MokoStandards.Governance
REPO: https://github.com/mokoconsulting-tech/Template-Joomla REPO: https://github.com/mokoconsulting-tech/Template-Joomla
VERSION: 01.00.40 VERSION: 01.00.36
PATH: /GOVERNANCE.md PATH: /GOVERNANCE.md
BRIEF: Project governance rules, roles, and decision process for Template-Joomla BRIEF: Project governance rules, roles, and decision process for Template-Joomla
--> -->
+1 -1
View File
@@ -23,7 +23,7 @@ DEFGROUP: Template-Joomla
INGROUP: Template-Joomla.Documentation INGROUP: Template-Joomla.Documentation
REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Joomla REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Joomla
PATH: /SECURITY.md PATH: /SECURITY.md
VERSION: 01.00.40 VERSION: 01.00.36
BRIEF: Security vulnerability reporting and handling policy BRIEF: Security vulnerability reporting and handling policy
--> -->
@@ -1,3 +0,0 @@
COM_MOKOSUITEREALTY="MokoSuite Realty"
COM_MOKOSUITEREALTY_SHORT="Realty"
COM_MOKOSUITEREALTY_XML_DESCRIPTION="MokoSuite Realty component."
@@ -5,13 +5,10 @@
<creationDate>2026-06-23</creationDate> <creationDate>2026-06-23</creationDate>
<copyright>Copyright (C) 2026 Moko Consulting.</copyright> <copyright>Copyright (C) 2026 Moko Consulting.</copyright>
<license>GPL-3.0-or-later</license> <license>GPL-3.0-or-later</license>
<version>01.00.40</version> <version>01.00.36</version>
<namespace path="src">Moko\Component\MokoSuiteRealty</namespace> <namespace path="src">Moko\Component\MokoSuiteRealty</namespace>
<administration> <administration>
<files folder="admin"><folder>services</folder><folder>src</folder><folder>tmpl</folder></files> <files folder="admin"><folder>services</folder><folder>src</folder><folder>tmpl</folder></files>
<menu>COM_MOKOSUITEREALTY_SHORT</menu> <menu>COM_MOKOSUITEREALTY</menu>
<languages folder="admin/language">
<language tag="en-GB">en-GB/com_mokosuiterealty.sys.ini</language>
</languages>
</administration> </administration>
</extension> </extension>
@@ -8,7 +8,7 @@
<license>GPL-3.0-or-later</license> <license>GPL-3.0-or-later</license>
<authorEmail>hello@mokoconsulting.tech</authorEmail> <authorEmail>hello@mokoconsulting.tech</authorEmail>
<authorUrl>https://mokoconsulting.tech</authorUrl> <authorUrl>https://mokoconsulting.tech</authorUrl>
<version>01.00.40</version> <version>01.00.36</version>
<php_minimum>8.3</php_minimum> <php_minimum>8.3</php_minimum>
<description>PLG_SYSTEM_MOKOSUITEREALTY_DESC</description> <description>PLG_SYSTEM_MOKOSUITEREALTY_DESC</description>
<namespace path="src">Moko\Plugin\System\MokoSuiteRealty</namespace> <namespace path="src">Moko\Plugin\System\MokoSuiteRealty</namespace>
@@ -3,7 +3,7 @@
<name>Web Services - MokoSuite Realty</name> <name>Web Services - MokoSuite Realty</name>
<element>mokosuiterealty</element> <element>mokosuiterealty</element>
<author>Moko Consulting</author> <author>Moko Consulting</author>
<version>01.00.40</version> <version>01.00.36</version>
<license>GPL-3.0-or-later</license> <license>GPL-3.0-or-later</license>
<namespace path="src">Moko\Plugin\WebServices\MokoSuiteRealty</namespace> <namespace path="src">Moko\Plugin\WebServices\MokoSuiteRealty</namespace>
<files><folder>src</folder><folder>services</folder></files> <files><folder>src</folder><folder>services</folder></files>
+1 -1
View File
@@ -2,7 +2,7 @@
<extension type="package" method="upgrade"> <extension type="package" method="upgrade">
<name>Package - MokoSuite Realty</name> <name>Package - MokoSuite Realty</name>
<packagename>mokosuiterealty</packagename> <packagename>mokosuiterealty</packagename>
<version>01.00.40</version> <version>01.00.36</version>
<creationDate>2026-06-21</creationDate> <creationDate>2026-06-21</creationDate>
<author>Moko Consulting</author> <author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail> <authorEmail>hello@mokoconsulting.tech</authorEmail>
+61 -61
View File
@@ -1,110 +1,92 @@
<?php <?php
/** /**
* @package MokoSuiteRealty * MokoSuite Realty Package Install Script
* @subpackage pkg_mokosuiterealty *
* @package MokoSuite Realty
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved. * @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE * @license GPL-3.0-or-later
*/ */
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Factory; use Joomla\CMS\Factory;
use Joomla\CMS\Installer\InstallerAdapter; use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Log\Log; use Joomla\Database\DatabaseInterface;
/**
* Package installation script for MokoSuiteRealty.
*/
class Pkg_MokoSuiteRealtyInstallerScript class Pkg_MokoSuiteRealtyInstallerScript
{ {
public function postflight(string $type, InstallerAdapter $adapter): void public function postflight(string $type, InstallerAdapter $adapter): void
{ {
// Be honest about success. Joomla's package installer only LOGS a failed child if ($type === 'install')
// sub-install but still runs this postflight, so don't show the license /
// next-steps message if a bundled extension is actually missing. Fails open
// (see missingChildExtensions) so a query/IO glitch never fakes a failure.
$missing = $this->missingChildExtensions($adapter);
if (!empty($missing))
{ {
Factory::getApplication()->enqueueMessage( $missing = $this->verifyChildren($adapter);
'<h4>MokoSuiteRealty did not install correctly.</h4>'
. '<p>The following bundled extensions are missing: '
. htmlspecialchars(implode(', ', $missing), ENT_QUOTES) . '</p>'
. '<p>Please uninstall MokoSuiteRealty and reinstall the full package.</p>',
'error'
);
return; if (!empty($missing))
{
Factory::getApplication()->enqueueMessage(
'<strong>MokoSuite Realty — Incomplete Installation</strong><br>'
. 'The following extensions failed to install: '
. implode(', ', $missing)
. '.<br>Please check file permissions and server logs, then reinstall the package.',
'error'
);
return;
}
$this->enablePlugin('system', 'mokosuiterealty');
$this->enablePlugin('webservices', 'mokosuiterealty');
} }
$this->warnMissingLicenseKey(); $this->warnMissingLicenseKey();
} }
/** private function verifyChildren(InstallerAdapter $adapter): array
* Verify every child extension declared in the package manifest actually landed in
* #__extensions. Returns readable labels of any that are missing.
*
* Matching per Joomla's #__extensions uniqueness: type = <file> "type"; element =
* <file> "id" (for plugins, strip a leading plg_<group>_); plugins also match
* folder = <file> "group".
*
* FAILS OPEN: any error returns [] so a transient glitch never fakes a failure.
*/
private function missingChildExtensions($adapter): array
{ {
try try
{ {
$manifest = $adapter->getParent()->getManifest(); $manifest = $adapter->getParent()->getManifest();
$files = $manifest->files->file ?? [];
if (!$manifest || !isset($manifest->files) || !isset($manifest->files->file)) if (!$files)
{ {
return []; return [];
} }
$db = Factory::getDbo(); $db = Factory::getContainer()->get(DatabaseInterface::class);
$missing = []; $missing = [];
foreach ($manifest->files->file as $file) foreach ($files as $file)
{ {
$attrs = $file->attributes(); $type = (string) ($file['type'] ?? '');
$id = isset($attrs['id']) ? (string) $attrs['id'] : ''; $id = (string) ($file['id'] ?? '');
$exType = isset($attrs['type']) ? (string) $attrs['type'] : ''; $group = (string) ($file['group'] ?? '');
if ($id === '' || $exType === '') if ($type === '' || $id === '')
{ {
continue; continue;
} }
$group = isset($attrs['group']) ? (string) $attrs['group'] : ''; $element = ($type === 'plugin' && $group !== '')
$element = $id; ? preg_replace('/^plg_' . preg_quote($group, '/') . '_/', '', $id)
: $id;
// Plugin element in #__extensions is the id minus any leading plg_<group>_.
if ($exType === 'plugin' && $group !== '')
{
$prefix = 'plg_' . $group . '_';
if (strpos($element, $prefix) === 0)
{
$element = substr($element, \strlen($prefix));
}
}
$query = $db->getQuery(true) $query = $db->getQuery(true)
->select('COUNT(*)') ->select('COUNT(*)')
->from($db->quoteName('#__extensions')) ->from($db->quoteName('#__extensions'))
->where($db->quoteName('element') . ' = ' . $db->quote($element)) ->where($db->quoteName('element') . ' = ' . $db->quote($element))
->where($db->quoteName('type') . ' = ' . $db->quote($exType)); ->where($db->quoteName('type') . ' = ' . $db->quote($type));
if ($exType === 'plugin' && $group !== '') if ($type === 'plugin' && $group !== '')
{ {
$query->where($db->quoteName('folder') . ' = ' . $db->quote($group)); $query->where($db->quoteName('folder') . ' = ' . $db->quote($group));
} }
if ((int) $db->setQuery($query)->loadResult() === 0) $db->setQuery($query);
if ((int) $db->loadResult() === 0)
{ {
$label = trim((string) $file); $missing[] = htmlspecialchars($type . ': ' . $id, ENT_QUOTES, 'UTF-8');
$missing[] = $label !== '' ? preg_replace('/\.zip$/i', '', $label) : $id;
} }
} }
@@ -112,16 +94,35 @@ class Pkg_MokoSuiteRealtyInstallerScript
} }
catch (\Throwable $e) catch (\Throwable $e)
{ {
// Fail open — never fake a failure on a glitch.
return []; return [];
} }
} }
private function enablePlugin(string $group, string $element): void
{
try
{
$db = Factory::getContainer()->get(DatabaseInterface::class);
$db->setQuery(
$db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote($group))
->where($db->quoteName('element') . ' = ' . $db->quote($element))
);
$db->execute();
}
catch (\Throwable $e)
{
}
}
private function warnMissingLicenseKey(): void private function warnMissingLicenseKey(): void
{ {
try try
{ {
$db = Factory::getDbo(); $db = Factory::getContainer()->get(DatabaseInterface::class);
$app = Factory::getApplication(); $app = Factory::getApplication();
$query = $db->getQuery(true) $query = $db->getQuery(true)
@@ -163,7 +164,6 @@ class Pkg_MokoSuiteRealtyInstallerScript
} }
catch (\Throwable $e) catch (\Throwable $e)
{ {
// Silent — avoid breaking install if update_sites query fails
} }
} }
} }