From: Alexander Ebert Date: Mon, 20 May 2013 22:55:02 +0000 (+0200) Subject: Improved performance for file logging X-Git-Tag: 2.0.0_Beta_1~118^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1be29799c55fe1e2992930373b553661da48062e;p=GitHub%2FWoltLab%2FWCF.git Improved performance for file logging --- 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); } } }