diff --git a/app/TorrentAbstract.php b/app/TorrentAbstract.php index 5ecb6604f..3e7fce38b 100644 --- a/app/TorrentAbstract.php +++ b/app/TorrentAbstract.php @@ -507,7 +507,7 @@ abstract class TorrentAbstract extends BaseAttrObject { $log['adjusted'] = ($log['Adjusted'] === '1'); $log['adjusted_checksum'] = ($log['AdjustedChecksum'] === '1'); $log['checksum'] = ($log['Checksum'] === '1'); - $log['details'] = explode("\r\n", trim($log['Details'] ?? '')); + $log['details'] = trim($log['Details'] ?? '') ? explode("\r\n", trim($log['Details'])) : []; if ($log['adjusted'] && $log['checksum'] !== $log['adjusted_checksum']) { $log['details'][] = 'Bad/No Checksum(s)'; } diff --git a/app/TorrentLog.php b/app/TorrentLog.php index 458f3bac3..8b65bd7fb 100644 --- a/app/TorrentLog.php +++ b/app/TorrentLog.php @@ -53,7 +53,7 @@ class TorrentLog extends BaseObject { AND LogID = ? ", $this->torrent->id(), $this->id ); - $info['detail_list'] = explode("\r\n", $info['Details'] ?? "\r\n"); + $info['detail_list'] = trim($info['Details'] ?? '') ? explode("\r\n", $info['Details']) : []; $info['adjustment_list'] = $info['AdjustmentDetails'] ? unserialize($info['AdjustmentDetails']) : []; $this->info = $info; return $this->info; diff --git a/tests/phpunit/TorrentTest.php b/tests/phpunit/TorrentTest.php index 8b3847558..a56b912f2 100644 --- a/tests/phpunit/TorrentTest.php +++ b/tests/phpunit/TorrentTest.php @@ -367,6 +367,31 @@ class TorrentTest extends TestCase { ); } + public function testLogfileList(): void { + $logfileSummary = new LogfileSummary([ + 'error' => [UPLOAD_ERR_OK], + 'name' => ['valid_log_eac.log'], + 'tmp_name' => [__DIR__ . '/../fixture/valid_log_eac.log'], + ]); + $torrentLogManager = new Manager\TorrentLog(); + $checkerVersion = Logchecker::getLogcheckerVersion(); + foreach ($logfileSummary->all() as $logfile) { + $torrentLogManager->create($this->torrent, $logfile, $checkerVersion); + } + $expected = [ + 'has_riplog' => false, + 'adjustment_details' => [], + 'adjusted' => false, + 'adjusted_checksum' => false, + 'checksum' => true, + 'details' => [], + ]; + $logfileList = $this->torrent->logfileList(); + $this->assertCount(1, $logfileList); + $this->assertArrayIsEqualToArrayOnlyConsideringListOfKeys($expected, $logfileList[0], array_keys($expected)); + $this->assertNotEmpty($logfileList[0]['html_log']); + } + public function testLogfileHashList(): void { try { $logfileSummary = new LogfileSummary([