From bef7098cb4b8fb8143df1e25f40e1c9ccd7f6c05 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 15 Apr 2018 10:26:38 -0400 Subject: [PATCH] Fix Event->Storage() --- web/includes/Event.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/web/includes/Event.php b/web/includes/Event.php index 66929687e..eca85cd97 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -15,12 +15,12 @@ class Event { public function __construct( $IdOrRow = null ) { $row = NULL; if ( $IdOrRow ) { - if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) { - $row = dbFetchOne( 'SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array( $IdOrRow ) ); + if ( is_integer($IdOrRow) or is_numeric($IdOrRow) ) { + $row = dbFetchOne('SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array($IdOrRow)); if ( ! $row ) { Error('Unable to load Event record for Id=' . $IdOrRow ); } - } elseif ( is_array( $IdOrRow ) ) { + } elseif ( is_array($IdOrRow) ) { $row = $IdOrRow; } else { $backTrace = debug_backtrace(); @@ -31,16 +31,16 @@ class Event { return; } - if ( $row ) { - foreach ($row as $k => $v) { - $this->{$k} = $v; - } - } else { + if ( $row ) { + foreach ($row as $k => $v) { + $this->{$k} = $v; + } + } else { $backTrace = debug_backtrace(); $file = $backTrace[1]['file']; $line = $backTrace[1]['line']; - Error('No row for Event ' . $IdOrRow . " from $file:$line"); - } + Error('No row for Event ' . $IdOrRow . " from $file:$line"); + } } # end if isset($IdOrRow) } // end function __construct @@ -51,10 +51,8 @@ class Event { if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) ) { if ( isset($this->{'StorageId'}) and $this->{'StorageId'} ) $this->{'Storage'} = Storage::find_one(array('Id'=>$this->{'StorageId'})); - if ( ! $this->{'Storage'} ) + if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) ) $this->{'Storage'} = new Storage(NULL); - } else { - $this->{'Storage'} = new Storage(NULL); } return $this->{'Storage'}; } @@ -73,12 +71,12 @@ class Event { $backTrace = debug_backtrace(); $file = $backTrace[1]['file']; $line = $backTrace[1]['line']; - Warning( "Unknown function call Event->$fn from $file:$line" ); + Warning("Unknown function call Event->$fn from $file:$line"); } } public function Time() { - if ( ! isset( $this->{'Time'} ) ) { + if ( ! isset($this->{'Time'}) ) { $this->{'Time'} = strtotime($this->{'StartTime'}); } return $this->{'Time'}; @@ -100,7 +98,7 @@ class Event { $event_path = $this->{'MonitorId'} .'/'.$this->{'Id'}; } - return( $event_path ); + return $event_path; } // end function Relative_Path() public function Link_Path() { @@ -210,8 +208,8 @@ class Event { $this->{'DiskSpace'} = $new; } if ( null === $this->{'DiskSpace'} ) { - $this->{'DiskSpace'} = folder_size( $this->Path() ); - dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) ); + $this->{'DiskSpace'} = folder_size($this->Path()); + dbQuery('UPDATE Events SET DiskSpace=? WHERE Id=?', array($this->{'DiskSpace'}, $this->{'Id'})); } return $this->{'DiskSpace'}; }