Passed
Push — master ( 059b28...26ef6b )
by Darko
13:18 queued 07:30
created
Blacklight/Releases.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             ($start === 0 ? ' LIMIT '.$num : ' LIMIT '.$num.' OFFSET '.$start)
90 90
         );
91 91
 
92
-        return Cache::flexible(md5($qry.$page), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($qry, $cat, $maxAge, $excludedCats, $groupName) {
92
+        return Cache::flexible(md5($qry.$page), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($qry, $cat, $maxAge, $excludedCats, $groupName) {
93 93
             $sql = self::fromQuery($qry);
94 94
             if (\count($sql) > 0) {
95 95
                 $possibleRows = $this->getBrowseCount($cat, $maxAge, $excludedCats, $groupName);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				GROUP BY r.id
266 266
 				ORDER BY %s %s %s",
267 267
             $this->uSQL($userShows, 'videos_id'),
268
-            (! empty($excludedCats) ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
268
+            (!empty($excludedCats) ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
269 269
             NZB::NZB_ADDED,
270 270
             Category::TV_ROOT,
271 271
             Category::TV_OTHER,
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             ($offset === false ? '' : (' LIMIT '.$limit.' OFFSET '.$offset))
277 277
         );
278 278
 
279
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql) {
279
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql) {
280 280
             return self::fromQuery($sql);
281 281
         });
282 282
     }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     {
331 331
         // Delete NZB from disk.
332 332
         $nzbPath = $nzb->NZBPath($identifiers['g']);
333
-        if (! empty($nzbPath)) {
333
+        if (!empty($nzbPath)) {
334 334
             File::delete($nzbPath);
335 335
         }
336 336
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
      */
371 371
     public function updateMulti($guids, $category, $grabs, $videoId, $episodeId, $anidbId, $imdbId)
372 372
     {
373
-        if (! \is_array($guids) || \count($guids) < 1) {
373
+        if (!\is_array($guids) || \count($guids) < 1) {
374 374
             return false;
375 375
         }
376 376
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
         $sql = '(1=2 ';
395 395
         foreach ($userQuery as $query) {
396 396
             $sql .= sprintf('OR (r.%s = %d', $type, $query->$type);
397
-            if (! empty($query->categories)) {
397
+            if (!empty($query->categories)) {
398 398
                 $catsArr = explode('|', $query->categories);
399 399
                 if (\count($catsArr) > 1) {
400 400
                     $sql .= sprintf(' AND r.categories_id IN (%s)', implode(',', $catsArr));
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
             $orderBy = $this->getBrowseOrder($orderBy);
436 436
         }
437 437
 
438
-        $searchFields = Arr::where($searchArr, static function ($value) {
438
+        $searchFields = Arr::where($searchArr, static function($value) {
439 439
             return $value !== -1;
440 440
         });
441 441
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
             $searchResult = $this->elasticSearch->indexSearch($phrases, $limit);
446 446
         } else {
447 447
             $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', '', [], $searchFields);
448
-            if (! empty($searchResult)) {
448
+            if (!empty($searchResult)) {
449 449
                 $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
450 450
             }
451 451
         }
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
             $offset
511 511
         );
512 512
 
513
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql) {
513
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql) {
514 514
             $releases = self::fromQuery($sql);
515 515
             if ($releases->isNotEmpty()) {
516 516
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 $searchResult = $this->elasticSearch->indexSearchApi($searchName, $limit);
528 528
             } else {
529 529
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $searchName, ['searchname']);
530
-                if (! empty($searchResult)) {
530
+                if (!empty($searchResult)) {
531 531
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
532 532
                 }
533 533
             }
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
             ((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', UsenetGroup::getIDByName($groupName)) : ''),
544 544
             $catQuery,
545 545
             (\count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
546
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
546
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
547 547
             ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '')
548 548
         );
549 549
         $baseSql = sprintf(
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
             $offset
575 575
         );
576 576
 
577
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql, $searchName, $searchResult) {
578
-            if ($searchName !== -1 && ! empty($searchResult)) {
577
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql, $searchName, $searchResult) {
578
+            if ($searchName !== -1 && !empty($searchResult)) {
579 579
                 $releases = self::fromQuery($sql);
580 580
             } elseif ($searchName !== -1 && empty($searchResult)) {
581 581
                 $releases = collect();
@@ -627,11 +627,11 @@  discard block
 block discarded – undo
627 627
             $show = self::fromQuery($showQry);
628 628
 
629 629
             if ($show->isNotEmpty()) {
630
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
630
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
631 631
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
632
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
632
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
633 633
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
634
-                } elseif (! empty($series) && empty($episode)) {
634
+                } elseif (!empty($series) && empty($episode)) {
635 635
                     // If $series is set but episode is not, return Season Packs and Episodes
636 636
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
637 637
                 }
@@ -645,26 +645,26 @@  discard block
 block discarded – undo
645 645
         }
646 646
 
647 647
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
648
-        if (! empty($name) && $showSql === '') {
649
-            if (! empty($series) && (int) $series < 1900) {
648
+        if (!empty($name) && $showSql === '') {
649
+            if (!empty($series) && (int) $series < 1900) {
650 650
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
651
-                if (! empty($episode) && ! str_contains($episode, '/')) {
651
+                if (!empty($episode) && !str_contains($episode, '/')) {
652 652
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
653 653
                 }
654 654
                 // If season is not empty but episode is, add a wildcard to the search
655 655
                 if (empty($episode)) {
656 656
                     $name .= '*';
657 657
                 }
658
-            } elseif (! empty($airDate)) {
658
+            } elseif (!empty($airDate)) {
659 659
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
660 660
             }
661 661
         }
662
-        if (! empty($name)) {
662
+        if (!empty($name)) {
663 663
             if (config('nntmux.elasticsearch_enabled') === true) {
664 664
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
665 665
             } else {
666 666
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
667
-                if (! empty($searchResult)) {
667
+                if (!empty($searchResult)) {
668 668
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
669 669
                 }
670 670
             }
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
             NZB::NZB_ADDED,
681 681
             $this->showPasswords(),
682 682
             $showSql,
683
-            (! empty($name) && ! empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
683
+            (!empty($name) && !empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
684 684
             Category::getCategorySearch($cat),
685 685
             $maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : '',
686 686
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '',
687
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
687
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
688 688
         );
689 689
         $baseSql = sprintf(
690 690
             "SELECT r.searchname, r.guid, r.postdate, r.groups_id, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.videos_id, r.tv_episodes_id, r.haspreview, r.jpgstatus,
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
             $offset
718 718
         );
719 719
 
720
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql, $name, $searchResult) {
721
-            $releases = ((! empty($name) && ! empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
720
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql, $name, $searchResult) {
721
+            $releases = ((!empty($name) && !empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
722 722
             if (count($releases) !== 0 && $releases->isNotEmpty()) {
723 723
                 $releases[0]->_totalrows = $this->getPagerCount(
724 724
                     preg_replace('#LEFT(\s+OUTER)?\s+JOIN\s+(?!tv_episodes)\s+.*ON.*=.*\n#i', ' ', $baseSql)
@@ -762,11 +762,11 @@  discard block
 block discarded – undo
762 762
 
763 763
             $show = self::fromQuery($showQry);
764 764
             if ($show->isNotEmpty()) {
765
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
765
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
766 766
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
767
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
767
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
768 768
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
769
-                } elseif (! empty($series) && empty($episode)) {
769
+                } elseif (!empty($series) && empty($episode)) {
770 770
                     // If $series is set but episode is not, return Season Packs and Episodes
771 771
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
772 772
                 }
@@ -779,26 +779,26 @@  discard block
 block discarded – undo
779 779
             }
780 780
         }
781 781
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
782
-        if (! empty($name) && $showSql === '') {
783
-            if (! empty($series) && (int) $series < 1900) {
782
+        if (!empty($name) && $showSql === '') {
783
+            if (!empty($series) && (int) $series < 1900) {
784 784
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
785
-                if (! empty($episode) && ! str_contains($episode, '/')) {
785
+                if (!empty($episode) && !str_contains($episode, '/')) {
786 786
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
787 787
                 }
788 788
                 // If season is not empty but episode is, add a wildcard to the search
789 789
                 if (empty($episode)) {
790 790
                     $name .= '*';
791 791
                 }
792
-            } elseif (! empty($airDate)) {
792
+            } elseif (!empty($airDate)) {
793 793
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
794 794
             }
795 795
         }
796
-        if (! empty($name)) {
796
+        if (!empty($name)) {
797 797
             if (config('nntmux.elasticsearch_enabled') === true) {
798 798
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
799 799
             } else {
800 800
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
801
-                if (! empty($searchResult)) {
801
+                if (!empty($searchResult)) {
802 802
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
803 803
                 }
804 804
             }
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
             NZB::NZB_ADDED,
815 815
             $this->showPasswords(),
816 816
             $showSql,
817
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
817
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
818 818
             Category::getCategorySearch($cat),
819 819
             ($maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : ''),
820 820
             ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''),
821
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
821
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
822 822
         );
823 823
         $baseSql = sprintf(
824 824
             "SELECT r.searchname, r.guid, r.postdate, r.groups_id, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.tv_episodes_id, r.haspreview, r.jpgstatus,
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
             $offset
846 846
         );
847 847
 
848
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql) {
848
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql) {
849 849
             $releases = self::fromQuery($sql);
850 850
             if ($releases->isNotEmpty()) {
851 851
                 $releases[0]->_totalrows = $this->getPagerCount(
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
      */
863 863
     public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = []): mixed
864 864
     {
865
-        if (! empty($name)) {
865
+        if (!empty($name)) {
866 866
             if (config('nntmux.elasticsearch_enabled') === true) {
867 867
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
868 868
             } else {
869 869
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
870
-                if (! empty($searchResult)) {
870
+                if (!empty($searchResult)) {
871 871
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
872 872
                 }
873 873
             }
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
             $this->showPasswords(),
885 885
             NZB::NZB_ADDED,
886 886
             ($aniDbID > -1 ? sprintf(' AND r.anidbid = %d ', $aniDbID) : ''),
887
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
888
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
887
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
888
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
889 889
             Category::getCategorySearch($cat),
890 890
             ($maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '')
891 891
         );
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
             $offset
912 912
         );
913 913
 
914
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql) {
914
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql) {
915 915
             $releases = self::fromQuery($sql);
916 916
             if ($releases->isNotEmpty()) {
917 917
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
      */
927 927
     public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = []): mixed
928 928
     {
929
-        if (! empty($name)) {
929
+        if (!empty($name)) {
930 930
             if (config('nntmux.elasticsearch_enabled') === true) {
931 931
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
932 932
             } else {
933 933
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
934
-                if (! empty($searchResult)) {
934
+                if (!empty($searchResult)) {
935 935
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
936 936
                 }
937 937
             }
@@ -948,11 +948,11 @@  discard block
 block discarded – undo
948 948
 			%s %s %s %s %s %s %s',
949 949
             NZB::NZB_ADDED,
950 950
             $this->showPasswords(),
951
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
951
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
952 952
             ($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = \'%s\' ', $imDbId) : '',
953 953
             ($tmDbId !== -1 && is_numeric($tmDbId)) ? sprintf(' AND m.tmdbid = %d ', $tmDbId) : '',
954 954
             ($traktId !== -1 && is_numeric($traktId)) ? sprintf(' AND m.traktid = %d ', $traktId) : '',
955
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
955
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
956 956
             Category::getCategorySearch($cat),
957 957
             $maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '',
958 958
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
             $offset
981 981
         );
982 982
 
983
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function () use ($sql, $baseSql) {
983
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_medium'), config('nntmux.cache_expiry_long')], function() use ($sql, $baseSql) {
984 984
             $releases = self::fromQuery($sql);
985 985
             if ($releases->isNotEmpty()) {
986 986
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
             }
1005 1005
 
1006 1006
             $results = $this->search(['searchname' => getSimilarName($name)], -1, '', '', -1, -1, 0, config('nntmux.items_per_page'), '', -1, $excludedCats, 'basic', [$parentCat]);
1007
-            if (! $results) {
1007
+            if (!$results) {
1008 1008
                 return $ret;
1009 1009
             }
1010 1010
 
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
             (int) config('nntmux.max_pager_results')
1028 1028
         );
1029 1029
 
1030
-        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_short'), config('nntmux.cache_expiry_medium')], function () use ($sql) {
1030
+        return Cache::flexible(md5($sql), [config('nntmux.cache_expiry_short'), config('nntmux.cache_expiry_medium')], function() use ($sql) {
1031 1031
             $count = self::fromQuery($sql);
1032 1032
 
1033 1033
             return $count[0]->count ?? 0;
Please login to merge, or discard this patch.