From a9d3be549f0b1bcf92757da69dfcd6b997b044dc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 10 Oct 2017 10:39:17 -0700 Subject: [PATCH] try caching storage --- web/includes/Event.php | 15 +++++++++------ web/includes/Storage.php | 8 ++++++++ web/includes/database.php | 8 ++++---- web/includes/functions.php | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/web/includes/Event.php b/web/includes/Event.php index fe9c4909c..1709065d0 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -1,7 +1,7 @@ $v) { $this->{$k} = $v; } } else { - Error('No row for Event ' . $IdOrRow ); + $backTrace = debug_backtrace(); + $file = $backTrace[1]['file']; + $line = $backTrace[1]['line']; + Error('No row for Event ' . $IdOrRow . " from $file:$line"); } + } # end if isset($IdOrRow) } // end function __construct public function Storage() { @@ -163,11 +166,11 @@ class Event { } // end function getStreamSrc function DiskSpace() { - if ( null == $this{'DiskSpace'} ) { - $this{'DiskSpace'} = folder_size( $this->Path() ); + if ( null == $this->{'DiskSpace'} ) { + $this->{'DiskSpace'} = folder_size( $this->Path() ); dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) ); } - return $this{'DiskSpace'}; + return $this->{'DiskSpace'}; } function createListThumbnail( $overwrite=false ) { diff --git a/web/includes/Storage.php b/web/includes/Storage.php index 3e5feef93..45bcfc0c0 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -1,14 +1,21 @@ $v) { $this->{$k} = $v; } + $storage_cache[$IdOrRow] = $this; } else { $this->{'Name'} = ''; $this->{'Path'} = ''; diff --git a/web/includes/database.php b/web/includes/database.php index 9619bd9a8..93c0e0c88 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -127,10 +127,10 @@ function dbQuery( $sql, $params=NULL ) { } else { $result = $dbConn->query( $sql ); } - //if ( $params ) - //Warning("SQL: $sql" . implode(',',$params)); - //else - //Warning("SQL: $sql" ); + if ( $params ) + Warning("SQL: $sql" . implode(',',$params)); + else + Warning("SQL: $sql" ); } catch(PDOException $e) { Fatal( "SQL-ERR '".$e->getMessage()."', statement was '".$sql."'" ); } diff --git a/web/includes/functions.php b/web/includes/functions.php index 7600bf5db..d0c4892b1 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2197,7 +2197,7 @@ function getStreamMode( ) { function folder_size($dir) { $size = 0; foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) { - $size += is_file($each) ? filesize($each) : folderSize($each); + $size += is_file($each) ? filesize($each) : folder_size($each); } return $size; } // end function folder_size