feat(cache): auto-clear Joomla cache on content/extension save
Universal: PR Check / Branch Policy (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 9s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Universal: Auto Version Bump / Version Bump (push) Successful in 17s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 14s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 16s
Generic: Project CI / Lint & Validate (pull_request) Successful in 35s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 35s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 37s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 44s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Project CI / Tests (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Has been cancelled
Platform: moko-platform CI / CI Summary (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report Issues (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 9s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Universal: Auto Version Bump / Version Bump (push) Successful in 17s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 14s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 16s
Generic: Project CI / Lint & Validate (pull_request) Successful in 35s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 35s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 37s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 44s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Project CI / Tests (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Has been cancelled
Platform: moko-platform CI / CI Summary (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report Issues (pull_request) Has been cancelled
- autoClearCache() called from onContentAfterSave and onExtensionAfterSave
- Controlled by auto_clear_cache param (default: off)
- Clears all cache groups via Cache::getInstance()->clean('')
- Silent failure — never breaks save operations
This commit is contained in:
@@ -186,12 +186,15 @@ class MokoSuiteClient extends CMSPlugin implements BootableExtensionInterface
|
||||
*/
|
||||
public function onExtensionAfterSave($context, $table, $isNew)
|
||||
{
|
||||
// Auto-clear cache on any extension save (#181)
|
||||
$this->autoClearCache();
|
||||
|
||||
if ($context !== 'com_plugins.plugin')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only act on our own plugin
|
||||
// Only act on our own plugin for the rest of this handler
|
||||
if ($table->element !== 'mokosuiteclient' || $table->folder !== 'system')
|
||||
{
|
||||
return;
|
||||
@@ -2522,6 +2525,9 @@ class MokoSuiteClient extends CMSPlugin implements BootableExtensionInterface
|
||||
*/
|
||||
public function onContentAfterSave($context, $article, $isNew): void
|
||||
{
|
||||
// Auto-clear cache on content save (#181)
|
||||
$this->autoClearCache();
|
||||
|
||||
if ($context !== 'com_content.article') return;
|
||||
|
||||
class_exists(\Moko\Component\MokoSuiteClient\Administrator\Service\AutomationEngine::class, true) && \Moko\Component\MokoSuiteClient\Administrator\Service\AutomationEngine::fire('content_save', [
|
||||
@@ -2863,4 +2869,39 @@ class MokoSuiteClient extends CMSPlugin implements BootableExtensionInterface
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Cache Auto-Clear (#181)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clear all Joomla cache groups when the auto_clear_cache param is enabled.
|
||||
*
|
||||
* Called from onContentAfterSave and onExtensionAfterSave so that
|
||||
* front-end visitors always see fresh content after an admin save.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 02.47.50
|
||||
*/
|
||||
private function autoClearCache(): void
|
||||
{
|
||||
if (!$this->params->get('auto_clear_cache', 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$cacheController = \Joomla\CMS\Cache\Cache::getInstance('', ['defaultgroup' => '']);
|
||||
$cacheController->clean('');
|
||||
|
||||
Log::add('Cache auto-cleared on save.', Log::DEBUG, 'mokosuiteclient');
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
// Silent — never break save operations
|
||||
Log::add('Cache auto-clear failed: ' . $e->getMessage(), Log::WARNING, 'mokosuiteclient');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,15 @@
|
||||
description="PLG_SYSTEM_MOKOSUITECLIENT_MONITOR_BASE_URL_DESC"
|
||||
filter="url" />
|
||||
|
||||
<field name="monitor_signing_key" type="hidden"
|
||||
<field name="auto_clear_cache" type="radio" default="0"
|
||||
label="Auto-Clear Cache on Save"
|
||||
description="Automatically clear Joomla cache when articles, modules, or extensions are saved."
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field name="monitor_signing_key" type="hidden"
|
||||
default="LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2QUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktZd2dnU2lBZ0VBQW9JQkFRQ2xZNnNzOTZpeTZOOGMKTHRxbndhbnU4eEozdDcrdDhXT3hoY0Yyclc2QmlmOVhNaEpnYkw0c055N0wwV1dTT2tkMmZxalBNcDFtOFNyNAo1VnNycjE3cFc5b0FNMmtmdFdsaTZ1NkhTVEYyN2pVVUJrT3o4MHZMRklMMGNGNkJCUkpYN2JVWkRpamdUMjc1ClREb3dXZy82Zk9GeWFEelBHUkJuYXFacTljU2lEYWoyNlpSTVZIbktQUERWTG92VzRPTDQzL2gwZ3BtN25nUGIKdWJlLzFFTDR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