Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
daf490d3
Commit
daf490d3
authored
Nov 21, 2012
by
Dries
Browse files
Issue
#1843844
by Crell: Convert cron to new routing system.
parent
62f6333a
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/system/lib/Drupal/system/CronController.php
0 → 100644
View file @
daf490d3
<?php
/**
* @file
* Definition of Drupal\system\CronController.
*/
namespace
Drupal\system
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
/**
* Controllers for Cron handling.
*/
class
CronController
{
/**
* Run Cron once.
*
* @return Symfony\Component\HttpFoundation\Response
* A Symfony response object.
*/
public
function
run
(
$key
)
{
if
(
!
$this
->
access
(
$key
))
{
throw
new
AccessDeniedHttpException
();
}
// @todo Make this an injected object.
drupal_cron_run
();
// HTTP 204 is "No content", meaning "I did what you asked and we're done."
return
new
Response
(
''
,
204
);
}
/**
* Determines if the user has access to run cron.
*
* @todo Eliminate this method in favor of a new-style access checker once
* http://drupal.org/node/1793520 gets in.
*/
function
access
(
$key
)
{
if
(
$key
!=
state
()
->
get
(
'system.cron_key'
))
{
watchdog
(
'cron'
,
'Cron could not run because an invalid key was used.'
,
array
(),
WATCHDOG_NOTICE
);
return
FALSE
;
}
elseif
(
config
(
'system.maintenance'
)
->
get
(
'enabled'
))
{
watchdog
(
'cron'
,
'Cron could not run because the site is in maintenance mode.'
,
array
(),
WATCHDOG_NOTICE
);
return
FALSE
;
}
return
TRUE
;
}
}
core/modules/system/system.module
View file @
daf490d3
...
...
@@ -564,13 +564,6 @@ function system_element_info() {
* Implements hook_menu().
*/
function
system_menu
()
{
$items
[
'cron/%'
]
=
array
(
'title'
=>
'Run cron'
,
'page callback'
=>
'system_cron_page'
,
'access callback'
=>
'system_cron_access'
,
'access arguments'
=>
array
(
1
),
'type'
=>
MENU_CALLBACK
,
);
$items
[
'system/files'
]
=
array
(
'title'
=>
'File download'
,
'page callback'
=>
'file_download'
,
...
...
@@ -1076,41 +1069,6 @@ function system_menu() {
return
$items
;
}
/**
* Page callback; Execute cron tasks.
*
* @see system_cron_access().
*/
function
system_cron_page
()
{
drupal_page_is_cacheable
(
FALSE
);
drupal_cron_run
();
// HTTP 204 is "No content", meaning "I did what you asked and we're done."
return
new
Response
(
''
,
204
);
}
/**
* Access callback for system_cron().
*
* @param string $key
* A hash to validate the page request origin.
*
* @see system_cron_page().
*/
function
system_cron_access
(
$key
)
{
if
(
$key
!=
state
()
->
get
(
'system.cron_key'
))
{
watchdog
(
'cron'
,
'Cron could not run because an invalid key was used.'
,
array
(),
WATCHDOG_NOTICE
);
return
FALSE
;
}
elseif
(
config
(
'system.maintenance'
)
->
get
(
'enabled'
))
{
watchdog
(
'cron'
,
'Cron could not run because the site is in maintenance mode.'
,
array
(),
WATCHDOG_NOTICE
);
return
FALSE
;
}
return
TRUE
;
}
/**
* Theme callback for the default batch page.
*/
...
...
core/modules/system/system.routing.yml
0 → 100644
View file @
daf490d3
cron
:
pattern
:
'
/cron/{key}'
defaults
:
_controller
:
'
\Drupal\system\CronController::run'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment