Skip to content
Snippets Groups Projects
Verified Commit b2805561 authored by Drew Webber's avatar Drew Webber
Browse files

Issue #3007538 by poker10, torotil, DamienMcKenna, Jorrit, Fabianx: Cron.php...

Issue #3007538 by poker10, torotil, DamienMcKenna, Jorrit, Fabianx: Cron.php does not check for maintenance mode correctly
parent d7b56576
No related branches found
No related tags found
1 merge request!7330Issue #3306390 by poker10, catch, Fabianx, pwolanin, rvtraveller: [D7]...
......@@ -13,12 +13,12 @@
include_once DRUPAL_ROOT . '/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)) {
if (variable_get('maintenance_mode', 0)) {
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
drupal_site_offline();
}
elseif (!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();
}
else {
......
......@@ -1277,6 +1277,41 @@ class SiteMaintenanceTestCase extends DrupalWebTestCase {
// Log in with temporary login link.
$this->drupalPost($path, array(), t('Log in'));
$this->assertText($user_message);
$this->drupalLogout();
}
/**
* Verify access to cron.php with custom 403 page during maintenance mode.
*/
function testCronSiteMaintenance() {
global $base_url;
// Set custom 403 page.
$this->drupalLogin($this->admin_user);
$edit = array(
'title' => $this->randomName(10),
'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(100)))),
);
$node = $this->drupalCreateNode($edit);
// Use a custom 403 page.
$this->drupalPost('admin/config/system/site-information', array('site_403' => 'node/' . $node->nid), t('Save configuration'));
// Turn on maintenance mode.
$edit = array(
'maintenance_mode' => 1,
);
$this->drupalPost('admin/config/development/maintenance', $edit, t('Save configuration'));
$this->drupalLogout();
// Access cron.php without valid cron key.
$this->drupalGet($base_url . '/cron.php', array('external' => TRUE));
$this->assertResponse(503);
// Access cron.php with valid cron key.
$key = variable_get('cron_key', 'drupal');
$this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
$this->assertResponse(503);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment