Remove cron.php entirely, as it is no longer necessary.
parent
88be740cdb
commit
4899a97a21
|
@ -99,8 +99,7 @@ DirectoryIndex index.php index.html index.htm
|
||||||
|
|
||||||
# Redirect common PHP files to their new locations.
|
# Redirect common PHP files to their new locations.
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR]
|
RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR]
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
|
RewriteCond %{REQUEST_URI} ^(.*)?/(install.php)
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)?/(cron.php)
|
|
||||||
RewriteCond %{REQUEST_URI} !core
|
RewriteCond %{REQUEST_URI} !core
|
||||||
RewriteRule ^ %1/core/%2 [L,QSA,R=301]
|
RewriteRule ^ %1/core/%2 [L,QSA,R=301]
|
||||||
|
|
||||||
|
|
|
@ -273,10 +273,10 @@ INSTALLATION
|
||||||
|
|
||||||
It is also possible to run the cron tasks independent of site visits; this is
|
It is also possible to run the cron tasks independent of site visits; this is
|
||||||
recommended for most sites. To do this, you will need to set up an automated
|
recommended for most sites. To do this, you will need to set up an automated
|
||||||
process to visit the page cron.php on your site, which executes the cron
|
process to visit the page /cron on your site, which executes the cron
|
||||||
tasks.
|
tasks.
|
||||||
|
|
||||||
The URL of the cron.php page requires a "cron key" to protect against
|
The URL of the cron page requires a "cron key" to protect against
|
||||||
unauthorized access. Your site's cron key is automatically generated during
|
unauthorized access. Your site's cron key is automatically generated during
|
||||||
installation and is specific to your site. The full URL of the page, with the
|
installation and is specific to your site. The full URL of the page, with the
|
||||||
cron key, is available in the "Cron maintenance tasks" section of the Status
|
cron key, is available in the "Cron maintenance tasks" section of the Status
|
||||||
|
@ -284,11 +284,11 @@ INSTALLATION
|
||||||
|
|
||||||
As an example for how to set up this automated process, you can use the
|
As an example for how to set up this automated process, you can use the
|
||||||
crontab utility on Unix/Linux systems. The following crontab line uses the
|
crontab utility on Unix/Linux systems. The following crontab line uses the
|
||||||
wget command to visit the cron.php page, and runs each hour, on the hour:
|
wget command to visit the cron page, and runs each hour, on the hour:
|
||||||
|
|
||||||
0 * * * * wget -O - -q -t 1 http://example.com/core/cron.php?cron_key=YOURKEY
|
0 * * * * wget -O - -q -t 1 http://example.com/cron?cron_key=YOURKEY
|
||||||
|
|
||||||
Replace the text "http://example.com/core/cron.php?cron_key=YOURKEY" in the
|
Replace the text "http://example.com/cron?cron_key=YOURKEY" in the
|
||||||
example with the full URL displayed under "Cron maintenance tasks" on the
|
example with the full URL displayed under "Cron maintenance tasks" on the
|
||||||
"Status report" page.
|
"Status report" page.
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Change the directory to the Drupal root.
|
|
||||||
chdir('..');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Root directory of Drupal installation.
|
|
||||||
*/
|
|
||||||
define('DRUPAL_ROOT', getcwd());
|
|
||||||
|
|
||||||
include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
|
|
||||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
|
||||||
|
|
||||||
if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
|
|
||||||
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
|
|
||||||
drupal_access_denied();
|
|
||||||
}
|
|
||||||
elseif (variable_get('maintenance_mode', 0)) {
|
|
||||||
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
|
|
||||||
drupal_access_denied();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
drupal_cron_run();
|
|
||||||
}
|
|
|
@ -631,7 +631,7 @@ function drupal_settings_initialize() {
|
||||||
// be modified by a visitor.
|
// be modified by a visitor.
|
||||||
if ($dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/')) {
|
if ($dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/')) {
|
||||||
// Remove "core" directory if present, allowing install.php, update.php,
|
// Remove "core" directory if present, allowing install.php, update.php,
|
||||||
// cron.php and others to auto-detect a base path.
|
// and others to auto-detect a base path.
|
||||||
$core_position = strrpos($dir, '/core');
|
$core_position = strrpos($dir, '/core');
|
||||||
if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) {
|
if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) {
|
||||||
$base_path = substr($dir, 0, $core_position);
|
$base_path = substr($dir, 0, $core_position);
|
||||||
|
|
|
@ -801,11 +801,11 @@ class AggregatorCronTestCase extends AggregatorTestCase {
|
||||||
$key = variable_get('cron_key', 'drupal');
|
$key = variable_get('cron_key', 'drupal');
|
||||||
$this->createSampleNodes();
|
$this->createSampleNodes();
|
||||||
$feed = $this->createFeed();
|
$feed = $this->createFeed();
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->cronRun();
|
||||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
||||||
$this->removeFeedItems($feed);
|
$this->removeFeedItems($feed);
|
||||||
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->cronRun();
|
||||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
||||||
|
|
||||||
// Test feed locking when queued for update.
|
// Test feed locking when queued for update.
|
||||||
|
@ -816,7 +816,7 @@ class AggregatorCronTestCase extends AggregatorTestCase {
|
||||||
'queued' => REQUEST_TIME,
|
'queued' => REQUEST_TIME,
|
||||||
))
|
))
|
||||||
->execute();
|
->execute();
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->cronRun();
|
||||||
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
||||||
db_update('aggregator_feed')
|
db_update('aggregator_feed')
|
||||||
->condition('fid', $feed->fid)
|
->condition('fid', $feed->fid)
|
||||||
|
@ -824,7 +824,7 @@ class AggregatorCronTestCase extends AggregatorTestCase {
|
||||||
'queued' => 0,
|
'queued' => 0,
|
||||||
))
|
))
|
||||||
->execute();
|
->execute();
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->cronRun();
|
||||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2188,7 +2188,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
* Runs cron in the Drupal installed by Simpletest.
|
* Runs cron in the Drupal installed by Simpletest.
|
||||||
*/
|
*/
|
||||||
protected function cronRun() {
|
protected function cronRun() {
|
||||||
$this->drupalGet($GLOBALS['base_url'] . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))));
|
$this->drupalGet('cron', array('query' => array('cron_key' => variable_get('cron_key', 'drupal'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -283,7 +283,7 @@ function system_requirements($phase) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$description .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
|
$description .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
|
||||||
$description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))))));
|
$description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url('cron', array('query' => array('cron_key' => variable_get('cron_key', 'drupal'))))));
|
||||||
|
|
||||||
$requirements['cron'] = array(
|
$requirements['cron'] = array(
|
||||||
'title' => $t('Cron maintenance tasks'),
|
'title' => $t('Cron maintenance tasks'),
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* Configuration system that lets administrators modify the workings of the site.
|
* Configuration system that lets administrators modify the workings of the site.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum age of temporary files in seconds.
|
* Maximum age of temporary files in seconds.
|
||||||
*/
|
*/
|
||||||
|
@ -580,6 +582,12 @@ function system_element_info() {
|
||||||
* Implements hook_menu().
|
* Implements hook_menu().
|
||||||
*/
|
*/
|
||||||
function system_menu() {
|
function system_menu() {
|
||||||
|
$items['cron'] = array(
|
||||||
|
'title' => 'Run cron',
|
||||||
|
'page callback' => 'system_cron_callback',
|
||||||
|
'access callback' => 'system_cron_access',
|
||||||
|
'type' => MENU_CALLBACK,
|
||||||
|
);
|
||||||
$items['system/files'] = array(
|
$items['system/files'] = array(
|
||||||
'title' => 'File download',
|
'title' => 'File download',
|
||||||
'page callback' => 'file_download',
|
'page callback' => 'file_download',
|
||||||
|
@ -1128,6 +1136,36 @@ function system_menu() {
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page callback; Execute cron tasks.
|
||||||
|
*
|
||||||
|
* @see system_cron_access().
|
||||||
|
*/
|
||||||
|
function system_cron_callback() {
|
||||||
|
drupal_cron_run();
|
||||||
|
|
||||||
|
// HTTP 204 is "No content", meaning "I did what you asked and we're done."
|
||||||
|
return new Response('a', 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Access callback for system_cron().
|
||||||
|
*
|
||||||
|
* @see system_cron_callback().
|
||||||
|
*/
|
||||||
|
function system_cron_access() {
|
||||||
|
if (request()->get('cron_key') != variable_get('cron_key', 'drupal')) {
|
||||||
|
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
elseif (variable_get('maintenance_mode', 0)) {
|
||||||
|
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.
|
* Theme callback for the default batch page.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -811,18 +811,18 @@ class CronRunTestCase extends DrupalWebTestCase {
|
||||||
global $base_url;
|
global $base_url;
|
||||||
|
|
||||||
// Run cron anonymously without any cron key.
|
// Run cron anonymously without any cron key.
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE));
|
$this->drupalGet('cron');
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
|
|
||||||
// Run cron anonymously with a random cron key.
|
// Run cron anonymously with a random cron key.
|
||||||
$key = $this->randomName(16);
|
$key = $this->randomName(16);
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->drupalGet('cron', array('query' => array('cron_key' => $key)));
|
||||||
$this->assertResponse(403);
|
$this->assertResponse(403);
|
||||||
|
|
||||||
// Run cron anonymously with the valid cron key.
|
// Run cron anonymously with the valid cron key.
|
||||||
$key = variable_get('cron_key', 'drupal');
|
$key = variable_get('cron_key', 'drupal');
|
||||||
$this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
|
$this->drupalGet('cron', array('query' => array('cron_key' => $key)));
|
||||||
$this->assertResponse(200);
|
$this->assertResponse(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
curl --silent --compressed http://example.com/core/cron.php
|
curl --silent --compressed http://example.com/cron
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
/usr/bin/lynx -source http://example.com/core/cron.php > /dev/null 2>&1
|
/usr/bin/lynx -source http://example.com/cron > /dev/null 2>&1
|
||||||
|
|
|
@ -43,8 +43,8 @@ All arguments are long options.
|
||||||
If the given path and file exists it will be executed directly,
|
If the given path and file exists it will be executed directly,
|
||||||
i.e. if URI is set to http://default/bar/foo.php
|
i.e. if URI is set to http://default/bar/foo.php
|
||||||
and bar/foo.php exists, this script will be executed without
|
and bar/foo.php exists, this script will be executed without
|
||||||
bootstrapping Drupal. To execute Drupal's cron.php, specify
|
bootstrapping Drupal. To execute Drupal's update.php, specify
|
||||||
http://default/core/cron.php as the URI.
|
http://default/core/update.php as the URI.
|
||||||
|
|
||||||
|
|
||||||
To run this script without --root argument invoke it from the root directory
|
To run this script without --root argument invoke it from the root directory
|
||||||
|
|
Loading…
Reference in New Issue