From f723e60b3a35964d14addcb955df3342cddd63c7 Mon Sep 17 00:00:00 2001 From: Chris Graham Date: Tue, 12 Dec 2017 02:32:37 +0000 Subject: [PATCH] Some performance improvements --- install.php | 2 +- lang/EN/config.ini | 2 ++ sources/caches.php | 12 +++++++++ sources/caches3.php | 18 ++++++++++++- sources/files.php | 2 +- sources/global.php | 6 ++++- sources/global2.php | 10 ++++--- sources/global3.php | 2 +- sources/lang3.php | 7 +++++ sources/lang_compile.php | 16 +++++------ sources/lang_filter_EN.php | 42 +++++++++++++++++------------ sources/minikernel.php | 2 +- sources/news2.php | 2 +- sources/sitemap.php | 6 +++++ sources/textfiles.php | 17 +++++------- sources/web_resources.php | 4 --- sources/zones2.php | 6 ++--- sources_custom/comcode_compiler.php | 10 +++++-- sources_custom/phpstub.php | 5 +++- 19 files changed, 115 insertions(+), 56 deletions(-) diff --git a/install.php b/install.php index 661be7e3bf..5e5683255f 100644 --- a/install.php +++ b/install.php @@ -2526,7 +2526,7 @@ function object_factory($class) */ function safe_ini_set($var, $value) { - if (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote('ini_set')) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) != 0) { + if (@preg_match('#(\s|,|^)' . preg_quote('ini_set', '#') . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) != 0) { return false; } diff --git a/lang/EN/config.ini b/lang/EN/config.ini index f9e0eea83a..ee441dd39f 100644 --- a/lang/EN/config.ini +++ b/lang/EN/config.ini @@ -515,3 +515,5 @@ DESCRIPTION_TIMEZONE_SITE=The time zone the site should report in. Note also tha DOC_BASE_CONFIGURATION=To change an option set during installation, you generally use the external "Installation Options editor".\n\nThe Installation Options editor is completely separated from the main software, so that if your site ever breaks due to a misconfiguration in the _config.php configuration file (perhaps if you moved servers, and your database settings are no longer valid), you can fix it without having to hand-edit the file. As a result of the separation, the Configuration editor cannot empty caches automatically when you change an option, so after using it you should use the cleanup tools to empty the caches. BASE_CONFIGURATION=Installation Options + +DEEPER_CONFIGURATION=Deeper configuration diff --git a/sources/caches.php b/sources/caches.php index 1c66ad035b..83c95957b5 100644 --- a/sources/caches.php +++ b/sources/caches.php @@ -140,6 +140,7 @@ class Self_learning_cache private $pending_save = false; public $paused = false; public $empty = true; + private $already_invalidated = false; /** * Constructor. Initialise our cache. @@ -338,6 +339,11 @@ public function invalidate() return; } + if ($this->already_invalidated) { + return; + } + $this->already_invalidated = true; + if (!is_null($this->path)) { @unlink($this->path); } else { @@ -356,6 +362,12 @@ public static function erase_smart_cache() return; } + static $done_once = false; + if ($done_once) { + return; + } + $done_once = true; + $dh = @opendir(get_custom_file_base() . '/caches/self_learning'); if ($dh !== false) { while (($f = readdir($dh)) !== false) { diff --git a/sources/caches3.php b/sources/caches3.php index e1705a910c..938dfcae59 100644 --- a/sources/caches3.php +++ b/sources/caches3.php @@ -216,6 +216,12 @@ function erase_thumb_cache() */ function erase_cached_language() { + static $done_once = false; + if ($done_once) { + return; + } + $done_once = true; + cms_profile_start_for('erase_cached_language'); $langs = find_all_langs(true); @@ -284,6 +290,16 @@ function erase_cached_templates($preserve_some = false, $only_templates = null, return; // Optimisation } + if ((!$rebuild_some_deleted_files) && ($preserve_some)) { + static $done_sweeping_decache_already = false; + if ($done_sweeping_decache_already) { + return; + } + if (($only_templates === null) && ($raw_file_regexp === null)) { + $done_sweeping_decache_already = true; + } + } + cms_profile_start_for('erase_cached_templates'); global $ERASED_TEMPLATES_ONCE; @@ -344,7 +360,7 @@ function erase_cached_templates($preserve_some = false, $only_templates = null, foreach ($themes as $theme) { $using_less = (addon_installed('less')) || /*LESS-regeneration is too intensive and assumed cache-safe anyway*/ - is_file(get_custom_file_base() . '/themes/' . $theme . '/css/global.less') || + is_file(get_custom_file_base() . '/themes/' . $theme . '/css/global.less') || is_file(get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.less'); foreach (array_keys($langs) as $lang) { diff --git a/sources/files.php b/sources/files.php index 5ca45e89f5..bbd59c4638 100644 --- a/sources/files.php +++ b/sources/files.php @@ -150,7 +150,7 @@ function cms_file_put_contents_safe($path, $contents, $flags = 4, $retry_depth = } // Find file size - clearstatcache(); + clearstatcache(true, $path); $size = @filesize($path); // Special condition: File already deleted diff --git a/sources/global.php b/sources/global.php index 1c4f36af74..2ba1af2398 100644 --- a/sources/global.php +++ b/sources/global.php @@ -414,7 +414,11 @@ function php_function_allowed($function) return false; } } - $cache[$function] = (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote($function)) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0); + static $disabled_functions = null; + if ($disabled_functions === null) { + $disabled_functions = strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist')); + } + $cache[$function] = (@preg_match('#(\s|,|^)' . preg_quote($function, '#') . '(\s|$|,)#', $disabled_functions) == 0); return $cache[$function]; } diff --git a/sources/global2.php b/sources/global2.php index 1ea46939e6..663a260d4c 100644 --- a/sources/global2.php +++ b/sources/global2.php @@ -35,7 +35,7 @@ function init__global2() } $error_log_path = get_custom_file_base() . '/data_custom/errorlog.php'; safe_ini_set('error_log', $error_log_path); - if (is_file($error_log_path) && filesize($error_log_path) < 17) { + if ((is_file($error_log_path)) && (filesize($error_log_path) < 17)) { @file_put_contents($error_log_path, "<" . "?php return; ?" . ">\n", LOCK_EX); } @@ -350,7 +350,7 @@ function init__global2() setlocale(LC_ALL, explode(',', do_lang('locale'))); if (substr(@strftime('%M'), 0, 2) == '??') { // Windows may do this because it can't output a utf-8 character set, so gets mangled to question marks by PHP setlocale(LC_ALL, explode(',', 'en-GB.UTF-8,en_GB.UTF-8,en-US.UTF-8,en_US.UTF-8,en.UTF-8,en-GB,en_GB,en-US,en_US,en')); // The user will have to define locale_subst correctly - } + } // Check RBLs $spam_check_level = get_option('spam_check_level'); @@ -874,6 +874,7 @@ function is_browser_decaching() } if (GOOGLE_APPENGINE) { + $BROWSER_DECACHEING_CACHE = false; return false; // Decaching by mistake is real-bad when Google Cloud Storage is involved } @@ -883,15 +884,18 @@ function is_browser_decaching() $config_file = rtrim(str_replace(array('if (!defined(\'DO_PLANNED_DECACHE\')) ', 'define(\'DO_PLANNED_DECACHE\', true);'), array('', ''), $config_file)) . "\n\n"; require_code('files'); cms_file_put_contents_safe(get_file_base() . '/_config.php', $config_file, FILE_WRITE_FIX_PERMISSIONS); + $BROWSER_DECACHEING_CACHE = true; return true; } if (get_value('ran_once') === null) { // Track whether Composr has run at least once set_value('ran_once', '1'); + $BROWSER_DECACHEING_CACHE = true; return true; } - return false; // This technique stopped working well, Chrome sends cache-control too freely + $BROWSER_DECACHEING_CACHE = false; + return false; // This technique stopped working well, Chrome sends cache-control too freely /* $header_method = (array_key_exists('HTTP_CACHE_CONTROL', $_SERVER)) && ($_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache') && (cms_srv('REQUEST_METHOD') != 'POST') && ((!function_exists('browser_matches'))); diff --git a/sources/global3.php b/sources/global3.php index ecc7a84d0b..c90418cfa8 100644 --- a/sources/global3.php +++ b/sources/global3.php @@ -2582,7 +2582,7 @@ function is_mobile($user_agent = null, $truth = false) return false; } } else { - if (preg_match('#(^|,)\s*' . str_replace('#', '\#', preg_quote(get_page_name())) . '\s*(,|$)#', $details['mobile_pages']) == 0 && preg_match('#(^|,)\s*' . str_replace('#', '\#', preg_quote(get_zone_name() . ':' . get_page_name())) . '\s*(,|$)#', $details['mobile_pages']) == 0) { + if (preg_match('#(^|,)\s*' . preg_quote(get_page_name(), '#') . '\s*(,|$)#', $details['mobile_pages']) == 0 && preg_match('#(^|,)\s*' . preg_quote(get_zone_name() . ':' . get_page_name(), '#') . '\s*(,|$)#', $details['mobile_pages']) == 0) { $IS_MOBILE_CACHE = false; return false; } diff --git a/sources/lang3.php b/sources/lang3.php index 95c1a620a4..a5c418628a 100644 --- a/sources/lang3.php +++ b/sources/lang3.php @@ -87,6 +87,11 @@ function _find_all_langs($even_empty_langs = false) { require_code('files'); + static $cached = array(); + if (isset($cached[$even_empty_langs])) { + return $cached[$even_empty_langs]; + } + // NB: This code is heavily optimised $_langs = array(fallback_lang() => 'lang'); @@ -94,6 +99,7 @@ function _find_all_langs($even_empty_langs = false) if (!in_safe_mode()) { $test = persistent_cache_get('LANGS_LIST'); if ($test !== null) { + $cached[$even_empty_langs] = $test; return $test; } @@ -160,6 +166,7 @@ function _find_all_langs($even_empty_langs = false) persistent_cache_set('LANGS_LIST', $_langs); } + $cached[$even_empty_langs] = $_langs; return $_langs; } diff --git a/sources/lang_compile.php b/sources/lang_compile.php index f96566bc6c..eaf86d8d45 100644 --- a/sources/lang_compile.php +++ b/sources/lang_compile.php @@ -79,7 +79,7 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro // Load originals $lang_file = get_file_base() . '/lang/' . $lang . '/' . filter_naughty($codename) . '.ini'; - if (file_exists($lang_file)) { // Non-custom, Proper language + if (is_file($lang_file)) { // Non-custom, Proper language _get_lang_file_map($lang_file, $load_target, 'strings', false, true, $lang); $bad = false; } @@ -87,11 +87,11 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro // Load overrides now if they are there if ($type !== 'lang') { $lang_file = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini'; - if ((!file_exists($lang_file)) && (get_file_base() !== get_custom_file_base())) { + if ((!is_file($lang_file)) && (get_file_base() !== get_custom_file_base())) { $lang_file = get_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini'; } } - if (($type !== 'lang') && (file_exists($lang_file))) { + if (($type !== 'lang') && (is_file($lang_file))) { _get_lang_file_map($lang_file, $load_target, 'strings', false, true, $lang); $bad = false; $dirty = true; // Tainted from the official pack, so can't store server wide @@ -103,7 +103,7 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro require_lang($codename, fallback_lang(), $type, $ignore_errors); $REQUIRE_LANG_LOOP--; $fallback_cache_path = get_custom_file_base() . '/caches/lang/' . fallback_lang() . '/' . $codename . '.lcd'; - if (file_exists($fallback_cache_path)) { + if (is_file($fallback_cache_path)) { require_code('files'); @copy($fallback_cache_path, $cache_path); fix_permissions($cache_path); @@ -203,14 +203,14 @@ function get_lang_file_section($lang, $file = null, $section = 'descriptions') function get_lang_file_map($lang, $file, $non_custom = false, $apply_filter = true) { $a = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $file . '.ini'; - if ((get_custom_file_base() !== get_file_base()) && (!file_exists($a))) { + if ((get_custom_file_base() !== get_file_base()) && (!is_file($a))) { $a = get_file_base() . '/lang_custom/' . $lang . '/' . $file . '.ini'; } - if ((!file_exists($a)) || ($non_custom)) { + if ((!is_file($a)) || ($non_custom)) { $b = get_custom_file_base() . '/lang/' . $lang . '/' . $file . '.ini'; - if (file_exists($b)) { + if (is_file($b)) { $a = $b; } else { if ($non_custom) { @@ -239,7 +239,7 @@ function get_lang_file_map($lang, $file, $non_custom = false, $apply_filter = tr function _get_lang_file_map($b, &$entries, $section = 'strings', $given_whole_file = false, $apply_filter = true, $lang = null) { if (!$given_whole_file) { - if (!file_exists($b)) { + if (!is_file($b)) { return; } diff --git a/sources/lang_filter_EN.php b/sources/lang_filter_EN.php index 7e0c835040..0ea7375441 100644 --- a/sources/lang_filter_EN.php +++ b/sources/lang_filter_EN.php @@ -220,9 +220,10 @@ public function compile_time($key, $value, $lang = null) // Put in correct brand name if (!is_null($key)) { - $remapping['the software'] = preg_quote(brand_name(), '#'); - $remapping['the website software'] = preg_quote(brand_name(), '#'); - $remapping['other webmasters'] = 'other ' . preg_quote(brand_name(), '#') . ' users'; + $brand_name = brand_name(); + $remapping['the software'] = preg_quote($brand_name, '#'); + $remapping['the website software'] = preg_quote($brand_name, '#'); + $remapping['other webmasters'] = 'other ' . preg_quote($brand_name, '#') . ' users'; } // Fix bad contextualisation @@ -247,29 +248,36 @@ public function compile_time($key, $value, $lang = null) if ($is_american) { // NB: Below you will see there are exceptions, typically when the base word already naturally ends with "se" on the end, it uses "s" not "z" - $value = str_replace('sation', 'zation', $value); - $value = str_replace('converzation', 'conversation', $value); // Exception, put this back - $value = str_replace('Converzation', 'Conversation', $value); // Exception, put this back + if (strpos($value, 'sation') !== false) { + $value = str_replace('sation', 'zation', $value); + $value = str_replace('converzation', 'conversation', $value); // Exception, put this back + $value = str_replace('Converzation', 'Conversation', $value); // Exception, put this back + } - $value = str_replace('sable', 'zable', $value); - $value = str_replace('dizable', 'disable', $value); // Exception, put this back - $value = str_replace('Dizable', 'Disable', $value); // Exception, put this back - $value = str_replace('advizable', 'advisable', $value); // Exception, put this back - $value = str_replace('Advizable', 'Advisable', $value); // Exception, put this back - $value = str_replace('purchazable', 'purchasable', $value); // Exception, put this back - $value = str_replace('Purchazable', 'Purchasable', $value); // Exception, put this back - $value = str_replace('uzable', 'usable', $value); // Exception, put this back + if (strpos($value, 'sable') !== false) { + $value = str_replace('sable', 'zable', $value); + $value = str_replace('dizable', 'disable', $value); // Exception, put this back + $value = str_replace('Dizable', 'Disable', $value); // Exception, put this back + $value = str_replace('advizable', 'advisable', $value); // Exception, put this back + $value = str_replace('Advizable', 'Advisable', $value); // Exception, put this back + $value = str_replace('purchazable', 'purchasable', $value); // Exception, put this back + $value = str_replace('Purchazable', 'Purchasable', $value); // Exception, put this back + $value = str_replace('uzable', 'usable', $value); // Exception, put this back + } - $value = str_replace('sational', 'zational', $value); - $value = str_replace('senzational', 'sensational', $value); // Exception, put this back + if (strpos($value, 'sational') !== false) { + $value = str_replace('sational', 'zational', $value); + $value = str_replace('senzational', 'sensational', $value); // Exception, put this back + } $remapping = $this->make_uncle_sam_happy; } else { $remapping = $this->the_sun_never_sets_on_the_british_empire; } + $lc_value = strtolower($value); foreach ($remapping as $authentic => $perverted) { - if (stripos($value, $authentic) !== false) { + if (strpos($lc_value, $authentic) !== false) { $value = preg_replace( '#(^|\s)' . preg_quote($authentic, '#') . '#', '$1' . $perverted, diff --git a/sources/minikernel.php b/sources/minikernel.php index c7b90c7f7a..dd204165f8 100644 --- a/sources/minikernel.php +++ b/sources/minikernel.php @@ -177,7 +177,7 @@ function php_function_allowed($function) return false; } } - return (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote($function)) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0); + return (@preg_match('#(\s|,|^)' . preg_quote($function, '#') . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0); } /** diff --git a/sources/news2.php b/sources/news2.php index 82a44362fe..31f2ba72d0 100644 --- a/sources/news2.php +++ b/sources/news2.php @@ -876,7 +876,7 @@ function _news_import_grab_images_and_fix_links($download_images, &$data, $impor // Go through other items, in case this news article/page is linking to them and needs a fixed link foreach ($imported_news as $item) { if (array_key_exists('full_url', $item)) { - $num_matches = preg_match_all('#]*)href="' . str_replace('#', '\#', preg_quote(escape_html($item['full_url']))) . '"([^<>]*)>(.*)#isU', $data, $matches); + $num_matches = preg_match_all('#]*)href="' . preg_quote(escape_html($item['full_url']), '#') . '"([^<>]*)>(.*)#isU', $data, $matches); for ($i = 0; $i < $num_matches; $i++) { if (($matches[1][$i] == '') && ($matches[2][$i] == '') && (strpos($data, '[html]') === false)) { $data = str_replace($matches[0][$i], '[page="_SEARCH:news:view:' . strval($item['import_id']) . '"]' . $matches[3][$i] . '[/page]', $data); diff --git a/sources/sitemap.php b/sources/sitemap.php index d2a4c6f7b8..2d77dc8e1f 100644 --- a/sources/sitemap.php +++ b/sources/sitemap.php @@ -1154,6 +1154,11 @@ function get_root_comcode_pages($zone, $include_zone = false) // This uses more memory than the above, but is needed as pages may not have got into the database yet... + static $cache = array(); + if (isset($cache[$zone][$include_zone])) { + return $cache[$zone][$include_zone]; + } + disable_php_memory_limit(); static $rows = array(); @@ -1191,6 +1196,7 @@ function get_root_comcode_pages($zone, $include_zone = false) $page_links[$key] = isset($root[$page]) ? $root[$page] : 1; } + $cache[$zone][$include_zone] = $page_links; return $page_links; } diff --git a/sources/textfiles.php b/sources/textfiles.php index 81cfbe028f..132f860617 100755 --- a/sources/textfiles.php +++ b/sources/textfiles.php @@ -47,15 +47,15 @@ function _find_text_file_path($codename, $lang) do { $lang = $langs[$i]; $path = get_custom_file_base() . '/text_custom/' . $lang . '/' . $codename . '.txt'; - if (!file_exists($path)) { + if (!is_file($path)) { $path = get_file_base() . '/text_custom/' . $lang . '/' . $codename . '.txt'; } - if (!file_exists($path)) { + if (!is_file($path)) { $path = get_file_base() . '/text/' . $lang . '/' . $codename . '.txt'; } $i++; - } while ((!file_exists($path)) && (array_key_exists($i, $langs))); - if (!file_exists($path)) { + } while ((!is_file($path)) && (array_key_exists($i, $langs))); + if (!is_file($path)) { $path = ''; } @@ -74,8 +74,7 @@ function read_text_file($codename, $lang = null, $missing_blank = false) { $path = _find_text_file_path($codename, $lang); - $tmp = @fopen($path, 'rb'); - if ($tmp === false) { + if (!is_file($path)) { if ($lang !== fallback_lang()) { return read_text_file($codename, fallback_lang(), $missing_blank); } @@ -85,11 +84,7 @@ function read_text_file($codename, $lang = null, $missing_blank = false) } warn_exit(do_lang_tempcode('MISSING_TEXT_FILE', escape_html($codename), escape_html('text/' . (is_null($lang) ? '' : ($lang . '/')) . $codename . '.txt'))); } - flock($tmp, LOCK_SH); - $in = @file_get_contents($path); - flock($tmp, LOCK_UN); - fclose($tmp); - $in = unixify_line_format($in); + $in = unixify_line_format(cms_file_get_contents_safe($path)); if (strpos($path, '_custom/') === false) { global $LANG_FILTER_OB; diff --git a/sources/web_resources.php b/sources/web_resources.php index 0435e73736..c8296bc254 100644 --- a/sources/web_resources.php +++ b/sources/web_resources.php @@ -75,10 +75,6 @@ function javascript_enforce($j, $theme = null, $allow_defer = false) return ''; } - if ($j == 'custom_globals') { - $allow_defer = false; - } - list($minify, $https, $mobile) = _get_web_resources_env(); global $SITE_INFO; diff --git a/sources/zones2.php b/sources/zones2.php index 5985a25e4f..0e0b18818c 100644 --- a/sources/zones2.php +++ b/sources/zones2.php @@ -845,7 +845,7 @@ function _find_all_pages($zone, $type, $ext = 'php', $keep_ext_on = false, $cuto $dh = @opendir($stub . '/' . $module_path); if ($dh !== false) { while (($file = readdir($dh)) !== false) { - if ((substr($file, -4) == '.' . $ext) && (file_exists($stub . '/' . $module_path . '/' . $file)) && (preg_match('#^[^\.][' . URL_CONTENT_REGEXP . ']*$#', substr($file, 0, strlen($file) - 4)) != 0)) { + if ((substr($file, -4) == '.' . $ext) && (is_file($stub . '/' . $module_path . '/' . $file)) && (preg_match('#^[^\.][' . URL_CONTENT_REGEXP . ']*$#', substr($file, 0, strlen($file) - 4)) != 0)) { if (!is_null($cutoff_time)) { if (filectime($stub . '/' . $module_path . '/' . $file) < $cutoff_time) { continue; @@ -861,7 +861,7 @@ function _find_all_pages($zone, $type, $ext = 'php', $keep_ext_on = false, $cuto foreach ($records as $record) { $file = $record['the_page'] . '.txt'; - if (!file_exists($stub . '/' . $module_path . '/' . $file)) { + if (!is_file($stub . '/' . $module_path . '/' . $file)) { continue; } @@ -887,7 +887,7 @@ function _find_all_pages($zone, $type, $ext = 'php', $keep_ext_on = false, $cuto foreach ($records as $record) { $file = $record['the_page'] . '.txt'; - if (!file_exists($stub . '/' . $module_path . '/' . $file)) { + if (!is_file($stub . '/' . $module_path . '/' . $file)) { continue; } diff --git a/sources_custom/comcode_compiler.php b/sources_custom/comcode_compiler.php index 4c930d3390..c32275bf45 100644 --- a/sources_custom/comcode_compiler.php +++ b/sources_custom/comcode_compiler.php @@ -20,7 +20,10 @@ function init__comcode_compiler($in = null) "if (\$as_admin)", " require_code('textfiles'); - \$whitelists = explode(\"\n\", read_text_file('comcode_whitelist', null, true)); + static \$whitelists = null; + if (\$whitelists === null) { + \$whitelists = explode(\"\n\", read_text_file('comcode_whitelist', null, true)); + } foreach (\$whitelists as \$w) { if (trim(\$w) != '') { if (\$w[0] != '/') { @@ -42,7 +45,10 @@ function init__comcode_compiler($in = null) global \$OBSCURE_REPLACEMENTS; \$OBSCURE_REPLACEMENTS = array(); require_code('textfiles'); - \$whitelists = explode(\"\n\", read_text_file('comcode_whitelist', null, true)); + static \$whitelists = null; + if (\$whitelists === null) { + \$whitelists = explode(\"\n\", read_text_file('comcode_whitelist', null, true)); + } foreach (\$whitelists as \$i => \$w) { if (trim(\$w) != '') { if (\$w[0] != '/') { diff --git a/sources_custom/phpstub.php b/sources_custom/phpstub.php index d5ae8e41f8..b248397930 100644 --- a/sources_custom/phpstub.php +++ b/sources_custom/phpstub.php @@ -414,8 +414,11 @@ function class_exists($class_name) /** * Clears file status cache. + * + * @param boolean $clear_realcache_path Whether to clear the realpath cache or not. + * @param PATH $filename Clear the realpath and the stat cache for a specific filename only; only used if clear_realpath_cache is true. */ -function clearstatcache() +function clearstatcache($clear_realcache_path, $filename) { }