Merge pull request 'fix: honest installer success for package postflight' (#76) 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

This commit was merged in pull request #76.
This commit is contained in:
2026-07-06 16:17:49 +00:00
11 changed files with 119 additions and 9 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
# FILE INFORMATION
# DEFGROUP: Gitea.Workflow
# INGROUP: mokocli.Automation
# VERSION: 01.01.03
# VERSION: 01.02.02
# BRIEF: Auto-create feature branch when an issue is opened
name: "Universal: Issue Branch"
+1
View File
@@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- SQL migration compatibility: removed `DROP COLUMN IF EXISTS` (MySQL 8.0.13+ only) in favor of plain `DROP COLUMN`
- Honest installer success: package postflight now verifies every bundled child extension (component, modules, plugin) actually landed in `#__extensions` before showing the license/next-steps message; if any is missing it shows an error and suppresses the success message instead of reporting a false success. Fails open so a transient DB/IO glitch never fakes a failure.
## [1.1.0] - 2026-06-23
+1 -1
View File
@@ -14,7 +14,7 @@
DEFGROUP:
INGROUP: Project.Documentation
REPO:
VERSION: 01.01.03
VERSION: 01.02.02
PATH: ./CODE_OF_CONDUCT.md
BRIEF: Reference + packaging repo for Moko Consulting Developer GPT Other Default
-->
+1 -1
View File
@@ -19,7 +19,7 @@
DEFGROUP: mokoconsulting-tech.Template-Joomla
INGROUP: MokoStandards.Governance
REPO: https://github.com/mokoconsulting-tech/Template-Joomla
VERSION: 01.01.03
VERSION: 01.02.02
PATH: /GOVERNANCE.md
BRIEF: Project governance rules, roles, and decision process for Template-Joomla
-->
+1 -1
View File
@@ -23,7 +23,7 @@ DEFGROUP: [PROJECT_NAME]
INGROUP: [PROJECT_NAME].Documentation
REPO: [REPOSITORY_URL]
PATH: /SECURITY.md
VERSION: 01.01.03
VERSION: 01.02.02
BRIEF: Security vulnerability reporting and handling policy
-->
@@ -15,7 +15,7 @@
-->
<extension type="component" method="upgrade">
<name>com_mokosuitestorelocator</name>
<version>01.01.03</version>
<version>01.02.02</version>
<creationDate>2026-06-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
@@ -14,7 +14,7 @@
-->
<extension type="module" client="site" method="upgrade">
<name>mod_mokosuitestorelocator_map</name>
<version>01.01.03</version>
<version>01.02.02</version>
<creationDate>2026-06-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
@@ -14,7 +14,7 @@
-->
<extension type="module" client="site" method="upgrade">
<name>mod_mokosuitestorelocator_search</name>
<version>01.01.03</version>
<version>01.02.02</version>
<creationDate>2026-06-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
@@ -5,7 +5,7 @@
========================================================================= -->
<extension type="plugin" group="webservices" method="upgrade">
<name>plg_webservices_mokosuitestorelocator</name>
<version>01.01.03</version>
<version>01.02.02</version>
<creationDate>2026-06-24</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
+1 -1
View File
@@ -18,7 +18,7 @@
<extension type="package" method="upgrade">
<name>MokoSuite Store Locator</name>
<packagename>mokosuitestorelocator</packagename>
<version>01.01.03</version>
<version>01.02.02</version>
<creationDate>2026-06-23</creationDate>
<author>Moko Consulting</author>
<authorEmail>hello@mokoconsulting.tech</authorEmail>
+109
View File
@@ -128,12 +128,121 @@ class Pkg_MokosuitestorelocatorInstallerScript implements InstallerScriptInterfa
*/
public function postflight(string $type, InstallerAdapter $parent): bool
{
// Housekeeping runs unconditionally.
$this->restoreDownloadKey();
// 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($parent);
if (!empty($missing))
{
\Joomla\CMS\Factory::getApplication()->enqueueMessage(
'<h4>MokoSuiteStoreLocator did not install correctly.</h4>'
. '<p>The following bundled extensions are missing: '
. htmlspecialchars(implode(', ', $missing), ENT_QUOTES) . '</p>'
. '<p>Please uninstall MokoSuiteStoreLocator and reinstall the full package.</p>',
'error'
);
return true;
}
// Success / next-steps path — only reached when every child installed.
$this->warnMissingLicenseKey();
return true;
}
/**
* 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 = the <file> "type" attribute
* - element = the <file> "id" attribute, EXCEPT for plugins the manifest often
* declares the full `plg_<group>_<element>` id, so strip a leading
* `plg_<group>_` to get the real element; components/modules use id as-is
* - plugins ALSO match folder = the <file> "group" attribute
*
* FAILS OPEN: any error (unreadable manifest, query failure) returns [] so a
* transient glitch never turns a good install into a false failure.
*
* @param InstallerAdapter $parent The parent installer object.
*
* @return array Readable labels of missing child extensions.
*
* @since 1.0.0
*/
private function missingChildExtensions(InstallerAdapter $parent): array
{
try
{
$manifest = $parent->getParent()->getManifest();
if (!$manifest || !isset($manifest->files) || !isset($manifest->files->file))
{
return [];
}
$db = \Joomla\CMS\Factory::getDbo();
$missing = [];
foreach ($manifest->files->file as $file)
{
$attrs = $file->attributes();
$id = isset($attrs['id']) ? (string) $attrs['id'] : '';
$exType = isset($attrs['type']) ? (string) $attrs['type'] : '';
if ($id === '' || $exType === '')
{
continue;
}
$group = isset($attrs['group']) ? (string) $attrs['group'] : '';
$element = $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)
->select('COUNT(*)')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('element') . ' = ' . $db->quote($element))
->where($db->quoteName('type') . ' = ' . $db->quote($exType));
if ($exType === 'plugin' && $group !== '')
{
$query->where($db->quoteName('folder') . ' = ' . $db->quote($group));
}
if ((int) $db->setQuery($query)->loadResult() === 0)
{
$label = trim((string) $file);
$missing[] = $label !== '' ? preg_replace('/\.zip$/i', '', $label) : $id;
}
}
return $missing;
}
catch (\Throwable $e)
{
// Fail open — never fake a failure on a glitch.
return [];
}
}
private ?string $savedDownloadKey = null;
private function saveDownloadKey(): void