From 1be29799c55fe1e2992930373b553661da48062e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 21 May 2013 00:55:02 +0200 Subject: [PATCH] Improved performance for file logging --- .../system/package/FilesFileHandler.class.php | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php b/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php index fda4ac8dcb..5e5be6be0b 100644 --- a/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php +++ b/wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php @@ -61,39 +61,14 @@ class FilesFileHandler extends PackageInstallationFileHandler { return; } - // fetch already installed files - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add('packageID = ?', array($this->packageInstallation->getPackageID())); - $conditions->add('filename IN (?)', array($files)); - $conditions->add('application = ?', array($this->application)); - - $sql = "SELECT filename - FROM wcf".WCF_N."_package_installation_file_log - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - - while ($filename = $statement->fetchColumn()) { - $index = array_search($filename, $files); - - if ($index !== false) { - unset($files[$index]); - } - } - - if (!empty($files)) { - $sql = "INSERT INTO wcf".WCF_N."_package_installation_file_log - (packageID, filename, application) - VALUES (?, ?, ?)"; + // insert 50 files per loop + for ($i = 0, $steps = ceil(count($files) / 50); $i < $steps; $i++) { + $items = array_slice($files, 0, 50); + $sql = "INSERT IGNORE INTO wcf".WCF_N."_package_installation_file_log + (packageID, filename, application) + VALUES ".substr(str_repeat("(".$this->packageInstallation->getPackageID().", ?, '".$this->application."'), ", count($items)), 0, -2); $statement = WCF::getDB()->prepareStatement($sql); - - foreach ($files as $file) { - $statement->execute(array( - $this->packageInstallation->getPackageID(), - $file, - $this->application - )); - } + $statement->execute($items); } } } -- 2.20.1