Compare commits

..

3 Commits

Author SHA1 Message Date
jmiller b3bb63c8dc Merge pull request 'fix: honest installer success' (#46) from fix/honest-install-success into dev
Universal: Auto Version Bump / Version Bump (push) Has been skipped
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 20s
2026-07-06 16:23:12 +00:00
gitea-actions[bot] 4212ce1ded chore(version): pre-release bump to 06.00.21-dev [skip ci]
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
2026-07-06 16:20:48 +00:00
jmiller 0e3c922b7a fix: honest installer success (gate license/next-steps on child install)
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Failing after 5s
Universal: PR Check / Secret Scan (pull_request) Successful in 5s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 12s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 31s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
The package postflight showed the "License Key Required" / next-steps
message even when a bundled child extension failed to sub-install
(Joomla only logs those failures). Add a fail-open manifest verifier
(missingChildExtensions) that confirms every declared child landed in
#__extensions and enqueues an error + returns before the license path
when any are missing. Fails open so a transient glitch never fakes a
failure.

Claude-Session: https://claude.ai/code/session_01B9aZHSWbiiZykJD88pYx8R
2026-07-06 11:19:37 -05:00
7 changed files with 65 additions and 133 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: 06.00.19 # VERSION: 06.00.21
# 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
@@ -11,6 +11,9 @@
## [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
- **Repository** -- initial repo creation with scaffolding - **Repository** -- initial repo creation with scaffolding
- **System Plugin** -- Extension class, service provider - **System Plugin** -- Extension class, service provider
@@ -5,7 +5,7 @@
<creationDate>2026-06-27</creationDate> <creationDate>2026-06-27</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>06.00.19</version> <version>06.00.21</version>
<namespace path="src">Moko\Component\MokoSuiteField</namespace> <namespace path="src">Moko\Component\MokoSuiteField</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>
@@ -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>06.00.19</version> <version>06.00.21</version>
<php_minimum>8.3</php_minimum> <php_minimum>8.3</php_minimum>
<description>PLG_SYSTEM_MOKOSUITEFIELD_DESC</description> <description>PLG_SYSTEM_MOKOSUITEFIELD_DESC</description>
<namespace path="src">Moko\Plugin\System\MokoSuiteField</namespace> <namespace path="src">Moko\Plugin\System\MokoSuiteField</namespace>
@@ -3,7 +3,7 @@
<name>Web Services - MokoSuite Field</name> <name>Web Services - MokoSuite Field</name>
<element>mokosuitefield</element> <element>mokosuitefield</element>
<author>Moko Consulting</author> <author>Moko Consulting</author>
<version>06.00.19</version> <version>06.00.21</version>
<license>GPL-3.0-or-later</license> <license>GPL-3.0-or-later</license>
<namespace path="src">Moko\Plugin\WebServices\MokoSuiteField</namespace> <namespace path="src">Moko\Plugin\WebServices\MokoSuiteField</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 Field</name> <name>Package - MokoSuite Field</name>
<packagename>mokosuitefield</packagename> <packagename>mokosuitefield</packagename>
<version>06.00.19</version> <version>06.00.21</version>
<creationDate>2026-06-27</creationDate> <creationDate>2026-06-27</creationDate>
<author>Moko Consulting</author> <author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail> <authorEmail>hello@mokoconsulting.tech</authorEmail>
+57 -128
View File
@@ -1,10 +1,9 @@
<?php <?php
/** /**
* MokoSuite Field Package Install Script * @package MokoSuiteField
* * @subpackage pkg_mokosuitefield
* @package MokoSuite Field
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved. * @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GPL-3.0-or-later * @license GNU General Public License version 3 or later; see LICENSE
*/ */
defined('_JEXEC') or die; defined('_JEXEC') or die;
@@ -12,99 +11,97 @@ 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\CMS\Log\Log;
use Joomla\Database\DatabaseInterface;
class Pkg_MokoSuiteFieldInstallerScript class Pkg_MokoSuiteFieldInstallerScript
{ {
private string $savedDlid = '';
public function preflight(string $type, InstallerAdapter $adapter): bool
{
if ($type === 'update')
{
$this->savedDlid = $this->getExistingDlid();
}
return true;
}
public function postflight(string $type, InstallerAdapter $adapter): void public function postflight(string $type, InstallerAdapter $adapter): void
{ {
if ($this->savedDlid) // Be honest about success. Joomla's package installer only LOGS a failed child
// 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))
{ {
$this->restoreDlid($this->savedDlid); Factory::getApplication()->enqueueMessage(
} '<h4>MokoSuiteField did not install correctly.</h4>'
. '<p>The following bundled extensions are missing: '
. htmlspecialchars(implode(', ', $missing), ENT_QUOTES) . '</p>'
. '<p>Please uninstall MokoSuiteField and reinstall the full package.</p>',
'error'
);
if ($type === 'install') return;
{
$missing = $this->verifyChildren($adapter);
if (!empty($missing))
{
Factory::getApplication()->enqueueMessage(
'<strong>MokoSuite Field — 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', 'mokosuitefield');
$this->enablePlugin('webservices', 'mokosuitefield');
} }
$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 (!$files) if (!$manifest || !isset($manifest->files) || !isset($manifest->files->file))
{ {
return []; return [];
} }
$db = Factory::getContainer()->get(DatabaseInterface::class); $db = Factory::getDbo();
$missing = []; $missing = [];
foreach ($files as $file) foreach ($manifest->files->file as $file)
{ {
$type = (string) ($file['type'] ?? ''); $attrs = $file->attributes();
$id = (string) ($file['id'] ?? ''); $id = isset($attrs['id']) ? (string) $attrs['id'] : '';
$group = (string) ($file['group'] ?? ''); $exType = isset($attrs['type']) ? (string) $attrs['type'] : '';
if ($type === '' || $id === '') if ($id === '' || $exType === '')
{ {
continue; continue;
} }
$element = ($type === 'plugin' && $group !== '') $group = isset($attrs['group']) ? (string) $attrs['group'] : '';
? preg_replace('/^plg_' . preg_quote($group, '/') . '_/', '', $id) $element = $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($type)); ->where($db->quoteName('type') . ' = ' . $db->quote($exType));
if ($type === 'plugin' && $group !== '') if ($exType === 'plugin' && $group !== '')
{ {
$query->where($db->quoteName('folder') . ' = ' . $db->quote($group)); $query->where($db->quoteName('folder') . ' = ' . $db->quote($group));
} }
$db->setQuery($query); if ((int) $db->setQuery($query)->loadResult() === 0)
if ((int) $db->loadResult() === 0)
{ {
$missing[] = htmlspecialchars($type . ': ' . $id, ENT_QUOTES, 'UTF-8'); $label = trim((string) $file);
$missing[] = $label !== '' ? preg_replace('/\.zip$/i', '', $label) : $id;
} }
} }
@@ -112,85 +109,16 @@ class Pkg_MokoSuiteFieldInstallerScript
} }
catch (\Throwable $e) catch (\Throwable $e)
{ {
// Fail open — never fake a failure on a glitch.
return []; return [];
} }
} }
private function getExistingDlid(): string
{
try
{
$db = Factory::getContainer()->get(DatabaseInterface::class);
$db->setQuery(
$db->getQuery(true)
->select($db->quoteName('extra_query'))
->from($db->quoteName('#__update_sites'))
->where('(' . $db->quoteName('name') . ' LIKE ' . $db->quote('%MokoSuiteField%')
. ' OR ' . $db->quoteName('location') . ' LIKE ' . $db->quote('%MokoSuiteField%') . ')')
->setLimit(1)
);
$extraQuery = $db->loadResult() ?? '';
if (preg_match('/dlid=([a-zA-Z0-9]+)/', $extraQuery, $matches))
{
return $matches[1];
}
}
catch (\Throwable $e)
{
Log::add('Field install: failed to read DLID — ' . $e->getMessage(), Log::WARNING, 'mokosuite.field');
}
return '';
}
private function restoreDlid(string $dlid): void
{
try
{
$db = Factory::getContainer()->get(DatabaseInterface::class);
$db->setQuery(
$db->getQuery(true)
->update($db->quoteName('#__update_sites'))
->set($db->quoteName('extra_query') . ' = ' . $db->quote('dlid=' . $dlid))
->where('(' . $db->quoteName('name') . ' LIKE ' . $db->quote('%MokoSuiteField%')
. ' OR ' . $db->quoteName('location') . ' LIKE ' . $db->quote('%MokoSuiteField%') . ')')
);
$db->execute();
}
catch (\Throwable $e)
{
Log::add('Field install: failed to restore DLID — ' . $e->getMessage(), Log::WARNING, 'mokosuite.field');
}
}
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)
{
Log::add('Field install: failed to enable ' . $group . '/' . $element . ' — ' . $e->getMessage(), Log::WARNING, 'mokosuite.field');
}
}
private function warnMissingLicenseKey(): void private function warnMissingLicenseKey(): void
{ {
try try
{ {
$db = Factory::getContainer()->get(DatabaseInterface::class); $db = Factory::getDbo();
$app = Factory::getApplication(); $app = Factory::getApplication();
$query = $db->getQuery(true) $query = $db->getQuery(true)
@@ -232,6 +160,7 @@ class Pkg_MokoSuiteFieldInstallerScript
} }
catch (\Throwable $e) catch (\Throwable $e)
{ {
// Silent — avoid breaking install if update_sites query fails
} }
} }
} }