Minor: Helix Ultimate `Helper::getTemplateId()` builds an invalid query on multilingual sites (missing closing parenthesis) - Forum | JoomShaper
Staff replied Helix Framework Joomla 5 v2.2.10

Minor: Helix Ultimate `Helper::getTemplateId()` builds an invalid query on multilingual sites (missing closing parenthesis)

Asked by HalTurner 1 day ago Last activity 18 hours ago

Environment

  • Helix Ultimate framework 2.2.10, plugins/system/helixultimate/src/Platform/Helper.php
  • Also present on the current GitHub master branch

The problem

In Helper::getTemplateId(), the multilingual branch adds a home condition that opens a parenthesis but never closes it:

  • $query->where($db->quoteName('home') . ' IN(' . $db->quote(Factory::getLanguage()->getTag()) . ', ' . $db->quote('1', false));

When Multilanguage is enabled, the database rejects the query, the try/catch swallows the exception, and the method silently returns 0.

In 2.2.10 nothing calls getTemplateId(), so there is no visible effect today, but any future caller on a multilingual site would get template ID 0 without an error.

Suggested fix

Close the parenthesis, or use the query builder's whereIn():

  • $query->whereIn($db->quoteName('home'), [Factory::getLanguage()->getTag(), '1'], ParameterType::STRING);

Or remove the method if it is no longer needed.

Impact

No current impact (the method is unused); a one-character fix that prevents a silent failure later.

1 reply

Ziaul Kabir Staff

Hi HalTurner,

Thanks for the detailed report. I checked Helix Ultimate 2.2.10 and confirmed it. In plugins/system/helixultimate/src/Platform/Helper.php (line 85), the multilingual branch of getTemplateId() opens IN( and never closes it. With Multilanguage enabled the query fails, and the catch returns 0 without any error.

I also searched the install for callers of getTemplateId() and found none. As you said, there's no visible effect today. The risk is for future code that calls it on a multilingual site.

Your whereIn() suggestion is the better fix, because it also parameterises the values:

$query->whereIn(
    $db->quoteName('home'),
    [Factory::getLanguage()->getTag(), '1'],
    ParameterType::STRING
);

It needs use Joomla\Database\ParameterType; at the top of the file. Closing the parenthesis is the minimal fix, and removing the method is another option since nothing uses it.

I've passed this to dev team for further review, so it can be fixed in a future release. Thanks again for reporting it.

Best Regards,

Log in to reply.