From 6b5e4cf076b3b64fe6a86c74c5792867f83047b1 Mon Sep 17 00:00:00 2001 From: Nick Ryzhy Date: Mon, 4 Jan 2016 18:12:18 +0300 Subject: [PATCH] Update siteinfo_helper.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Кэширование объекта $siteinfo. Метод siteinfo() вызывается кучу раз на каждой странице. Почему бы его не закэшировать? --- application/helpers/siteinfo_helper.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/application/helpers/siteinfo_helper.php b/application/helpers/siteinfo_helper.php index 5a532d1003..cf97ccae39 100755 --- a/application/helpers/siteinfo_helper.php +++ b/application/helpers/siteinfo_helper.php @@ -31,9 +31,13 @@ function siteinfo($name = NULL) { if (0 !== strpos($name, 'siteinfo_')) { $name = 'siteinfo_' . $name; } - $ci = &get_instance(); - $ci->load->library('SiteInfo'); - $siteinfo = new SiteInfo(); + + static $siteinfo; + if ( empty( $siteinfo ) ) { + $ci = &get_instance(); + $ci->load->library('SiteInfo'); + $siteinfo = new SiteInfo(); + } // next code is only for compatibility with older versions of library, // so in the future needed to be removed (with funciton processOldVersions() too) @@ -67,7 +71,10 @@ function siteInfoAdditionalManipulations($name) { $name = str_replace('_url', '', $name); } - $siteinfo = new SiteInfo(); + static $siteinfo; + if ( empty( $siteinfo ) ) { + $siteinfo = new SiteInfo(); + } $value = $siteinfo->getSiteInfo($name); switch ($name) { case 'siteinfo_favicon': @@ -103,4 +110,4 @@ function siteInfoAdditionalManipulations($name) { return false; } -} \ No newline at end of file +}