From 4271fe99ca7560109b39b18599d8ce19f3205eae Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 19 Apr 2017 20:08:02 +0200 Subject: [PATCH] Fix bad logic for namefixer release update function --- Changelog | 1 + misc/update/match_prefiles.php | 12 +++++------- nntmux/NameFixer.php | 12 ++++++------ resources/db/patches/mysql/0271~general.sql | 0 resources/db/patches/mysql/0272~roleexcat.sql | 0 .../patches/mysql/0273~release_naming_regexees.sql | 0 .../db/patches/mysql/0274~release_naming_regexes.sql | 0 .../db/patches/mysql/0275~release_naming_regexes.sql | 0 resources/db/patches/mysql/0276~settings.sql | 0 resources/db/patches/mysql/0277~settings.sql | 0 resources/db/patches/mysql/0278~settings.sql | 0 resources/db/patches/mysql/0279~settings.sql | 0 resources/db/patches/mysql/0280~settings.sql | 0 resources/db/patches/mysql/0281~tmux.sql | 0 resources/db/patches/mysql/0282~settings.sql | 0 resources/db/patches/mysql/0283~release_groups.sql | 0 resources/db/patches/mysql/0284~general.sql | 0 resources/db/patches/mysql/0285~predb_hashes.sql | 0 resources/db/patches/mysql/0286~general.sql | 0 resources/db/patches/mysql/0287~binaries.sql | 0 resources/db/patches/mysql/0288~collections.sql | 0 resources/db/patches/mysql/0289~parts.sql | 0 resources/db/patches/mysql/0290~missed_parts.sql | 0 resources/db/patches/mysql/0291~mgr_general.sql | 0 resources/db/patches/mysql/0292~mgr_posters.sql | 0 resources/db/patches/mysql/0293~general.sql | 0 resources/db/patches/mysql/0294~collections.sql | 0 resources/db/patches/mysql/0295~releases_regexes.sql | 0 resources/db/patches/mysql/0296~general.sql | 0 resources/db/patches/mysql/0297~steam_apps.sql | 0 resources/db/patches/mysql/0298~gamesinfo.sql | 0 resources/db/patches/mysql/0299~settings.sql | 0 resources/db/patches/mysql/0300~general.sql | 0 resources/db/patches/mysql/0301~par2_hashes.sql | 0 resources/db/patches/mysql/0302~general.sql | 0 .../db/patches/mysql/0303~release_naming_regexes.sql | 0 36 files changed, 12 insertions(+), 13 deletions(-) mode change 100644 => 100755 resources/db/patches/mysql/0271~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0272~roleexcat.sql mode change 100644 => 100755 resources/db/patches/mysql/0273~release_naming_regexees.sql mode change 100644 => 100755 resources/db/patches/mysql/0274~release_naming_regexes.sql mode change 100644 => 100755 resources/db/patches/mysql/0275~release_naming_regexes.sql mode change 100644 => 100755 resources/db/patches/mysql/0276~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0277~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0278~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0279~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0280~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0281~tmux.sql mode change 100644 => 100755 resources/db/patches/mysql/0282~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0283~release_groups.sql mode change 100644 => 100755 resources/db/patches/mysql/0284~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0285~predb_hashes.sql mode change 100644 => 100755 resources/db/patches/mysql/0286~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0287~binaries.sql mode change 100644 => 100755 resources/db/patches/mysql/0288~collections.sql mode change 100644 => 100755 resources/db/patches/mysql/0289~parts.sql mode change 100644 => 100755 resources/db/patches/mysql/0290~missed_parts.sql mode change 100644 => 100755 resources/db/patches/mysql/0291~mgr_general.sql mode change 100644 => 100755 resources/db/patches/mysql/0292~mgr_posters.sql mode change 100644 => 100755 resources/db/patches/mysql/0293~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0294~collections.sql mode change 100644 => 100755 resources/db/patches/mysql/0295~releases_regexes.sql mode change 100644 => 100755 resources/db/patches/mysql/0296~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0297~steam_apps.sql mode change 100644 => 100755 resources/db/patches/mysql/0298~gamesinfo.sql mode change 100644 => 100755 resources/db/patches/mysql/0299~settings.sql mode change 100644 => 100755 resources/db/patches/mysql/0300~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0301~par2_hashes.sql mode change 100644 => 100755 resources/db/patches/mysql/0302~general.sql mode change 100644 => 100755 resources/db/patches/mysql/0303~release_naming_regexes.sql diff --git a/Changelog b/Changelog index 112c094e8..d731415d2 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-04-19 DariusIII + * Fix: Fix bad logic for namefixer release update function * Fix: Cast $release['releases_id'] as integer when comparing to $this->relid in NameFixer class * Chg: Declare PHP7 return types, remove duplicated TV naming regex in NameFixer class * Chg: Declare PHP7 return types in Categorize class and add PHPDOC blocks to functions diff --git a/misc/update/match_prefiles.php b/misc/update/match_prefiles.php index 66daaf7db..99a163966 100755 --- a/misc/update/match_prefiles.php +++ b/misc/update/match_prefiles.php @@ -4,15 +4,13 @@ require_once dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'bootstrap.php'; use nntmux\ColorCLI; use nntmux\NameFixer; -$cli = new ColorCLI(); - if (!isset($argv[1]) && ($argv[1] !== 'full' || !is_numeric($argv[1]))) { exit( - $cli->error(PHP_EOL - . "This script tries to match release filenames to PreDB filenames." . PHP_EOL - . "To display the changes, use 'show' as the second argument. The optional third argument will limit the amount of filenames to attempt to match." . PHP_EOL . PHP_EOL - . "php match_prefiles.php full show ...: to run on full database and show renames." . PHP_EOL - . "php match_prefiles.php 2000 show ...: to run against 2000 distinct releases and show renames." . PHP_EOL + ColorCLI::error(PHP_EOL + . 'This script tries to match release filenames to PreDB filenames.' . PHP_EOL + . 'To display the changes, use "show" as the second argument. The optional third argument will limit the amount of filenames to attempt to match.' . PHP_EOL . PHP_EOL + . 'php match_prefiles.php full show ...: to run on full database and show renames.' . PHP_EOL + . 'php match_prefiles.php 2000 show ...: to run against 2000 distinct releases and show renames.' . PHP_EOL ) ); } diff --git a/nntmux/NameFixer.php b/nntmux/NameFixer.php index f65d75224..d4ca4e8c1 100755 --- a/nntmux/NameFixer.php +++ b/nntmux/NameFixer.php @@ -757,9 +757,9 @@ class NameFixer * @param int $show * @param int $preId */ - public function updateRelease($release, $name, $method, $echo, $type, $nameStatus, $show, $preId = 0): void + public function updateRelease($release, $name, $method, $echo, $type, int $nameStatus, int $show, int $preId = 0): void { - $release['releases_id'] = ($release['releases_id'] ?? $release['releaseid']); + $release['releases_id'] = $release['releases_id'] ?? $release['releaseid']; if ($this->relid !== (int)$release['releases_id']) { $releaseCleaning = new ReleaseCleaning($this->pdo); $newName = $releaseCleaning->fixerCleaner($name); @@ -817,13 +817,13 @@ class NameFixer } if ($type !== 'PAR2, ') { - echo "\n"; + echo PHP_EOL; } } $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); - if ($echo === true) { + if ($echo === 1) { if ($nameStatus === 1) { $status = ''; switch ($type) { @@ -851,7 +851,7 @@ class NameFixer $status = 'isrenamed = 1, iscategorized = 1, proc_uid = 1,'; break; } - $this->pdo->queryExec( + $end = $this->pdo->queryExec( sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, @@ -1033,7 +1033,7 @@ class NameFixer * * @param array $args The CLI script arguments */ - public function getPreFileNames(array $args = array()): void + public function getPreFileNames(array $args = []): void { $n = PHP_EOL; diff --git a/resources/db/patches/mysql/0271~general.sql b/resources/db/patches/mysql/0271~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0272~roleexcat.sql b/resources/db/patches/mysql/0272~roleexcat.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0273~release_naming_regexees.sql b/resources/db/patches/mysql/0273~release_naming_regexees.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0274~release_naming_regexes.sql b/resources/db/patches/mysql/0274~release_naming_regexes.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0275~release_naming_regexes.sql b/resources/db/patches/mysql/0275~release_naming_regexes.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0276~settings.sql b/resources/db/patches/mysql/0276~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0277~settings.sql b/resources/db/patches/mysql/0277~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0278~settings.sql b/resources/db/patches/mysql/0278~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0279~settings.sql b/resources/db/patches/mysql/0279~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0280~settings.sql b/resources/db/patches/mysql/0280~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0281~tmux.sql b/resources/db/patches/mysql/0281~tmux.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0282~settings.sql b/resources/db/patches/mysql/0282~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0283~release_groups.sql b/resources/db/patches/mysql/0283~release_groups.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0284~general.sql b/resources/db/patches/mysql/0284~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0285~predb_hashes.sql b/resources/db/patches/mysql/0285~predb_hashes.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0286~general.sql b/resources/db/patches/mysql/0286~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0287~binaries.sql b/resources/db/patches/mysql/0287~binaries.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0288~collections.sql b/resources/db/patches/mysql/0288~collections.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0289~parts.sql b/resources/db/patches/mysql/0289~parts.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0290~missed_parts.sql b/resources/db/patches/mysql/0290~missed_parts.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0291~mgr_general.sql b/resources/db/patches/mysql/0291~mgr_general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0292~mgr_posters.sql b/resources/db/patches/mysql/0292~mgr_posters.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0293~general.sql b/resources/db/patches/mysql/0293~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0294~collections.sql b/resources/db/patches/mysql/0294~collections.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0295~releases_regexes.sql b/resources/db/patches/mysql/0295~releases_regexes.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0296~general.sql b/resources/db/patches/mysql/0296~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0297~steam_apps.sql b/resources/db/patches/mysql/0297~steam_apps.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0298~gamesinfo.sql b/resources/db/patches/mysql/0298~gamesinfo.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0299~settings.sql b/resources/db/patches/mysql/0299~settings.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0300~general.sql b/resources/db/patches/mysql/0300~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0301~par2_hashes.sql b/resources/db/patches/mysql/0301~par2_hashes.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0302~general.sql b/resources/db/patches/mysql/0302~general.sql old mode 100644 new mode 100755 diff --git a/resources/db/patches/mysql/0303~release_naming_regexes.sql b/resources/db/patches/mysql/0303~release_naming_regexes.sql old mode 100644 new mode 100755