Kunena 7.1.1 & Kunena 6.4.17 – Security Updates Released
The Kunena team has announce the arrival of Kunena 7.1.1 [K 7.1.1] in stable which is now available for download as a native Joomla extension for J! 5.4.x/6.0.x./6.1.x./6.2.x This version addresses most of the issues that were discovered in K 6.2 / K 6.3 / K 6.4 / K7.0 and issues discovered during the last development stages of K 7.1
Just a reminder: K6.4.17 receives only securities fixes until end of 2026, so it's advised for users to upgrade to K7.1.
Question Queued notifications fail from CLI
After upgrading to Kunena 7.1.0, the scheduled task "Kunena - Send the mail notifications queued" fails when it runs from the Joomla CLI (php cli/joomla.php scheduler:run, triggered by cron). The task log shows:
ERROR Task> Queued notification #1 could not be sent: Call to undefined method Joomla\CMS\Application\ConsoleApplication::getTemplate()
WARNING Task> One or more queued notifications could not be sent and will be retried.
Environment: Kunena 7.1.0, Joomla 6.2, PHP 8.5, task executed via CLI cron.
ISSUE 1 – Fatal error in KunenaTemplate::getInstance() under CLI
Stack trace:
libraries/kunena/src/Template/KunenaTemplate.php:483 KunenaTemplate::getInstance()
libraries/kunena/src/Factory/KunenaFactory.php:76 KunenaFactory::getTemplate()
libraries/kunena/src/Layout/KunenaBase.php:709 KunenaBase::factory()
libraries/kunena/src/Forum/Message/KunenaMessage.php:1963 KunenaMessage->attachEmailBody()
It happens when the configured Kunena template no longer exists. In our case the site was upgraded from older versions and the configuration still had template = "crypsis". The code then takes the fallback branch:
// If template xml doesn't exist, raise warning and use aurelia instead
$file = JPATH_THEMES . "/{$app->getTemplate()}/html/com_kunena/template.php";
$app is Factory::getApplication(), which is a ConsoleApplication under CLI and has no getTemplate() method. The $file value assigned here is never used: it is overwritten inside the following isClient('site') block, or ignored otherwise. Removing the line, or guarding it with $app->isClient('site'), fixes the issue. Setting Aurelia as the default template also works around it.
It might also be worth making the upgrade process reset an obsolete template value (such as crypsis) to aurelia.
ISSUE 2 – Wrong message links in emails sent from CLI
Once issue 1 is worked around, the emails are sent, but the message links are wrong:
- With live_site empty: joomla.invalid/set/by/console/applicatio...=2447&Itemid=0#10614
- With live_site set: www.example.comcli/index.php?option=com_...c&...&Itemid=0#10614 (no slash, cli/ path, non-SEF, Itemid=0)
The email layouts rebuild the link from the current request instead of using the URL that was stored in the queue:
- components/com_kunena/template/aurelia/layouts/email/subscription/default.php lines 25 and 204
- components/com_kunena/template/aurelia/layouts/email/subscription/moderator.php line 25
$this->messageLink = Uri::getInstance()->toString(array('scheme', 'host', 'port')) . $this->message->getUrl(null, false);
KunenaMessage::processNotification() already computes the correct permalink during the web request and stores it in #__kunena_notifications_mailsqueue.url. That value is passed to the layout as $this->messageUrl by attachEmailBody(), but the layouts never use it. A possible fix:
$this->messageLink = $this->messageUrl?: Uri::getInstance()->toString(array('scheme', 'host', 'port')) . $this->message->getUrl(null, false);
Line 204 of default.php should also use $this->messageLink instead of recomputing the URL. I'd also suggest escaping the link when it is output in the HTML (htmlspecialchars($this->messageLink, ENT_QUOTES, 'UTF-8')).
Best regards,
Jose
Please Log in or Create an account to join the conversation.
I don't provide support by PM, because this can be useful for someone else.
Please Log in or Create an account to join the conversation.
Thanks! I tested PR #10314 on a copy of the production site (Joomla 6.2, Kunena 7.1.0, PHP 8.5, Kunena template setting still "crypsis"), running the task via `php cli/joomla.php scheduler:run`. Before the patch I could reproduce the fatal error; after applying it the queued notification is sent and marked as sent, so issue 1 is fixed for me.
Issue 2 is still present: the links in the emails are ` joomla.invalid/set/by/console/applicatio...&limitstart=12#10613 `, and the header image in the email (`/media/kunena/email/hero-wide.png`) also gets that host, so it is broken too. The correct permalink is already stored in `#__kunena_notifications_mailsqueue.url` and passed to the layout as `$this->messageUrl`, but `email/subscription/default.php` and `moderator.php` rebuild it from `Uri::getInstance()`. Could you take a look at that one as well?
Best regards,
Jose
Please Log in or Create an account to join the conversation.
I don't provide support by PM, because this can be useful for someone else.
Please Log in or Create an account to join the conversation.
Thanks, PR #10320 works for the links. I applied it to 7.1.0 (aurelia and system layouts), queued a notification and ran the task from `cli/joomla.php scheduler:run`. Every link in the email (HTML and plain-text parts) now uses the correct permalink from the queue.
One thing is still left: the header image. In `subscription/default.php` (line 162 in 7.1.0) the src is built with `Uri::base() . $config->emailHeader`. From CLI that gives:
joomla.invalid/set/by/console/applicatio.../email/hero-wide.png
(there is also a double slash). One way to fix it would be to take the scheme and host from `$this->messageUrl` when it is set, the same way the links now work, and fall back to `Uri::root()` otherwise. `TopicItemDisplay.php` (line 530) uses the same `Uri::base() . '/media/kunena/email/hero-wide.png'` pattern, but that one only runs on the site.
Thanks again for the quick fixes!
Jose
Please Log in or Create an account to join the conversation.
Can-you try please with this PR for the last issue : github.com/Kunena/Kunena-Forum/pull/10326 ?
I don't provide support by PM, because this can be useful for someone else.
Please Log in or Create an account to join the conversation.