[smarty-php] r4897 committed - - improvement cache is_file(file_exists) results of loadPlugin() to a...

4 views
Skip to first unread message

smart...@googlecode.com

unread,
Oct 14, 2014, 6:30:12 PM10/14/14
to smart...@googlegroups.com
Revision: 4897
Author: Uwe....@googlemail.com
Date: Tue Oct 14 22:29:58 2014 UTC
Log: - improvement cache is_file(file_exists) results of loadPlugin()
to avoid unnecessary calls during compilation (Issue 201}

https://code.google.com/p/smarty-php/source/detail?r=4897

Modified:
/trunk/distribution/change_log.txt
/trunk/distribution/libs/Smarty.class.php

=======================================
--- /trunk/distribution/change_log.txt Tue Oct 14 21:59:49 2014 UTC
+++ /trunk/distribution/change_log.txt Tue Oct 14 22:29:58 2014 UTC
@@ -2,6 +2,7 @@
14.10.2014
- bugfix any tag placed within "<script language=php>" will throw a
security exception to close all thinkable holes
- bugfix classmap in root composer.json should start at "libs/..."
+ - improvement cache is_file(file_exists) results of loadPlugin() to avoid
unnecessary calls during compilation (Issue 201}

12.10.2014
- bugfix a comment like "<script{*foo*} language=php>" bypassed
$php_handling checking (Thue Kristensen)
=======================================
--- /trunk/distribution/libs/Smarty.class.php Fri Oct 10 17:12:39 2014 UTC
+++ /trunk/distribution/libs/Smarty.class.php Tue Oct 14 22:29:58 2014 UTC
@@ -662,6 +662,14 @@
* @var array
*/
public $merged_templates_func = array();
+
+ /**
+ * Cache of is_file results of loadPlugin()
+ *
+ * @var array
+ */
+ public static $_is_file_cache= array();
+
/**#@-*/

/**
@@ -1372,9 +1380,8 @@
// if type is "internal", get plugin from sysplugins
if (strtolower($_name_parts[1]) == 'internal') {
$file = SMARTY_SYSPLUGINS_DIR .
strtolower($plugin_name) . '.php';
- if (file_exists($file)) {
+ if (isset(self::$_is_file_cache[$file]) ?
self::$_is_file_cache[$file] : self::$_is_file_cache[$file] =
is_file($file)) {
require_once($file);
-
return $file;
} else {
return false;
@@ -1392,9 +1399,8 @@
$_plugin_dir . strtolower($_plugin_filename),
);
foreach ($names as $file) {
- if (file_exists($file)) {
+ if (isset(self::$_is_file_cache[$file]) ?
self::$_is_file_cache[$file] : self::$_is_file_cache[$file] =
is_file($file)) {
require_once($file);
-
return $file;
}
if ($this->use_include_path && !preg_match('/^([\/\\\\]|
[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
Reply all
Reply to author
Forward
0 new messages