Passed
Push — master ( 5c6770...370515 )
by Darko
06:58 queued 55s
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::remember(md5($qry.$page), config('nntmux.cache_expiry_medium'), function () use ($qry, $cat, $maxAge, $excludedCats, $groupName) {
92
+        return Cache::remember(md5($qry.$page), config('nntmux.cache_expiry_medium'), 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::remember(md5($sql), config('nntmux.cache_expiry_long'), function () use ($sql) {
279
+        return Cache::remember(md5($sql), 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::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
513
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), 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::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql, $searchName, $searchResult) {
578
-            if ($searchName !== -1 && ! empty($searchResult)) {
577
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), 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();
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
             $show = self::fromQuery($showQry);
627 627
 
628 628
             if ($show->isNotEmpty()) {
629
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
629
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
630 630
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
631
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
631
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
632 632
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
633
-                } elseif (! empty($series) && empty($episode)) {
633
+                } elseif (!empty($series) && empty($episode)) {
634 634
                     // If $series is set but episode is not, return Season Packs and Episodes
635 635
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
636 636
                 }
@@ -644,26 +644,26 @@  discard block
 block discarded – undo
644 644
         }
645 645
 
646 646
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
647
-        if (! empty($name) && $showSql === '') {
648
-            if (! empty($series) && (int) $series < 1900) {
647
+        if (!empty($name) && $showSql === '') {
648
+            if (!empty($series) && (int) $series < 1900) {
649 649
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
650
-                if (! empty($episode) && ! str_contains($episode, '/')) {
650
+                if (!empty($episode) && !str_contains($episode, '/')) {
651 651
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
652 652
                 }
653 653
                 // If season is not empty but episode is, add a wildcard to the search
654 654
                 if (empty($episode)) {
655 655
                     $name .= '*';
656 656
                 }
657
-            } elseif (! empty($airDate)) {
657
+            } elseif (!empty($airDate)) {
658 658
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
659 659
             }
660 660
         }
661
-        if (! empty($name)) {
661
+        if (!empty($name)) {
662 662
             if (config('nntmux.elasticsearch_enabled') === true) {
663 663
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
664 664
             } else {
665 665
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
666
-                if (! empty($searchResult)) {
666
+                if (!empty($searchResult)) {
667 667
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
668 668
                 }
669 669
             }
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
             NZB::NZB_ADDED,
680 680
             $this->showPasswords(),
681 681
             $showSql,
682
-            (! empty($name) && ! empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
682
+            (!empty($name) && !empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
683 683
             Category::getCategorySearch($cat),
684 684
             $maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : '',
685 685
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '',
686
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
686
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
687 687
         );
688 688
         $baseSql = sprintf(
689 689
             "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,
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
             $offset
717 717
         );
718 718
 
719
-        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql, $name, $searchResult) {
720
-            $releases = ((! empty($name) && ! empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
719
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql, $name, $searchResult) {
720
+            $releases = ((!empty($name) && !empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
721 721
             if (count($releases) !== 0 && $releases->isNotEmpty()) {
722 722
                 $releases[0]->_totalrows = $this->getPagerCount(
723 723
                     preg_replace('#LEFT(\s+OUTER)?\s+JOIN\s+(?!tv_episodes)\s+.*ON.*=.*\n#i', ' ', $baseSql)
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
 
762 762
             $show = self::fromQuery($showQry);
763 763
             if ($show->isNotEmpty()) {
764
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
764
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
765 765
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
766
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
766
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
767 767
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
768
-                } elseif (! empty($series) && empty($episode)) {
768
+                } elseif (!empty($series) && empty($episode)) {
769 769
                     // If $series is set but episode is not, return Season Packs and Episodes
770 770
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
771 771
                 }
@@ -778,26 +778,26 @@  discard block
 block discarded – undo
778 778
             }
779 779
         }
780 780
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
781
-        if (! empty($name) && $showSql === '') {
782
-            if (! empty($series) && (int) $series < 1900) {
781
+        if (!empty($name) && $showSql === '') {
782
+            if (!empty($series) && (int) $series < 1900) {
783 783
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
784
-                if (! empty($episode) && ! str_contains($episode, '/')) {
784
+                if (!empty($episode) && !str_contains($episode, '/')) {
785 785
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
786 786
                 }
787 787
                 // If season is not empty but episode is, add a wildcard to the search
788 788
                 if (empty($episode)) {
789 789
                     $name .= '*';
790 790
                 }
791
-            } elseif (! empty($airDate)) {
791
+            } elseif (!empty($airDate)) {
792 792
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
793 793
             }
794 794
         }
795
-        if (! empty($name)) {
795
+        if (!empty($name)) {
796 796
             if (config('nntmux.elasticsearch_enabled') === true) {
797 797
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
798 798
             } else {
799 799
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
800
-                if (! empty($searchResult)) {
800
+                if (!empty($searchResult)) {
801 801
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
802 802
                 }
803 803
             }
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
             NZB::NZB_ADDED,
814 814
             $this->showPasswords(),
815 815
             $showSql,
816
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
816
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
817 817
             Category::getCategorySearch($cat),
818 818
             ($maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : ''),
819 819
             ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''),
820
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
820
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
821 821
         );
822 822
         $baseSql = sprintf(
823 823
             "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,
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
             $offset
845 845
         );
846 846
 
847
-        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
847
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
848 848
             $releases = self::fromQuery($sql);
849 849
             if ($releases->isNotEmpty()) {
850 850
                 $releases[0]->_totalrows = $this->getPagerCount(
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
      */
862 862
     public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = []): mixed
863 863
     {
864
-        if (! empty($name)) {
864
+        if (!empty($name)) {
865 865
             if (config('nntmux.elasticsearch_enabled') === true) {
866 866
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
867 867
             } else {
868 868
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
869
-                if (! empty($searchResult)) {
869
+                if (!empty($searchResult)) {
870 870
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
871 871
                 }
872 872
             }
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
             $this->showPasswords(),
884 884
             NZB::NZB_ADDED,
885 885
             ($aniDbID > -1 ? sprintf(' AND r.anidbid = %d ', $aniDbID) : ''),
886
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
887
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
886
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
887
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
888 888
             Category::getCategorySearch($cat),
889 889
             ($maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '')
890 890
         );
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
             $offset
911 911
         );
912 912
 
913
-        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
913
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
914 914
             $releases = self::fromQuery($sql);
915 915
             if ($releases->isNotEmpty()) {
916 916
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -925,12 +925,12 @@  discard block
 block discarded – undo
925 925
      */
926 926
     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
927 927
     {
928
-        if (! empty($name)) {
928
+        if (!empty($name)) {
929 929
             if (config('nntmux.elasticsearch_enabled') === true) {
930 930
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
931 931
             } else {
932 932
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
933
-                if (! empty($searchResult)) {
933
+                if (!empty($searchResult)) {
934 934
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
935 935
                 }
936 936
             }
@@ -947,11 +947,11 @@  discard block
 block discarded – undo
947 947
 			%s %s %s %s %s %s %s',
948 948
             NZB::NZB_ADDED,
949 949
             $this->showPasswords(),
950
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
950
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
951 951
             ($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = \'%s\' ', $imDbId) : '',
952 952
             ($tmDbId !== -1 && is_numeric($tmDbId)) ? sprintf(' AND m.tmdbid = %d ', $tmDbId) : '',
953 953
             ($traktId !== -1 && is_numeric($traktId)) ? sprintf(' AND m.traktid = %d ', $traktId) : '',
954
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
954
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
955 955
             Category::getCategorySearch($cat),
956 956
             $maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '',
957 957
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
             $offset
980 980
         );
981 981
 
982
-        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
982
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
983 983
             $releases = self::fromQuery($sql);
984 984
             if ($releases->isNotEmpty()) {
985 985
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
             }
1004 1004
 
1005 1005
             $results = $this->search(['searchname' => getSimilarName($name)], -1, '', '', -1, -1, 0, config('nntmux.items_per_page'), '', -1, $excludedCats, 'basic', [$parentCat]);
1006
-            if (! $results) {
1006
+            if (!$results) {
1007 1007
                 return $ret;
1008 1008
             }
1009 1009
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
             preg_replace('/SELECT.+?FROM\s+releases/is', 'SELECT r.id FROM releases', $query)
1029 1029
         );
1030 1030
 
1031
-        return Cache::remember(md5($sql), config('nntmux.cache_expiry_short'), function () use ($sql) {
1031
+        return Cache::remember(md5($sql), config('nntmux.cache_expiry_short'), function() use ($sql) {
1032 1032
             $count = self::fromQuery($sql);
1033 1033
 
1034 1034
             return $count[0]->count ?? 0;
Please login to merge, or discard this patch.