User tests: Successful: Unsuccessful:
This code never made it from the last platform update to the cms.
By deprecating the expressions on modules, we can remove the eval($str) in 4.0. (or maybe even faster???) This is good for HHVM http://hhvm.com
Maybe the PLT can go a little bit more bold here and remove the old code:
for ($i = 0, $n = count($words); $i < $n; $i += 2)
{
// Odd parts (modules)
$name = strtolower($words[$i]);
$words[$i] = ((isset(parent::$_buffer['modules'][$name])) && (parent::$_buffer['modules'][$name] === false))
? 0
: count(JModuleHelper::getModules($name));
}
$str = 'return ' . implode(' ', $words) . ';';
return eval($str);
Maybe the PLT can go a little bit more bold here and remove the old code:
Why would we want to create a backward compatibility break on purpose when we can properly deprecate the existing function?
Currently, you can do this in your template:if ($this->countModules('position-1 or position-2 or position-3')) :
It will return true if either of the positions contains a module. You can also use and
or some other operators if you want.
The function to make this work uses eval()
and some rather complex code.
The idea of this change is that we would deprecate the possibility to use an expression in countModules()
and get rid of the eval()
.
The thing is that you can do the same almost as easy in the template directly. The above code would then look like this:if ($this->countModules('position-1') or $this->countModules('position-2') or $this->countModules('position-3')) :
To test this, you can use such an call in your template. If you use an expression, you should see a deprecation message in your log file (if you have deprecation logging enabled). It should still work.
If you don't use an expression, you should not get the message and it should of course also work.
@dgt41 i have test this here successfull. After enabling Log deprecated API for the Debug Plugin i have add the following lines to the protostar template index.php
if ($this->countModules('position-7 or position-8'))
{
//Do nothing
}
Then apply your patch and i will see after reload the FE at the Log Part of the Debug console the Message:
WARNING - deprecated
Using an expression in JDocumentHtml::countModules() is deprecated.
Thanks @Bakual for the instructions i will copy it to the JC itm
So I tested this patch and the JLog::add is triggered but I don't get any log where this is written. Is there anything in particular to set up? I have enabled the Debug system option. The array of loggers is empty, so there is no place to write the log.
Once this goes ahead, this document needs to be updated as well:
http://docs.joomla.org/JDocumentHTML/countModules
You have to enable it in debug plugin, https://www.dropbox.com/s/ej6ebdwg7zxj4y0/Screenshot%202014-05-28%2009.53.03.png
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-06-11 23:15:16 |
Anyone with credentials maybe can update. I made a doc with all the changes here: https://docs.google.com/document/d/1Csn0FMxLNCpGLU8gpGK2j_QNbWZ6KJ5xE2nEpUI5r60/edit?usp=sharing
Thanks for the doc update.
test “test” ‘test’ test
JoomlaCode Tracker: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33645