From cf4f6a3579736eaedfc7e00517c254b2bd7e8f0a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 3 Sep 2018 11:25:26 +0200 Subject: [PATCH] Update ReleaseRemover class --- Blacklight/ReleaseRemover.php | 26 ++++++++++++++------------ Changelog | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Blacklight/ReleaseRemover.php b/Blacklight/ReleaseRemover.php index 8d08e78840..e628d2d3d8 100755 --- a/Blacklight/ReleaseRemover.php +++ b/Blacklight/ReleaseRemover.php @@ -12,10 +12,6 @@ */ class ReleaseRemover { - /** - * @const New line. - */ - private const N = PHP_EOL; /** * @var string @@ -150,7 +146,7 @@ public function __construct(array $options = []) * Remove releases using user criteria. * * @param array $arguments Array of criteria used to delete unwanted releases. - * Criteria muse look like this : columnName=modifier="content" + * Criteria must look like this : columnName=modifier="content" * columnName is a column name from the releases table. * modifiers are : equals,like,bigger,smaller * content is what to change the column content to @@ -492,7 +488,7 @@ protected function removePasswordURL() 'SELECT r.guid, r.searchname, r.id FROM releases r STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id - WHERE rf.name LIKE %s ', + WHERE rf.name LIKE %s %s', $this->pdo->quote('%password.url%'), $this->crapTime ); @@ -857,8 +853,7 @@ protected function removeBlacklistFiles(): bool if (\count($allRegex) > 0) { foreach ($allRegex as $regex) { $regexSQL = sprintf( - 'STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id - WHERE rf.name REGEXP %s ', + 'STRAIGHT_JOIN release_files rf ON r.id = rf.releases_id WHERE rf.name REGEXP %s', $this->pdo->quote($regex->regex) ); @@ -1014,8 +1009,10 @@ protected function removeCodecPoster() /** * Delete releases from the database. + * + * @return true */ - protected function deleteReleases() + protected function deleteReleases(): bool { $deletedCount = 0; foreach ($this->result as $release) { @@ -1040,7 +1037,7 @@ protected function deleteReleases() * * @return bool False on failure, true on success after setting a count of found releases. */ - protected function checkSelectQuery() + protected function checkSelectQuery(): bool { // Run the query, check if it picked up anything. $result = DB::select($this->cleanSpaces($this->query)); @@ -1073,7 +1070,7 @@ protected function formatCriteriaQuery($argument) return ''; } - $this->error = 'Invalid argument supplied: '.$argument.self::N; + $this->error = 'Invalid argument supplied: '.$argument.PHP_EOL; $args = explode('=', $argument); if (\count($args) === 3) { $args[0] = $this->cleanSpaces($args[0]); @@ -1244,7 +1241,7 @@ protected function checkUserResponse() // Print the query to the user, ask them if they want to continue using it. echo ColorCLI::primary( 'This is the query we have formatted using your criteria, you can run it in SQL to see if you like the results:'. - self::N.$this->query.';'.self::N. + PHP_EOL.$this->query.';'.PHP_EOL. 'If you are satisfied, type yes and press enter. Anything else will exit.' ); @@ -1308,6 +1305,11 @@ protected function returnError() return false; } + /** + * @param string $dbRegex + * + * @return bool|mixed|string + */ protected function extractSrchFromRegx($dbRegex = '') { $regexMatch = ''; diff --git a/Changelog b/Changelog index 30a17cbe08..1fc3e0066e 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-09-03 DariusIII + * Chg: Update ReleaseRemover class * Chg: Check for array before inserting audio data from mediainfo * Chg: Add checks before inserting audio data from mediainfo * Chg: Update handling of allAsMgr tables