Optimization of the loading mechanism parameters mambots
Today, looking through the list of queries that Joomla does when displaying the page, drew attention to some redundancy of these requests. First and foremost, it concerns the BitTorrent Plugin their parameters. As a result, small-scale experiments has been made a modification that allows you to save a number of queries performed by using standard mambots.
Introduction to the loading mechanism parameters mambots
Most mambots used in Joomla, is the parameters that can be set when editing the mambot mambots Manager in the administrative panel site. When you open the site downloads a kernel Joomla Mambots published and then, if necessary, and their causes.
Around version 1.0.8 the developers had made Joomla optimization to reduce the number of database queries. In particular, it affected and the mechanism of load parameters mambots. After this modification, the code download settings mambot took the form (for example mambot MosImage):
/ / Check if param query has previously been processed
if ( !isset($ _MAMBOTS-> _content_mambot_params['Mosimage']) ) {
/ / Load mambot params info
$ Query = "SELECT params"
. "\ N FROM # __mambots "
. "\ N WHERE element = 'mosimage' "
. "\ N AND folder = 'content' "
;
$ Database->setQuery( $ Query );
$ Database->loadObject($ Mambot);
/ / Save query to class variable
$ _MAMBOTS-> _content_mambot_params['Mosimage'] = $ Mambot;
}
/ / Pull query data from class variable
$ Mambot = $ _MAMBOTS-> _content_mambot_params['Mosimage'];
As can be seen from the code, the developers offered the option of maintaining read mambot parameters into the global variable object $ _MAMBOTS. And during the next boot, this request is no longer satisfied. This step turned out to get rid of re-loading parameters.
But, looking bootloader code in mambots joomla.phpI saw that the parameters of mambots and so are selected in a query when loading mambots. Therefore, it is possible to initialize the array _content_mambot_params More at boot mambots, and thus to exclude requests for downloading parameters from themselves mambots.
Description of the update mechanism for downloading parameters mambots
Before the beginning of modifications recommended to backup changed files. If you suddenly something will not work – the presence of the backup will allow you to undo changes and restore your site.
- Open the file / Includes / joomla.php
- We find in him a line:
/ / Load query into class variable _content_mambots if (!($ This-> _content_mambots = $ Database->loadObjectList())) { / / Echo "Error loading Mambots:". $ Database-> getErrorMsg (); return false; } - Save the changes to the file.
and after adding a small piece of code:
foreach( $ This-> _content_mambots as $ Mambot ) {
$ This-> _content_mambot_params[$ Mambot->element] = $ Mambot;
}
After doing this modification, the parameters of Mambots Content will be initialized immediately at startup Mambots in this group. And subsequently, additional requests will fail.
