Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

engine/lib/cron.php (1 issue)

usage of deprecated functions.

Deprecated Code Minor
1
<?php
2
/**
3
 * Elgg cron library.
4
 *
5
 * @package    Elgg.Core
6
 * @subpackage Cron
7
 */
8
9
/**
10
 * Cron initialization
11
 *
12
 * @return void
13
 * @access private
14
 */
15
function _elgg_cron_init() {
16 33
	elgg_register_page_handler('cron', '_elgg_cron_page_handler');
0 ignored issues
show
Deprecated Code introduced by Cash Costello
The function elgg_register_page_handler() has been deprecated: 3.0 ( Ignorable by Annotation )

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

16
	/** @scrutinizer ignore-deprecated */ elgg_register_page_handler('cron', '_elgg_cron_page_handler');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
17
18 33
	elgg_set_config('elgg_cron_periods', array_keys(\Elgg\Cron::$intervals));
19
20 33
	elgg_register_menu_item('page', [
21 33
		'name' => 'cron',
22 33
		'text' => elgg_echo('admin:cron'),
23 33
		'href' => 'admin/cron',
24 33
		'section' => 'information',
25 33
		'context' => 'admin',
26
	]);
27 33
}
28
29
/**
30
 * /cron handler
31
 *
32
 * @param array $segments URL segments
33
 *
34
 * @return bool
35
 * @access private
36
 */
37
function _elgg_cron_page_handler($segments) {
38
39 2
	if (_elgg_config()->security_protect_cron) {
40
		elgg_signed_request_gatekeeper();
41
	}
42
43 2
	$interval = strtolower(array_shift($segments));
44
45 2
	$intervals = null;
46 2
	if ($interval !== 'run') {
47 1
		$intervals = [$interval];
48
	}
49
50 2
	$output = '';
51
	try {
52 2
		$jobs = _elgg_services()->cron->run($intervals);
53 2
		foreach ($jobs as $job) {
54 2
			$output .= $job->getOutput() . PHP_EOL;
55
		}
56
	} catch (CronException $ex) {
57
		$output .= "Exception: {$ex->getMessage()}";
58
	}
59
60 2
	echo $output;
61 2
	return true;
62
}
63
64
/**
65
 * @see \Elgg\Application::loadCore Do not do work here. Just register for events.
66
 */
67
return function (\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
68 18
	$events->registerHandler('init', 'system', '_elgg_cron_init');
69
};
70