9bbf2a74fb
Three-pronged queue processing: 1. Joomla Scheduled Task (preferred): New plg_task_mokojoomcross plugin registers "MokoJoomCross - Process Queue" task type. Admin creates a scheduled task in System → Scheduled Tasks with desired interval. 2. Page-load fallback: System plugin onAfterRender with configurable throttle interval. Runs on backend, frontend, or both. Small batch size (5) to avoid slowing page loads. 3. Both can run simultaneously — QueueProcessor uses DB-based lock to prevent concurrent execution (120s safety timeout). Shared QueueProcessor helper handles: - Queued post dispatch to service plugins - Failed post retry with configurable max retries + delay - Scheduled post firing (when scheduled_at <= now) - Log cleanup based on retention period Dashboard shows warning banner when page-load processing is active, recommending switch to Joomla Scheduled Tasks for production. Config options: queue_processing (scheduler/pageload/both), pageload_client (admin/site/both), pageload_interval (seconds). Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
135 lines
4.4 KiB
PHP
135 lines
4.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoJoomCross
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\Installer\InstallerAdapter;
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
class Pkg_MokoJoomCrossInstallerScript
|
|
{
|
|
/**
|
|
* Minimum PHP version required
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $minimumPhp = '8.1.0';
|
|
|
|
/**
|
|
* Called before any install/update/uninstall action.
|
|
*
|
|
* @param string $type Action type (install, update, uninstall)
|
|
* @param InstallerAdapter $parent Installer adapter
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function preflight(string $type, InstallerAdapter $parent): bool
|
|
{
|
|
if (version_compare(PHP_VERSION, $this->minimumPhp, '<')) {
|
|
Factory::getApplication()->enqueueMessage(
|
|
Text::sprintf('PKG_MOKOJOOMCROSS_PHP_VERSION_ERROR', $this->minimumPhp),
|
|
'error'
|
|
);
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Called after install/update.
|
|
*
|
|
* @param string $type Action type
|
|
* @param InstallerAdapter $parent Installer adapter
|
|
*
|
|
* @return void
|
|
*/
|
|
public function postflight(string $type, InstallerAdapter $parent): void
|
|
{
|
|
$db = Factory::getDbo();
|
|
|
|
if ($type === 'install') {
|
|
// Enable core plugins automatically on fresh install
|
|
$corePlugins = [
|
|
['system', 'mokojoomcross'],
|
|
['content', 'mokojoomcross'],
|
|
['webservices', 'mokojoomcross'],
|
|
['task', 'mokojoomcross'],
|
|
];
|
|
|
|
foreach ($corePlugins as [$folder, $element]) {
|
|
$query = $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($folder))
|
|
->where($db->quoteName('element') . ' = ' . $db->quote($element));
|
|
|
|
$db->setQuery($query);
|
|
$db->execute();
|
|
}
|
|
|
|
// Enable all service plugins in the mokojoomcross group
|
|
$query = $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('mokojoomcross'));
|
|
|
|
$db->setQuery($query);
|
|
$db->execute();
|
|
|
|
// Check for Perfect Publisher Pro and offer migration
|
|
$this->detectPerfectPublisherPro($db);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Detect Perfect Publisher Pro installation and store migration flag.
|
|
*
|
|
* @param \Joomla\Database\DatabaseInterface $db Database driver
|
|
*
|
|
* @return void
|
|
*/
|
|
private function detectPerfectPublisherPro($db): void
|
|
{
|
|
$query = $db->getQuery(true)
|
|
->select($db->quoteName(['element', 'params']))
|
|
->from($db->quoteName('#__extensions'))
|
|
->where($db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%'))
|
|
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
|
|
|
$db->setQuery($query);
|
|
$result = $db->loadObject();
|
|
|
|
if ($result) {
|
|
Factory::getApplication()->enqueueMessage(
|
|
Text::_('PKG_MOKOJOOMCROSS_MIGRATION_DETECTED'),
|
|
'notice'
|
|
);
|
|
|
|
// Store migration availability in component params
|
|
$query = $db->getQuery(true)
|
|
->update($db->quoteName('#__extensions'))
|
|
->set($db->quoteName('params') . ' = ' . $db->quote(json_encode([
|
|
'migration_available' => 'perfectpublisher',
|
|
'migration_source_params' => $result->params,
|
|
])))
|
|
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
|
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokojoomcross'));
|
|
|
|
$db->setQuery($query);
|
|
$db->execute();
|
|
}
|
|
}
|
|
}
|