* @package WoltLabSuite\Core
*/
+use wcf\system\database\table\column\BigintDatabaseTableColumn;
use wcf\system\database\table\column\NotNullInt10DatabaseTableColumn;
use wcf\system\database\table\column\TinyintDatabaseTableColumn;
+use wcf\system\database\table\column\VarbinaryDatabaseTableColumn;
use wcf\system\database\table\PartialDatabaseTable;
return [
PartialDatabaseTable::create('wcf1_package_installation_file_log')
->columns([
NotNullInt10DatabaseTableColumn::create('packageID'),
+ VarbinaryDatabaseTableColumn::create('sha256')
+ ->length(32)
+ ->defaultValue(null),
+ BigintDatabaseTableColumn::create('lastUpdated')
+ ->length(20)
+ ->defaultValue(null),
]),
PartialDatabaseTable::create('wcf1_package_installation_plugin')
->columns([
namespace wcf\system\package;
+use wcf\data\application\Application;
use wcf\data\package\Package;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
return;
}
- $sql = "INSERT IGNORE INTO wcf" . WCF_N . "_package_installation_file_log
- (packageID, filename, application)
- VALUES (?, ?, ?)";
+ $baseDirectory = Application::getDirectory($this->application);
+
+ $sql = "INSERT INTO wcf1_package_installation_file_log
+ (packageID, filename, application, sha256, lastUpdated)
+ VALUES (?, ?, ?, ?, ?)
+ ON DUPLICATE KEY UPDATE sha256 = VALUES(sha256),
+ lastUpdated = VALUES(lastUpdated)";
$statement = WCF::getDB()->prepareStatement($sql);
WCF::getDB()->beginTransaction();
$this->packageInstallation->getPackageID(),
$file,
$this->application,
+ \hash_file('sha256', $baseDirectory . $file, true),
+ TIME_NOW,
]);
}
WCF::getDB()->commitTransaction();
// log files
$sql = "INSERT INTO wcf" . WCF_N . "_package_installation_file_log
- (packageID, filename, application)
- VALUES (?, ?, ?)";
+ (packageID, filename, application, sha256, lastUpdated)
+ VALUES (?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([
- $this->installation->getPackageID(),
- 'config.inc.php',
- Package::getAbbreviation($this->installation->getPackage()->package),
- ]);
- $statement->execute([
- $this->installation->getPackageID(),
+ foreach ([
PackageInstallationDispatcher::CONFIG_FILE,
- Package::getAbbreviation($this->installation->getPackage()->package),
- ]);
+ 'config.inc.php',
+ ] as $filename) {
+ $statement->execute([
+ $this->installation->getPackageID(),
+ $filename,
+ Package::getAbbreviation($this->installation->getPackage()->package),
+ \hash_file('sha256', $packageDir . $filename, true),
+ \TIME_NOW,
+ ]);
+ }
// load application
WCF::loadRuntimeApplication($this->installation->getPackageID());
packageID INT(10) NOT NULL,
filename VARBINARY(765) NOT NULL, -- VARBINARY(765) roughly equals VARCHAR(255)
application VARCHAR(20) NOT NULL,
+ sha256 VARBINARY(32) DEFAULT NULL,
+ lastUpdated BIGINT(20) DEFAULT NULL,
UNIQUE KEY applicationFile (application, filename)
);