diff --git a/src/packages/com_mokowaas/admin/src/Model/DashboardModel.php b/src/packages/com_mokowaas/admin/src/Model/DashboardModel.php index d140e9e9..da4ce417 100644 --- a/src/packages/com_mokowaas/admin/src/Model/DashboardModel.php +++ b/src/packages/com_mokowaas/admin/src/Model/DashboardModel.php @@ -267,44 +267,18 @@ class DashboardModel extends BaseDatabaseModel { try { - // Purge all file-based cache directories - $root = JPATH_ROOT; - $dirs = [ - $root . '/cache', - $root . '/administrator/cache', + // Use Joomla's native cache API — same as com_cache + $cache = Factory::getContainer()->get(\Joomla\CMS\Cache\CacheControllerFactoryInterface::class); + $cache->createCacheController('', ['defaultgroup' => ''])->cache->clean(''); + + // Also clean admin cache + $conf = Factory::getApplication()->get('cache_handler', 'file'); + $options = [ + 'defaultgroup' => '', + 'cachebase' => JPATH_ADMINISTRATOR . '/cache', + 'storage' => $conf, ]; - - foreach ($dirs as $dir) - { - if (!is_dir($dir)) - { - continue; - } - - $it = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), - \RecursiveIteratorIterator::CHILD_FIRST - ); - - foreach ($it as $file) - { - $name = $file->getFilename(); - - if ($name === 'index.html' || $name === '.htaccess') - { - continue; - } - - if ($file->isDir()) - { - @rmdir($file->getPathname()); - } - else - { - @unlink($file->getPathname()); - } - } - } + $cache->createCacheController('', $options)->cache->clean(''); // Clear opcache if available if (\function_exists('opcache_reset'))