diff --git a/libraries/joomla/document/html/html.php b/libraries/joomla/document/html/html.php
index 9b03c7932f9e4..8563acbff25b9 100644
--- a/libraries/joomla/document/html/html.php
+++ b/libraries/joomla/document/html/html.php
@@ -493,6 +493,18 @@ public function countModules($condition)
{
$operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)';
$words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);
+
+ if (count($words) === 1)
+ {
+ $name = strtolower($words[0]);
+ $result = ((isset(parent::$_buffer['modules'][$name])) && (parent::$_buffer['modules'][$name] === false))
+ ? 0 : count(JModuleHelper::getModules($name));
+
+ return $result;
+ }
+
+ JLog::add('Using an expression in JDocumentHtml::countModules() is deprecated.', JLog::WARNING, 'deprecated');
+
for ($i = 0, $n = count($words); $i < $n; $i += 2)
{
// Odd parts (modules)