From f07b1a70ab11e7da1be27a195a07333fe71b01b3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 15 May 2013 16:07:10 -0700 Subject: [PATCH] Prevent empty log files. --- e107_handlers/admin_log_class.php | 12 +++++++++--- e107_handlers/arraystorage_class.php | 2 +- e107_handlers/core_functions.php | 4 ++-- e107_handlers/plugin_class.php | 12 +++++++++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php index 73b635b43..98d46c7b7 100644 --- a/e107_handlers/admin_log_class.php +++ b/e107_handlers/admin_log_class.php @@ -653,6 +653,10 @@ class e_admin_log { $text .= " e107 CMS Log file : ".$logTitle." ".date('Y-m-d_H-i-s')."\n"; $text .= "-------------------------------------------------------------------------------------------\n\n"; + } + else + { + return; } foreach($this->_allMessages as $m) @@ -660,8 +664,10 @@ class e_admin_log $text .= date('Y-m-d H:i:s',$m['time'])." \t".str_pad($m['dislevel'],10," ",STR_PAD_RIGHT)."\t".strip_tags($m['message'])."\n"; } + $date = date('Y-m-d_H-i-s'); + $fileName = e_LOG.$date."_".$this->logFile.".log"; - if(file_put_contents($this->logFile,$text)) + if(file_put_contents($fileName,$text)) { $this->_allMessages = array(); return $this->logFile; @@ -681,9 +687,9 @@ class e_admin_log public function toFile($name,$logTitle='') { - $date = date('Y-m-d_H-i-s'); - $this->logFile = e_LOG.$date."_".$name.".log"; + + $this->logFile = $name; $this->saveToFile($logTitle); $this->logFile = null; } diff --git a/e107_handlers/arraystorage_class.php b/e107_handlers/arraystorage_class.php index 9ccc5dcfb..07fc3f7bf 100644 --- a/e107_handlers/arraystorage_class.php +++ b/e107_handlers/arraystorage_class.php @@ -11,7 +11,7 @@ if (!defined('e107_INIT')) { exit; } /** -* DEPRECATED: Allows Storage of arrays without use of serialize functions +* @DEPRECATED: Allows Storage of arrays without use of serialize functions * */ class ArrayData { diff --git a/e107_handlers/core_functions.php b/e107_handlers/core_functions.php index e1869e0f3..06da228a5 100644 --- a/e107_handlers/core_functions.php +++ b/e107_handlers/core_functions.php @@ -367,7 +367,7 @@ class e_array { /** - * DEPRECATED - Backwards Compatible. Use write() instead; + * @DEPRECATED - Backwards Compatible. Use e107::serialize() instead; * @param array $ArrayData array to be stored * @param bool $AddSlashes default true, add slashes for db storage, else false * @returnReturn a string containg exported array data. @@ -385,7 +385,7 @@ class e_array { } /** - * DEPRECATED: Use read(); instead. + * @DEPRECATED: Use e107::unserialize(); instead. * Returns an array from stored array data. * * @param string $ArrayData diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 2476b2091..d5c6336d5 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -173,6 +173,7 @@ class e107plugin $xml = e107::getXml(); $mes = e107::getMessage(); $needed = array(); + $log = e107::getAdminLog(); if(!$plugVersions = e107::getConfig('core')->get('plug_installed')) { @@ -195,6 +196,7 @@ class e107plugin $mes->addDebug("Plugin Update(s) Required"); return TRUE; } + $needed[$path] = $data; } @@ -207,11 +209,19 @@ class e107plugin return TRUE; } - $mes->addDebug("Plugin: {$path} requires an update."); + // $mes->addDebug("Plugin: {$path} requires an update."); + + // $log->flushMessages(); $needed[$path] = $data; } } + } + + // Display debug and log to file. + foreach($needed as $path=>$tmp) + { + $log->addDebug("Plugin: {$path} requires an update."); } return count($needed) ? $needed : FALSE;