Completed
Push — dev ( 2fdbac...874ad8 )
by Darko
10:14
created

Forking::backFillChildWorker()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Blacklight\libraries;
4
5
use Blacklight\Nfo;
6
use Blacklight\NZB;
7
use Blacklight\NNTP;
8
use App\Models\Settings;
9
use Blacklight\ColorCLI;
10
use Illuminate\Support\Carbon;
11
use Illuminate\Support\Facades\DB;
12
use Illuminate\Support\Facades\Log;
13
use Blacklight\processing\PostProcess;
14
15
/**
16
 * Class Forking.
17
 *
18
 * This forks various newznab scripts.
19
 *
20
 * For example, you get all the ID's of the active groups in the groups table, you then iterate over them and spawn
21
 * processes of misc/update_binaries.php passing the group ID's.
22
 */
23
class Forking extends \fork_daemon
24
{
25
    private const OUTPUT_NONE = 0; // Don't display child output.
26
    private const OUTPUT_REALTIME = 1; // Display child output in real time.
27
    private const OUTPUT_SERIALLY = 2; // Display child output when child is done.
28
29
    /**
30
     * @var \Blacklight\ColorCLI
31
     */
32
    public $colorCli;
33
34
    /**
35
     * @var int The type of output
36
     */
37
    protected $outputType;
38
39
    /**
40
     * Path to do not run folder.
41
     *
42
     * @var string
43
     */
44
    private $dnr_path;
45
46
    /**
47
     * Work to work on.
48
     *
49
     * @var array
50
     */
51
    private $work = [];
52
53
    /**
54
     * How much work do we have to do?
55
     *
56
     * @var int
57
     */
58
    public $_workCount = 0;
59
60
    /**
61
     * The type of work we want to work on.
62
     *
63
     * @var string
64
     */
65
    private $workType = '';
66
67
    /**
68
     * List of passed in options for the current work type.
69
     *
70
     * @var array
71
     */
72
    private $workTypeOptions = [];
73
74
    /**
75
     * Max amount of child processes to do work at a time.
76
     *
77
     * @var int
78
     */
79
    private $maxProcesses = 1;
80
81
    /**
82
     * Group used for safe backfill.
83
     *
84
     * @var string
85
     */
86
    private $safeBackfillGroup = '';
87
88
    /**
89
     * @var int
90
     */
91
    protected $maxSize;
92
93
    /**
94
     * @var int
95
     */
96
    protected $minSize;
97
98
    /**
99
     * @var int
100
     */
101
    protected $maxRetries;
102
103
    /**
104
     * @var int
105
     */
106
    protected $dummy;
107
108
    /**
109
     * @var bool
110
     */
111
    private $processAdditional = false; // Should we process additional?
112
    private $processNFO = false; // Should we process NFOs?
113
    private $processMovies = false; // Should we process Movies?
114
    private $processTV = false; // Should we process TV?
115
116
    /**
117
     * Setup required parent / self vars.
118
     *
119
     * @throws \Exception
120
     */
121
    public function __construct()
122
    {
123
        parent::__construct();
124
125
        $this->colorCli = new ColorCLI();
126
127
        $this->register_logging(
128
            [0 => $this, 1 => 'logger'],
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'logger') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_logging(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

128
            /** @scrutinizer ignore-type */ [0 => $this, 1 => 'logger'],
Loading history...
129
            (\defined('NN_MULTIPROCESSING_LOG_TYPE') ? NN_MULTIPROCESSING_LOG_TYPE : \fork_daemon::LOG_LEVEL_INFO)
0 ignored issues
show
Bug introduced by
The constant Blacklight\libraries\NN_MULTIPROCESSING_LOG_TYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
130
        );
131
132
        if (\defined('NN_MULTIPROCESSING_MAX_CHILD_WORK')) {
133
            $this->max_work_per_child_set(NN_MULTIPROCESSING_MAX_CHILD_WORK);
0 ignored issues
show
Bug introduced by
The constant Blacklight\libraries\NN_...OCESSING_MAX_CHILD_WORK was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
134
        } else {
135
            $this->max_work_per_child_set(1);
136
        }
137
138
        if (\defined('NN_MULTIPROCESSING_MAX_CHILD_TIME')) {
139
            $this->child_max_run_time_set(NN_MULTIPROCESSING_MAX_CHILD_TIME);
0 ignored issues
show
Bug introduced by
The constant Blacklight\libraries\NN_...OCESSING_MAX_CHILD_TIME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
140
        } else {
141
            $this->child_max_run_time_set(1800);
142
        }
143
144
        // Use a single exit method for all children, makes things easier.
145
        $this->register_parent_child_exit([0 => $this, 1 => 'childExit']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'childExit') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_parent_child_exit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

145
        $this->register_parent_child_exit(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'childExit']);
Loading history...
146
147
        if (\defined('NN_MULTIPROCESSING_CHILD_OUTPUT_TYPE')) {
148
            switch (NN_MULTIPROCESSING_CHILD_OUTPUT_TYPE) {
0 ignored issues
show
Bug introduced by
The constant Blacklight\libraries\NN_...SSING_CHILD_OUTPUT_TYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
149
                case 0:
150
                    $this->outputType = self::OUTPUT_NONE;
151
                    break;
152
                case 1:
153
                    $this->outputType = self::OUTPUT_REALTIME;
154
                    break;
155
                case 2:
156
                    $this->outputType = self::OUTPUT_SERIALLY;
157
                    break;
158
                default:
159
                    $this->outputType = self::OUTPUT_REALTIME;
160
            }
161
        } else {
162
            $this->outputType = self::OUTPUT_REALTIME;
163
        }
164
165
        $this->dnr_path = PHP_BINARY.' '.NN_MULTIPROCESSING.'.do_not_run/switch.php "php  ';
166
167
        $this->maxSize = (int) Settings::settingValue('..maxsizetoprocessnfo');
168
        $this->minSize = (int) Settings::settingValue('..minsizetoprocessnfo');
169
        $this->maxRetries = (int) Settings::settingValue('..maxnforetries') >= 0 ? -((int) Settings::settingValue('..maxnforetries') + 1) : Nfo::NFO_UNPROC;
170
        $this->maxRetries = $this->maxRetries < -8 ? -8 : $this->maxRetries;
171
    }
172
173
    /**
174
     * Setup the class to work on a type of work, then process the work.
175
     * Valid work types:.
176
     *
177
     * @param string $type The type of multiProcessing to do : backfill, binaries, releases, postprocess
178
     * @param array $options Array containing arguments for the type of work.
179
     *
180
     * @throws \Exception
181
     */
182
    public function processWorkType($type, array $options = [])
183
    {
184
        // Set/reset some variables.
185
        $startTime = now()->timestamp;
186
        $this->workType = $type;
187
        $this->workTypeOptions = $options;
188
        $this->processAdditional = $this->processNFO = $this->processTV = $this->processMovies = $this->ppRenamedOnly = false;
189
        $this->work = [];
190
191
        // Process extra work that should not be forked and done before forking.
192
        $this->processStartWork();
193
194
        // Get work to fork.
195
        $this->getWork();
196
197
        // Process the work we got.
198
        $this->processWork();
199
200
        // Process extra work that should not be forked and done after.
201
        $this->processEndWork();
202
203
        if (config('nntmux.echocli')) {
204
            $this->colorCli->header(
205
                'Multi-processing for '.$this->workType.' finished in '.(now()->timestamp - $startTime).
206
                    ' seconds at '.now()->toRfc2822String().'.'.PHP_EOL
207
                );
208
        }
209
    }
210
211
    /**
212
     * Only post process renamed movie / tv releases?
213
     *
214
     * @var bool
215
     */
216
    private $ppRenamedOnly;
217
218
    /**
219
     * Get work for our workers to work on, set the max child processes here.
220
     *
221
     * @throws \Exception
222
     */
223
    private function getWork()
224
    {
225
        $maxProcesses = 0;
226
227
        switch ($this->workType) {
228
229
            case 'backfill':
230
                $maxProcesses = $this->backfillMainMethod();
231
                break;
232
233
            case 'binaries':
234
                $maxProcesses = $this->binariesMainMethod();
235
                break;
236
237
            case 'fixRelNames_standard':
238
            case 'fixRelNames_predbft':
239
                $maxProcesses = $this->fixRelNamesMainMethod();
240
                break;
241
242
            case 'releases':
243
                $maxProcesses = $this->releasesMainMethod();
244
                break;
245
246
            case 'postProcess_ama':
247
                $this->processSingle();
248
                break;
249
250
            case 'postProcess_add':
251
                $maxProcesses = $this->postProcessAddMainMethod();
252
                break;
253
254
            case 'postProcess_mov':
255
                $this->ppRenamedOnly = (isset($this->workTypeOptions[0]) && $this->workTypeOptions[0] === true);
256
                $maxProcesses = $this->postProcessMovMainMethod();
257
                break;
258
259
            case 'postProcess_nfo':
260
                $maxProcesses = $this->postProcessNfoMainMethod();
261
                break;
262
263
            case 'postProcess_sha':
264
                $this->processSharing();
265
                break;
266
267
            case 'postProcess_tv':
268
                $this->ppRenamedOnly = (isset($this->workTypeOptions[0]) && $this->workTypeOptions[0] === true);
269
                $maxProcesses = $this->postProcessTvMainMethod();
270
                break;
271
272
            case 'safe_backfill':
273
                $maxProcesses = $this->safeBackfillMainMethod();
274
                break;
275
276
            case 'safe_binaries':
277
                $maxProcesses = $this->safeBinariesMainMethod();
278
                break;
279
280
            case 'update_per_group':
281
                $maxProcesses = $this->updatePerGroupMainMethod();
282
                break;
283
        }
284
285
        $this->setMaxProcesses($maxProcesses);
286
    }
287
288
    /**
289
     * Process work if we have any.
290
     */
291
    private function processWork()
292
    {
293
        $this->_workCount = \count($this->work);
294
        if ($this->_workCount > 0) {
295
            if (config('nntmux.echocli') === true) {
296
                $this->colorCli->header(
297
                    'Multi-processing started at '.now()->toRfc2822String().' for '.$this->workType.' with '.$this->_workCount.
298
                        ' job(s) to do using a max of '.$this->maxProcesses.' child process(es).'
299
                    );
300
            }
301
302
            $this->addwork($this->work);
303
            $this->process_work(true);
304
        } elseif (config('nntmux.echocli') === true) {
305
            $this->colorCli->header('No work to do!');
306
        }
307
    }
308
309
    /**
310
     * Process any work that does not need to be forked, but needs to run at the end.
311
     */
312
    private function processStartWork()
313
    {
314
        switch ($this->workType) {
315
            case 'safe_backfill':
316
            case 'safe_binaries':
317
                $this->_executeCommand(
318
                    PHP_BINARY.' '.NN_UPDATE.'tmux/bin/update_groups.php'
319
                );
320
                break;
321
        }
322
    }
323
324
    /**
325
     * Process any work that does not need to be forked, but needs to run at the end.
326
     */
327
    private function processEndWork()
328
    {
329
        switch ($this->workType) {
330
            case 'releases':
331
                $this->_executeCommand(
332
                    $this->dnr_path.'releases  '.\count($this->work).'_"'
333
                );
334
                break;
335
            case 'update_per_group':
336
                $this->_executeCommand(
337
                    $this->dnr_path.'releases  '.\count($this->work).'_"'
338
                );
339
                break;
340
        }
341
    }
342
343
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
344
    //////////////////////////////////////// All backFill code here ////////////////////////////////////////////////////
345
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
346
347
    /**
348
     * @return int
349
     * @throws \Exception
350
     */
351
    private function backfillMainMethod(): int
352
    {
353
        $this->register_child_run([0 => $this, 1 => 'backFillChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'backFillChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

353
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'backFillChildWorker']);
Loading history...
354
        // The option for backFill is for doing up to x articles. Else it's done by date.
355
        $this->work = DB::select(
356
            sprintf(
357
                'SELECT name %s FROM usenet_groups WHERE backfill = 1',
358
                ($this->workTypeOptions[0] === false ? '' : (', '.$this->workTypeOptions[0].' AS max'))
359
            )
360
        );
361
362
        return (int) Settings::settingValue('..backfillthreads');
363
    }
364
365
    /**
366
     * @param $groups
367
     */
368
    public function backFillChildWorker($groups)
369
    {
370
        foreach ($groups as $group) {
371
            $this->_executeCommand(
372
                PHP_BINARY.' '.NN_UPDATE.'backfill.php '.
373
                $group->name.(isset($group->max) ? (' '.$group->max) : '')
374
            );
375
        }
376
    }
377
378
    /**
379
     * @return int
380
     */
381
    private function safeBackfillMainMethod(): int
382
    {
383
        $this->register_child_run([0 => $this, 1 => 'safeBackfillChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'safeBackfillChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

383
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'safeBackfillChildWorker']);
Loading history...
384
385
        $backfill_qty = (int) Settings::settingValue('site.tmux.backfill_qty');
386
        $backfill_order = (int) Settings::settingValue('site.tmux.backfill_order');
387
        $backfill_days = (int) Settings::settingValue('site.tmux.backfill_days');
388
        $maxmssgs = (int) Settings::settingValue('..maxmssgs');
389
        $threads = (int) Settings::settingValue('..backfillthreads');
390
391
        $orderby = 'ORDER BY a.last_record ASC';
392
        switch ($backfill_order) {
393
            case 1:
394
                $orderby = 'ORDER BY first_record_postdate DESC';
395
                break;
396
397
            case 2:
398
                $orderby = 'ORDER BY first_record_postdate ASC';
399
                break;
400
401
            case 3:
402
                $orderby = 'ORDER BY name ASC';
403
                break;
404
405
            case 4:
406
                $orderby = 'ORDER BY name DESC';
407
                break;
408
409
            case 5:
410
                $orderby = 'ORDER BY a.last_record DESC';
411
                break;
412
        }
413
414
        $backfilldays = '';
415
        if ($backfill_days === 1) {
416
            $days = 'backfill_target';
417
            $backfilldays = now()->subDays(Carbon::createFromDate($days));
0 ignored issues
show
Bug introduced by
$days of type string is incompatible with the type integer|null expected by parameter $year of Carbon\Carbon::createFromDate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

417
            $backfilldays = now()->subDays(Carbon::createFromDate(/** @scrutinizer ignore-type */ $days));
Loading history...
Bug introduced by
Illuminate\Support\Carbon::createFromDate($days) of type Illuminate\Support\Carbon is incompatible with the type integer expected by parameter $value of Carbon\Carbon::subDays(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

417
            $backfilldays = now()->subDays(/** @scrutinizer ignore-type */ Carbon::createFromDate($days));
Loading history...
418
        } elseif ($backfill_days === 2) {
419
            $backfilldays = now()->subDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate'))->diffInDays())->format('Y-m-d');
420
        }
421
422
        $data = DB::select(
423
            sprintf(
424
                'SELECT g.name,
425
				g.first_record AS our_first,
426
				MAX(a.first_record) AS their_first,
427
				MAX(a.last_record) AS their_last
428
				FROM usenet_groups g
429
				INNER JOIN short_groups a ON g.name = a.name
430
				WHERE g.first_record IS NOT NULL
431
				AND g.first_record_postdate IS NOT NULL
432
				AND g.backfill = 1
433
				AND %s < g.first_record_postdate
434
				GROUP BY a.name, a.last_record, g.name, g.first_record
435
				%s LIMIT 1',
436
                $backfilldays,
437
                $orderby
438
            )
439
        );
440
441
        $count = 0;
442
        if ($data[0]->name) {
443
            $this->safeBackfillGroup = $data[0]->name;
444
445
            $count = ($data[0]->our_first - $data[0]->their_first);
446
        }
447
448
        if ($count > 0) {
449
            if ($count > ($backfill_qty * $threads)) {
450
                $geteach = ceil(($backfill_qty * $threads) / $maxmssgs);
451
            } else {
452
                $geteach = $count / $maxmssgs;
453
            }
454
455
            $queue = [];
456
            for ($i = 0; $i <= $geteach - 1; $i++) {
457
                $queue[$i] = sprintf('get_range  backfill  %s  %s  %s  %s', $data[0]->name, $data[0]->our_first - $i * $maxmssgs - $maxmssgs, $data[0]->our_first - $i * $maxmssgs - 1, $i + 1);
458
            }
459
            $this->work = $queue;
460
        }
461
462
        return $threads;
463
    }
464
465
    /**
466
     * @param        $ranges
467
     * @param string $identifier
468
     */
469
    public function safeBackfillChildWorker($ranges, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

469
    public function safeBackfillChildWorker($ranges, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
470
    {
471
        foreach ($ranges as $range) {
472
            $this->_executeCommand(
473
                $this->dnr_path.$range.'"'
474
            );
475
        }
476
    }
477
478
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
479
    //////////////////////////////////////// All binaries code here ////////////////////////////////////////////////////
480
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
481
482
    /**
483
     * @return int
484
     */
485
    private function binariesMainMethod()
486
    {
487
        $this->register_child_run([0 => $this, 1 => 'binariesChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'binariesChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

487
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'binariesChildWorker']);
Loading history...
488
        $this->work = DB::select(
489
            sprintf(
490
                'SELECT name, %d AS max FROM usenet_groups WHERE active = 1',
491
                $this->workTypeOptions[0]
492
            )
493
        );
494
495
        return (int) Settings::settingValue('..binarythreads');
496
    }
497
498
    /**
499
     * @param        $groups
500
     * @param string $identifier
501
     */
502
    public function binariesChildWorker($groups, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

502
    public function binariesChildWorker($groups, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
503
    {
504
        foreach ($groups as $group) {
505
            $this->_executeCommand(
506
                PHP_BINARY.' '.NN_UPDATE.'update_binaries.php '.$group->name.' '.$group->max
507
            );
508
        }
509
    }
510
511
    /**
512
     * @return int
513
     * @throws \Exception
514
     */
515
    private function safeBinariesMainMethod()
516
    {
517
        $this->register_child_run([0 => $this, 1 => 'safeBinariesChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'safeBinariesChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

517
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'safeBinariesChildWorker']);
Loading history...
518
519
        $maxheaders = (int) Settings::settingValue('..max_headers_iteration') ?: 1000000;
520
        $maxmssgs = (int) Settings::settingValue('..maxmssgs');
521
        $threads = (int) Settings::settingValue('..binarythreads');
522
523
        $groups = DB::select(
524
            '
525
			SELECT g.name AS groupname, g.last_record AS our_last,
526
				a.last_record AS their_last
527
			FROM usenet_groups g
528
			INNER JOIN short_groups a ON g.active = 1 AND g.name = a.name
529
			ORDER BY a.last_record DESC'
530
        );
531
532
        if (! empty($groups)) {
533
            $i = 1;
534
            $queue = [];
535
            foreach ($groups as $group) {
536
                if ((int) $group->our_last === 0) {
537
                    $queue[$i] = sprintf('update_group_headers  %s', $group->groupname);
538
                    $i++;
539
                } else {
540
                    //only process if more than 20k headers available and skip the first 20k
541
                    $count = $group->their_last - $group->our_last - 20000;
542
                    //echo "count: " . $count . "maxmsgs x2: " . ($maxmssgs * 2) . PHP_EOL;
543
                    if ($count <= $maxmssgs * 2) {
544
                        $queue[$i] = sprintf('update_group_headers  %s', $group->groupname);
545
                        $i++;
546
                    } else {
547
                        $queue[$i] = sprintf('part_repair  %s', $group->groupname);
548
                        $i++;
549
                        $geteach = floor(min($count, $maxheaders) / $maxmssgs);
550
                        $remaining = min($count, $maxheaders) - $geteach * $maxmssgs;
551
                        //echo "maxmssgs: " . $maxmssgs . " geteach: " . $geteach . " remaining: " . $remaining . PHP_EOL;
552
                        for ($j = 0; $j < $geteach; $j++) {
553
                            $queue[$i] = sprintf('get_range  binaries  %s  %s  %s  %s', $group->groupname, $group->our_last + $j * $maxmssgs + 1, $group->our_last + $j * $maxmssgs + $maxmssgs, $i);
554
                            $i++;
555
                        }
556
                        //add remainder to queue
557
                        $queue[$i] = sprintf('get_range  binaries  %s  %s  %s  %s', $group->groupname, $group->our_last + ($j + 1) * $maxmssgs + 1, $group->our_last + ($j + 1) * $maxmssgs + $remaining + 1, $i);
558
                        $i++;
559
                    }
560
                }
561
            }
562
            //var_dump($queue);
563
            $this->work = $queue;
564
        }
565
566
        return $threads;
567
    }
568
569
    /**
570
     * @param        $ranges
571
     * @param string $identifier
572
     */
573
    public function safeBinariesChildWorker($ranges, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

573
    public function safeBinariesChildWorker($ranges, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
574
    {
575
        foreach ($ranges as $range) {
576
            $this->_executeCommand(
577
                $this->dnr_path.$range.'"'
578
            );
579
        }
580
    }
581
582
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
583
    //////////////////////////////////// All fix release names code here ///////////////////////////////////////////////
584
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
585
586
    /**
587
     * @return int
588
     */
589
    private function fixRelNamesMainMethod()
590
    {
591
        $this->register_child_run([0 => $this, 1 => 'fixRelNamesChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'fixRelNamesChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

591
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'fixRelNamesChildWorker']);
Loading history...
592
593
        $threads = (int) Settings::settingValue('..fixnamethreads');
594
        $maxperrun = (int) Settings::settingValue('..fixnamesperrun');
595
596
        if ($threads > 16) {
597
            $threads = 16;
598
        } elseif ($threads === 0) {
599
            $threads = 1;
600
        }
601
602
        $leftGuids = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
603
604
        // Prevent PreDB FT from always running
605
        if ($this->workTypeOptions[0] === 'predbft') {
606
            $preCount = DB::select(
607
                sprintf(
608
                    "
609
					SELECT COUNT(p.id) AS num
610
					FROM predb p
611
					WHERE LENGTH(p.title) >= 15
612
					AND p.title NOT REGEXP '[\"\<\> ]'
613
					AND p.searched = 0
614
					AND p.predate < (NOW() - INTERVAL 1 DAY)"
615
                )
616
            );
617
            if ($preCount[0]->num > 0) {
618
                $leftGuids = \array_slice($leftGuids, 0, (int) ceil($preCount[0]->num / $maxperrun));
619
            } else {
620
                $leftGuids = [];
621
            }
622
        }
623
624
        $count = 0;
625
        $queue = [];
626
        foreach ($leftGuids as $leftGuid) {
627
            $count++;
628
            if ($maxperrun > 0) {
629
                $queue[$count] = sprintf('%s %s %s %s', $this->workTypeOptions[0], $leftGuid, $maxperrun, $count);
630
            }
631
        }
632
        $this->work = $queue;
633
634
        return $threads;
635
    }
636
637
    /**
638
     * @param        $guids
639
     * @param string $identifier
640
     */
641
    public function fixRelNamesChildWorker($guids, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

641
    public function fixRelNamesChildWorker($guids, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
642
    {
643
        foreach ($guids as $guid) {
644
            $this->_executeCommand(
645
                PHP_BINARY.' '.NN_UPDATE.'tmux/bin/groupfixrelnames.php "'.$guid.'"'.' true'
646
            );
647
        }
648
    }
649
650
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
651
    //////////////////////////////////////// All releases code here ////////////////////////////////////////////////////
652
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
653
654
    /**
655
     * @return int
656
     */
657
    private function releasesMainMethod()
658
    {
659
        $this->register_child_run([0 => $this, 1 => 'releasesChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'releasesChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

659
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'releasesChildWorker']);
Loading history...
660
661
        $groups = DB::select('SELECT id FROM usenet_groups WHERE (active = 1 OR backfill = 1)');
662
663
        foreach ($groups as $group) {
664
            try {
665
                if (! empty(DB::select(sprintf('SELECT id FROM collections LIMIT 1')))) {
666
                    $this->work[] = ['id' => $group->id];
667
                }
668
            } catch (\PDOException $e) {
669
                if (config('app.debug') === true) {
670
                    Log::debug($e->getMessage());
671
                }
672
            }
673
        }
674
675
        return (int) Settings::settingValue('..releasethreads');
676
    }
677
678
    /**
679
     * @param        $groups
680
     * @param string $identifier
681
     */
682
    public function releasesChildWorker($groups, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

682
    public function releasesChildWorker($groups, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
683
    {
684
        foreach ($groups as $group) {
685
            $this->_executeCommand($this->dnr_path.'releases  '.$group['id'].'"');
686
        }
687
    }
688
689
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
690
    /////////////////////////////////////// All post process code here /////////////////////////////////////////////////
691
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
692
693
    /**
694
     * Only 1 exit method is used for post process, since they are all similar.
695
     *
696
     *
697
     * @param array $groups
698
     * @param string $identifier
699
     */
700
    public function postProcessChildWorker($groups, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

700
    public function postProcessChildWorker($groups, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
701
    {
702
        $type = '';
703
        if ($this->processAdditional) {
704
            $type = 'pp_additional  ';
705
        } elseif ($this->processNFO) {
706
            $type = 'pp_nfo  ';
707
        } elseif ($this->processMovies) {
708
            $type = 'pp_movie  ';
709
        } elseif ($this->processTV) {
710
            $type = 'pp_tv  ';
711
        }
712
        foreach ($groups as $group) {
713
            if ($type !== '') {
714
                $this->_executeCommand(
715
                    $this->dnr_path.$type.$group->id.(isset($group->renamed) ? ('  '.$group->renamed) : '').'"'
716
                );
717
            }
718
        }
719
    }
720
721
    private $ppAddMinSize;
722
    private $ppAddMaxSize;
723
724
    /**
725
     * @return int
726
     * @throws \Exception
727
     */
728
    private function postProcessAddMainMethod()
729
    {
730
        $this->ppAddMinSize =
731
            Settings::settingValue('..minsizetopostprocess') !== '' ? (int) Settings::settingValue('..minsizetopostprocess') : 1;
0 ignored issues
show
introduced by
The condition App\Models\Settings::set...etopostprocess') !== '' is always true.
Loading history...
732
        $this->ppAddMinSize = ($this->ppAddMinSize > 0 ? ('AND r.size > '.($this->ppAddMinSize * 1048576)) : '');
733
        $this->ppAddMaxSize =
734
            (Settings::settingValue('..maxsizetopostprocess') !== '') ? (int) Settings::settingValue('..maxsizetopostprocess') : 100;
0 ignored issues
show
introduced by
The condition App\Models\Settings::set...etopostprocess') !== '' is always true.
Loading history...
735
        $this->ppAddMaxSize = ($this->ppAddMaxSize > 0 ? ('AND r.size < '.($this->ppAddMaxSize * 1073741824)) : '');
736
737
        $checkProcessAdditional = DB::select(
738
            sprintf(
739
                '
740
					SELECT leftguid AS id
741
					FROM releases r
742
					LEFT JOIN categories c ON c.id = r.categories_id
743
					WHERE r.nzbstatus = %d
744
					AND r.passwordstatus BETWEEN -6 AND -1
745
					AND r.haspreview = -1
746
					AND c.disablepreview = 0
747
					%s %s
748
					GROUP BY leftguid
749
					LIMIT 16',
750
                NZB::NZB_ADDED,
751
                $this->ppAddMaxSize,
752
                $this->ppAddMinSize
753
            )
754
        );
755
756
        $maxProcesses = 1;
757
        if (\count($checkProcessAdditional) > 0) {
758
            $this->processAdditional = true;
759
            $this->register_child_run([0 => $this, 1 => 'postProcessChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'postProcessChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

759
            $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'postProcessChildWorker']);
Loading history...
760
            $this->work = $checkProcessAdditional;
761
            $maxProcesses = (int) Settings::settingValue('..postthreads');
762
        }
763
764
        return $maxProcesses;
765
    }
766
767
    private $nfoQueryString = '';
768
769
    /**
770
     * Check if we should process NFO's.
771
     *
772
     * @return bool
773
     * @throws \Exception
774
     */
775
    private function checkProcessNfo(): bool
776
    {
777
        if ((int) Settings::settingValue('..lookupnfo') === 1) {
778
            $this->nfoQueryString = Nfo::NfoQueryString();
779
780
            return DB::select(sprintf('SELECT r.id FROM releases r WHERE 1=1 %s LIMIT 1', $this->nfoQueryString)) > 0;
781
        }
782
783
        return false;
784
    }
785
786
    /**
787
     * @return int
788
     * @throws \Exception
789
     */
790
    private function postProcessNfoMainMethod(): int
791
    {
792
        $maxProcesses = 1;
793
        if ($this->checkProcessNfo()) {
794
            $this->processNFO = true;
795
            $this->register_child_run([0 => $this, 1 => 'postProcessChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'postProcessChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

795
            $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'postProcessChildWorker']);
Loading history...
796
            $this->work = DB::select(
797
                sprintf(
798
                    '
799
					SELECT leftguid AS id
800
					FROM releases r
801
					WHERE 1=1 %s
802
					GROUP BY leftguid
803
					LIMIT 16',
804
                    $this->nfoQueryString
805
                )
806
            );
807
            $maxProcesses = (int) Settings::settingValue('..nfothreads');
808
        }
809
810
        return $maxProcesses;
811
    }
812
813
    /**
814
     * @return bool
815
     * @throws \Exception
816
     */
817
    private function checkProcessMovies(): bool
818
    {
819
        if (Settings::settingValue('..lookupimdb') > 0) {
820
            return DB::select(sprintf('
821
						SELECT id
822
						FROM releases
823
						WHERE categories_id BETWEEN 5000 AND 5999
824
						AND nzbstatus = %d
825
						AND imdbid IS NULL
826
						%s %s
827
						LIMIT 1', NZB::NZB_ADDED, ((int) Settings::settingValue('..lookupimdb') === 2 ? 'AND isrenamed = 1' : ''), ($this->ppRenamedOnly ? 'AND isrenamed = 1' : ''))) > 0;
828
        }
829
830
        return false;
831
    }
832
833
    /**
834
     * @return int
835
     * @throws \Exception
836
     */
837
    private function postProcessMovMainMethod(): int
838
    {
839
        $maxProcesses = 1;
840
        if ($this->checkProcessMovies()) {
841
            $this->processMovies = true;
842
            $this->register_child_run([0 => $this, 1 => 'postProcessChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'postProcessChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

842
            $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'postProcessChildWorker']);
Loading history...
843
            $this->work = DB::select(
844
                sprintf(
845
                    '
846
					SELECT leftguid AS id, %d AS renamed
847
					FROM releases
848
					WHERE categories_id BETWEEN 5000 AND 5999
849
					AND nzbstatus = %d
850
					AND imdbid IS NULL
851
					%s %s
852
					GROUP BY leftguid
853
					LIMIT 16',
854
                    ($this->ppRenamedOnly ? 2 : 1),
855
                    NZB::NZB_ADDED,
856
                    ((int) Settings::settingValue('..lookupimdb') === 2 ? 'AND isrenamed = 1' : ''),
857
                    ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '')
858
                )
859
            );
860
            $maxProcesses = (int) Settings::settingValue('..postthreadsnon');
861
        }
862
863
        return $maxProcesses;
864
    }
865
866
    /**
867
     * Check if we should process TV's.
868
     * @return bool
869
     * @throws \Exception
870
     */
871
    private function checkProcessTV()
872
    {
873
        if ((int) Settings::settingValue('..lookuptvrage') > 0) {
874
            return DB::select(sprintf('
875
						SELECT id
876
						FROM releases
877
						WHERE categories_id BETWEEN 5000 AND 5999
878
						AND nzbstatus = %d
879
						AND size > 1048576
880
						AND tv_episodes_id BETWEEN -2 AND 0
881
						%s %s
882
						', NZB::NZB_ADDED, (int) Settings::settingValue('..lookuptvrage') === 2 ? 'AND isrenamed = 1' : '', $this->ppRenamedOnly ? 'AND isrenamed = 1' : '')) > 0;
883
        }
884
885
        return false;
886
    }
887
888
    /**
889
     * @return int
890
     * @throws \Exception
891
     */
892
    private function postProcessTvMainMethod()
893
    {
894
        $maxProcesses = 1;
895
        if ($this->checkProcessTV()) {
896
            $this->processTV = true;
897
            $this->register_child_run([0 => $this, 1 => 'postProcessChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => 'postProcessChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

897
            $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'postProcessChildWorker']);
Loading history...
898
            $this->work = DB::select(
899
                sprintf(
900
                    '
901
					SELECT leftguid AS id, %d AS renamed
902
					FROM releases
903
					WHERE categories_id BETWEEN 3000 AND 3999
904
					AND nzbstatus = %d
905
					AND tv_episodes_id BETWEEN -2 AND 0
906
					AND size > 1048576
907
					%s %s
908
					GROUP BY leftguid
909
					LIMIT 16',
910
                    ($this->ppRenamedOnly ? 2 : 1),
911
                    NZB::NZB_ADDED,
912
                    (int) Settings::settingValue('..lookuptvrage') === 2 ? 'AND isrenamed = 1' : '',
913
                    ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '')
914
                )
915
            );
916
            $maxProcesses = (int) Settings::settingValue('..postthreadsnon');
917
        }
918
919
        return $maxProcesses;
920
    }
921
922
    /**
923
     * Process sharing.
924
     * @return bool
925
     * @throws \Exception
926
     */
927
    private function processSharing()
928
    {
929
        $sharing = DB::select('SELECT enabled FROM sharing');
930
        if ($sharing > 0 && (int) $sharing[0]->enabled === 1) {
931
            $nntp = new NNTP();
932
            if ((int) (Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) === true) {
0 ignored issues
show
introduced by
The condition App\Models\Settings::set....alternate_nntp') === 1 is always false.
Loading history...
introduced by
The condition (int)App\Models\Settings...p->doConnect() === true is always false.
Loading history...
933
                (new PostProcess(['ColorCLI' => $this->colorCli]))->processSharing($nntp);
934
            }
935
936
            return true;
937
        }
938
939
        return false;
940
    }
941
942
    /**
943
     * Process all that require a single thread.
944
     *
945
     * @throws \Exception
946
     */
947
    private function processSingle()
948
    {
949
        $postProcess = new PostProcess(['ColorCLI' => $this->colorCli]);
950
        //$postProcess->processAnime();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
951
        $postProcess->processBooks();
952
        $postProcess->processConsoles();
953
        $postProcess->processGames();
954
        $postProcess->processMusic();
955
        $postProcess->processXXX();
956
    }
957
958
    /**
959
     * @param        $groups
960
     * @param string $identifier
961
     */
962
    public function requestIDChildWorker($groups, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

962
    public function requestIDChildWorker($groups, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
963
    {
964
        foreach ($groups as $group) {
965
            $this->_executeCommand($this->dnr_path.'requestid  '.$group['id'].'"');
966
        }
967
    }
968
969
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
970
    ///////////////////////////////// All "update_per_Group" code goes here ////////////////////////////////////////////
971
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
972
973
    /**
974
     * @return int
975
     * @throws \Exception
976
     */
977
    private function updatePerGroupMainMethod()
978
    {
979
        $this->register_child_run([0 => $this, 1 => 'updatePerGroupChildWorker']);
0 ignored issues
show
Bug introduced by
array(0 => $this, 1 => '...tePerGroupChildWorker') of type array<integer,Blacklight...braries\Forking|string> is incompatible with the type string expected by parameter $function_name of fork_daemon::register_child_run(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

979
        $this->register_child_run(/** @scrutinizer ignore-type */ [0 => $this, 1 => 'updatePerGroupChildWorker']);
Loading history...
980
        $this->work = DB::select('SELECT id FROM usenet_groups WHERE (active = 1 OR backfill = 1)');
981
982
        return (int) Settings::settingValue('..releasethreads');
983
    }
984
985
    /**
986
     * @param        $groups
987
     * @param string $identifier
988
     */
989
    public function updatePerGroupChildWorker($groups, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

989
    public function updatePerGroupChildWorker($groups, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
990
    {
991
        foreach ($groups as $group) {
992
            $this->_executeCommand(
993
                $this->dnr_path.'update_per_group  '.$group->id.'"'
994
            );
995
        }
996
    }
997
998
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
999
    //////////////////////////////////////////// Various methods ///////////////////////////////////////////////////////
1000
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1001
1002
    /**
1003
     * Execute a shell command, use the appropriate PHP function based on user setting.
1004
     *
1005
     * @param string $command
1006
     */
1007
    protected function _executeCommand($command)
1008
    {
1009
        switch ($this->outputType) {
1010
            case self::OUTPUT_NONE:
1011
                exec($command);
1012
                break;
1013
            case self::OUTPUT_REALTIME:
1014
                passthru($command);
1015
                break;
1016
            case self::OUTPUT_SERIALLY:
1017
                echo shell_exec($command);
1018
                break;
1019
        }
1020
    }
1021
1022
    /**
1023
     * Set the amount of max child processes.
1024
     *
1025
     * @param int $maxProcesses
1026
     */
1027
    private function setMaxProcesses($maxProcesses)
1028
    {
1029
        // Check if override setting is on.
1030
        if (\defined('NN_MULTIPROCESSING_MAX_CHILDREN_OVERRIDE') && NN_MULTIPROCESSING_MAX_CHILDREN_OVERRIDE > 0) {
0 ignored issues
show
Bug introduced by
The constant Blacklight\libraries\NN_...G_MAX_CHILDREN_OVERRIDE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1031
            $maxProcesses = NN_MULTIPROCESSING_MAX_CHILDREN_OVERRIDE;
1032
        }
1033
1034
        if (is_numeric($maxProcesses) && $maxProcesses > 0) {
1035
            switch ($this->workType) {
1036
                case 'postProcess_tv':
1037
                case 'postProcess_mov':
1038
                case 'postProcess_nfo':
1039
                case 'postProcess_add':
1040
                    if ($maxProcesses > 16) {
1041
                        $maxProcesses = 16;
1042
                    }
1043
            }
1044
            $this->maxProcesses = (int) $maxProcesses;
1045
            $this->max_children_set($this->maxProcesses);
1046
        } else {
1047
            $this->max_children_set(1);
1048
        }
1049
    }
1050
1051
    /**
1052
     * Echo a message to CLI.
1053
     *
1054
     * @param string $message
1055
     */
1056
    public function logger($message)
1057
    {
1058
        if (config('nntmux.echocli')) {
1059
            echo $message.PHP_EOL;
1060
        }
1061
    }
1062
1063
    /**
1064
     * This method is executed whenever a child is finished doing work.
1065
     *
1066
     * @param string $pid        The PID numbers.
1067
     * @param string $identifier Optional identifier to give a PID a name.
1068
     */
1069
    public function childExit($pid, $identifier = '')
0 ignored issues
show
Unused Code introduced by
The parameter $identifier is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1069
    public function childExit($pid, /** @scrutinizer ignore-unused */ $identifier = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1070
    {
1071
        if (config('nntmux.echocli')) {
1072
            $this->colorCli->header(
1073
                'Process ID #'.$pid.' has completed.'.PHP_EOL.
1074
                    'There are '.($this->forked_children_count - 1).' process(es) still active with '.
1075
                    (--$this->_workCount).' job(s) left in the queue.',
1076
                true
1077
                );
1078
        }
1079
    }
1080
}
1081