From de646ce5bb345d2b27f7bf53f8ed5154b3829e92 Mon Sep 17 00:00:00 2001 From: quix0r Date: Mon, 5 Nov 2012 15:36:29 +0000 Subject: [PATCH] Lower memory usage or caching? Red or blue pill? - Function readFromFile() does now longer 'cache' its content as it is to memory intensive - TODOs.txt updated --- DOCS/TODOs.txt | 83 ++++++++++++++++++++++++++++++++++++++- inc/wrapper-functions.php | 34 +++++++--------- 2 files changed, 96 insertions(+), 21 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 2e6245ccae..7c1e89e72c 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -226,8 +226,89 @@ ./.htaccess:13: # @TODO When ext-terms is finished RewriteRule ^agb.php$ modules.php?module=index&what=terms [L] ./.htaccess:9: # @TODO When ext-imprint is finished RewriteRule ^cms/index/wht/impressum$ modules.php?module=index&what=imprint [L] ### ### DEPRECATION FOLLOWS: ### ### +./inc/autopurge.php:2:// @DEPRECATED +./inc/birthday_mails.php:2:// @DEPRECATED +./inc/check-reset.php:2:// @DEPRECATED +./inc/doubler_send.php:2:// @DEPRECATED +./inc/extensions.php:2:// @DEPRECATED +./inc/fatal_errors.php:2:// @DEPRECATED +./inc/hooks.php:2:// @DEPRECATED +./inc/language.php:2:// @DEPRECATED +./inc/language/pro_de.php:2:// @DEPRECATED +./inc/libs/output_functions.php:2:// @DEPRECATED +./inc/load_extensions.php:2:// @DEPRECATED +./inc/mails/birthday_mails.php:2:// @DEPRECATED ./inc/modules/admin/admin-inc.php:522:// @DEPRECATED -./templates/de/html/philosophy.tpl:1: +./inc/modules/admin/what-admins_contact.php:2:// @DEPRECATED +./inc/modules/admin/what-autopurge.php:2:// @DEPRECATED +./inc/modules/admin/what-config_cache.php:2:// @DEPRECATED +./inc/modules/admin/what-config_reg.php:2:// @DEPRECATED +./inc/modules/admin/what-del_task.php:2:// @DEPRECATED +./inc/modules/admin/what-list_newsletter.php:2:// @DEPRECATED +./inc/modules/admin/what-list_norefs.php:2:// @DEPRECATED +./inc/modules/admin/what-newsletter.php:2:// @DEPRECATED +./inc/modules/admin/what-repair_amenu.php:2:// @DEPRECATED +./inc/modules/admin/what-repair_gmenu.php:2:// @DEPRECATED +./inc/modules/admin/what-repair_mmenu.php:2:// @DEPRECATED +./inc/modules/admin/what-stats.php:2:// @DEPRECATED +./inc/modules/admin/what-user_online.php:2:// @DEPRECATED +./inc/modules/frameset.php:2:// @DEPRECATED +./inc/modules/welcome.php:2:// @DEPRECATED +./inc/patch-system.php:2:// @DEPRECATED +./inc/pool-update.php:2:// @DEPRECATED +./inc/profile-updte.php:2:// @DEPRECATED +./inc/security.php:2:// @DEPRECATED +./inc/sql_error.php:2:// @DEPRECATED +./inc/stats_bonus.php:2:// @DEPRECATED +./inc/template.php:2:// @DEPRECATED +./templates/de/html/admin/admin_add_reflvl.tpl:1: +./templates/de/html/admin/admin_add_shop_cat.tpl:1: +./templates/de/html/admin/admin_admins_contact_form.tpl:1: +./templates/de/html/admin/admin_config_autopurge_pro.tpl:1: +./templates/de/html/admin/admin_config_beg_pro.tpl:1: +./templates/de/html/admin/admin_config_bonus_pro.tpl:1: +./templates/de/html/admin/admin_config_cache.tpl:1: +./templates/de/html/admin/admin_config_doubler_pro.tpl:1: +./templates/de/html/admin/admin_config_reg_pro.tpl:1: +./templates/de/html/admin/admin_config_shop.tpl:1: +./templates/de/html/admin/admin_config_transfer_pro.tpl:1: +./templates/de/html/admin/admin_extensions_installed.tpl:1: +./templates/de/html/admin/admin_extensions_list.tpl:1: +./templates/de/html/admin/admin_extensions_search.tpl:1: +./templates/de/html/admin/admin_forum_add.tpl:1: +./templates/de/html/admin/admin_forum_descr.tpl:1: +./templates/de/html/admin/admin_forum_display_cat.tpl:1: +./templates/de/html/admin/admin_forum_edit_del.tpl:1: +./templates/de/html/admin/admin_forum_edit_forum.tpl:1: +./templates/de/html/admin/admin_holiday_task.tpl:1: +./templates/de/html/admin/admin_list_unconfirmed_header.tpl:1: +./templates/de/html/admin/admin_logout_sql_patches.tpl:1: +./templates/de/html/admin/admin_mods_footer_list.tpl:1: +./templates/de/html/admin/admin_mods_footer_stats2.tpl:1: +./templates/de/html/admin/admin_mods_footer_stats.tpl:1: +./templates/de/html/admin/admin_mods_header_list.tpl:1: +./templates/de/html/admin/admin_mods_header_stats2.tpl:1: +./templates/de/html/admin/admin_mods_header_stats.tpl:1: +./templates/de/html/admin/admin_mods_list_row.tpl:1: +./templates/de/html/admin/admin_mods_list.tpl:1: +./templates/de/html/admin/admin_new_ext.tpl:1: +./templates/de/html/admin/admin_newsletter_tsk.tpl:1: +./templates/de/html/admin/admin_online_footer.tpl:1: +./templates/de/html/admin/admin_online_header.tpl:1: +./templates/de/html/admin/admin_overview_header.tpl:1: +./templates/de/html/admin/admin_patches_row.tpl:1: +./templates/de/html/admin/admin_patches.tpl:1: +./templates/de/html/admin/admin_reg_row.tpl:1: +./templates/de/html/admin/admin_reg.tpl:1: +./templates/de/html/admin/admin_theme_list.tpl:1: +./templates/de/html/fatal_footer.tpl:1: +./templates/de/html/fatal_header.tpl:1: +./templates/de/html/guest/guest_confirm_table.tpl:1: +./templates/de/html/guest/guest_paidlinks_register_header.tpl:1: +./templates/de/html/guest/guest_paidlinks_register.tpl:1: +./templates/de/html/theme_one.tpl:1: +./templates/de/html/theme_select_box.tpl:1: +./templates/de/html/theme_select_form.tpl:1: ### ### template-warnings.log follows: ### ### PHP Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : td in templates/de/html/menu/menu_what_end.tpl, line: 1 in PHP Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : tr in templates/de/html/menu/menu_what_end.tpl, line: 2 in diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index ce8ad10999..e0569e68e6 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -46,19 +46,19 @@ function readFromFile ($FQFN) { if (!isFileReadable($FQFN)) { // This should not happen reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!'); - } elseif (!isset($GLOBALS['file_content'][$FQFN])) { - // Load the file - if (function_exists('file_get_contents')) { - // Use new function - $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN); - } else { - // Fall-back to implode-file chain - $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN)); - } } // END - if + // Load the file + if (function_exists('file_get_contents')) { + // Use new function + $fileContent = file_get_contents($FQFN); + } else { + // Fall-back to implode-file chain + $fileContent = implode('', file($FQFN)); + } + // Return the content - return $GLOBALS['file_content'][$FQFN]; + return $fileContent; } // Writes content to a file @@ -66,7 +66,7 @@ function writeToFile ($FQFN, $content, $aquireLock = FALSE) { // Is the file writeable? if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) { // Not writeable! - logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN))); + logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable or cannot change CHMOD to 0644.", basename($FQFN))); // Failed! :( return FALSE; @@ -74,7 +74,6 @@ function writeToFile ($FQFN, $content, $aquireLock = FALSE) { // By default all is failed... $GLOBALS['file_readable'][$FQFN] = FALSE; - unset($GLOBALS['file_content'][$FQFN]); $return = FALSE; // Is the function there? @@ -89,7 +88,8 @@ function writeToFile ($FQFN, $content, $aquireLock = FALSE) { } } else { // Write it with fopen - $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!'); + $fp = fopen($FQFN, 'w') + or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!'); // Aquire a lock? if ($aquireLock === TRUE) { @@ -108,9 +108,6 @@ function writeToFile ($FQFN, $content, $aquireLock = FALSE) { if ($return !== FALSE) { // Mark it as readable $GLOBALS['file_readable'][$FQFN] = TRUE; - - // Remember content in cache - $GLOBALS['file_content'][$FQFN] = $content; } // END - if // Return status @@ -123,10 +120,7 @@ function clearOutputBuffer () { if (isset($GLOBALS[__FUNCTION__])) { // This function is called twice reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.'); - } // END - if - - // Trigger an error on failure - if ((ob_get_length() > 0) && (!ob_end_clean())) { + } elseif ((ob_get_length() > 0) && (!ob_end_clean())) { // Failed! reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.'); } // END - if -- 2.39.5