Protokoll #24565
| ID | 24565 |
|---|---|
| Zeitstempel | 2025-12-27 23:48:53.823450 |
| Client | root |
| IP | Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 |
| Modell | claude-sonnet-4-20250514 |
| Status | pending |
| Tokens | 1,437 (Input: 0, Output: 0) |
| Dauer | - |
| Request-Zeit | Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18 |
| Response-Zeit | - |
Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22
Request
{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Persistence\/FileBackupRepository.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Persistence;\n\n\/\/ @responsibility: Persistenz für Datei-Backup-Historie (Restore-Validierung)\n\nuse Domain\\Repository\\FileBackupRepositoryInterface;\nuse PDO;\n\nclass FileBackupRepository implements FileBackupRepositoryInterface\n{\n private PDO $db;\n\n \/**\n * Allowlist of base paths where file restoration is permitted.\n * Only files within these directories can be restored.\n *\/\n private const ALLOWED_RESTORE_PATHS = [\n '\/var\/www\/dev.campus.systemische-tools.de\/',\n '\/var\/www\/prod.campus.systemische-tools.de\/',\n ];\n\n public function __construct(PDO $pdo)\n {\n $this->db = $pdo;\n }\n\n \/**\n * Find all backups with optional filters.\n *\n * @param array<string, mixed> $filters\n *\/\n public function findAll(array $filters = [], int $limit = 50, int $offset = 0): array\n {\n $sql = 'SELECT id, file_path, content_hash, file_size, version, change_type,\n changed_at, changed_by, reason\n FROM file_backup_history WHERE 1=1';\n $params = [];\n\n if (!empty($filters['search'])) {\n $sql .= ' AND file_path LIKE :search';\n $params['search'] = '%' . $filters['search'] . '%';\n }\n\n if (!empty($filters['change_type'])) {\n $sql .= ' AND change_type = :change_type';\n $params['change_type'] = $filters['change_type'];\n }\n\n $sql .= ' ORDER BY changed_at DESC LIMIT :limit OFFSET :offset';\n\n $stmt = $this->db->prepare($sql);\n foreach ($params as $key => $value) {\n $stmt->bindValue(':' . $key, $value);\n }\n $stmt->bindValue(':limit', $limit, PDO::PARAM_INT);\n $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);\n $stmt->execute();\n\n return $stmt->fetchAll(PDO::FETCH_ASSOC);\n }\n\n \/**\n * Count total backups with filters.\n *\n * @param array<string, mixed> $filters\n *\/\n public function count(array $filters = []): int\n {\n $sql = 'SELECT COUNT(*) FROM file_backup_history WHERE 1=1';\n $params = [];\n\n if (!empty($filters['search'])) {\n $sql .= ' AND file_path LIKE :search';\n $params['search'] = '%' . $filters['search'] . '%';\n }\n\n if (!empty($filters['change_type'])) {\n $sql .= ' AND change_type = :change_type';\n $params['change_type'] = $filters['change_type'];\n }\n\n $stmt = $this->db->prepare($sql);\n $stmt->execute($params);\n\n return (int) $stmt->fetchColumn();\n }\n\n \/**\n * Find backup by ID.\n *\/\n public function findById(int $id): ?array\n {\n $stmt = $this->db->prepare(\n 'SELECT * FROM file_backup_history WHERE id = :id'\n );\n $stmt->execute(['id' => $id]);\n $result = $stmt->fetch(PDO::FETCH_ASSOC);\n\n return $result !== false ? $result : null;\n }\n\n \/**\n * Find all backups for a specific file path.\n *\/\n public function findByFilePath(string $path): array\n {\n $stmt = $this->db->prepare(\n 'SELECT id, file_path, content_hash, file_size, version, change_type,\n changed_at, changed_by, reason\n FROM file_backup_history\n WHERE file_path = :path\n ORDER BY version DESC'\n );\n $stmt->execute(['path' => $path]);\n\n return $stmt->fetchAll(PDO::FETCH_ASSOC);\n }\n\n \/**\n * Get statistics about backups.\n *\n * @return array<string, int>\n *\/\n public function getStatistics(): array\n {\n $stats = [];\n\n \/\/ Total backups\n $stats['total'] = (int) $this->db->query(\n 'SELECT COUNT(*) FROM file_backup_history'\n )->fetchColumn();\n\n \/\/ Unique files\n $stats['files'] = (int) $this->db->query(\n 'SELECT COUNT(DISTINCT file_path) FROM file_backup_history'\n )->fetchColumn();\n\n \/\/ Total versions (max version per file summed)\n $stats['versions'] = (int) $this->db->query(\n 'SELECT COALESCE(SUM(max_version), 0) FROM (\n SELECT MAX(version) as max_version FROM file_backup_history GROUP BY file_path\n ) as v'\n )->fetchColumn();\n\n \/\/ Last 24 hours\n $stats['recent'] = (int) $this->db->query(\n 'SELECT COUNT(*) FROM file_backup_history WHERE changed_at >= NOW() - INTERVAL 24 HOUR'\n )->fetchColumn();\n\n \/\/ By change type\n $stats['created'] = (int) $this->db->query(\n \"SELECT COUNT(*) FROM file_backup_history WHERE change_type = 'created'\"\n )->fetchColumn();\n\n $stats['modified'] = (int) $this->db->query(\n \"SELECT COUNT(*) FROM file_backup_history WHERE change_type = 'modified'\"\n )->fetchColumn();\n\n return $stats;\n }\n\n \/**\n * Restore a file from backup.\n *\n * @throws \\RuntimeException If restore fails or path validation fails\n *\/\n public function restore(int $id): bool\n {\n $backup = $this->findById($id);\n\n if ($backup === null) {\n throw new \\RuntimeException('Backup not found');\n }\n\n $filePath = $backup['file_path'];\n $content = $backup['file_content'];\n",
"numLines": 180,
"startLine": 1,
"totalLines": 296
}
}
}
Response
-