This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into CD-43-header-footer
* origin/develop: ES-141: Set initial value for high-water mark ES-141: Use high-water mark for locations ES-141: Use high-water mark Fix typo in reliefweb sync ES-141: CS ES-141: Check source field length, add logging OPS-4872: Add Maintenance 200 module
- Loading branch information
Showing
11 changed files
with
561 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
339 changes: 339 additions & 0 deletions
339
html/sites/all/modules/contrib/maintenance200/LICENSE.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Maintenance 200 Module | ||
|
||
Description | ||
-------------- | ||
The Maintenance 200 module allows a site to return a Status code of 200 rather | ||
than the default 503 (Service Unavailable) code. "But wait," you ask, "why | ||
would I want that? The site is truly in a 503 state and should report that." The | ||
reason you'd want to return a 200 is so that your CDN or caching layer (e.g., Varnish) | ||
will cache the maintenance page and serve it to new requests rather than passing | ||
the request down to your origin server. | ||
|
||
Admittedly, this is kind of a double edge sword, since once the page is in cache | ||
you'll have to flush your cache to bring the site back up, which may incur more origin | ||
load that is spared by caching the maintenance page, but c'est la vie. | ||
|
||
Installation | ||
-------------- | ||
Just like any other Drupal module. | ||
|
||
Configuration | ||
----------------- | ||
The module adds a set of radio buttons to the core Maintenance Mode form. | ||
Simply select the desired HTTP status code and that value will be returned when | ||
the site is in maintenance mode. |
14 changes: 14 additions & 0 deletions
14
html/sites/all/modules/contrib/maintenance200/maintenance200.info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name = "Maintenance 200" | ||
description = "Allows the maintenance page to return a Status of 200 rather than the standard 503 code." | ||
core = "7.x" | ||
|
||
configure = admin/config/development/maintenance | ||
|
||
files[] = maintenance200.test | ||
|
||
; Information added by Drupal.org packaging script on 2015-03-08 | ||
version = "7.x-1.1" | ||
core = "7.x" | ||
project = "maintenance200" | ||
datestamp = "1425773226" | ||
|
40 changes: 40 additions & 0 deletions
40
html/sites/all/modules/contrib/maintenance200/maintenance200.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Code for the Maintenance 200 module. | ||
*/ | ||
|
||
/** | ||
* Implements hook_preprocess_HOOK(). | ||
* | ||
* Set the Status header to the selected code when the maintenance page | ||
* is preprocessed. | ||
*/ | ||
function maintenance200_preprocess_maintenance_page(&$vars) { | ||
drupal_add_http_header('Status', variable_get('maintenance_mode_status', '200 OK')); | ||
} | ||
|
||
/** | ||
* Implements hook_form_FORM_ID_alter(). | ||
* | ||
* Add elements for setting the maintenance mode status code to the maintenance form. | ||
*/ | ||
function maintenance200_form_system_site_maintenance_mode_alter(&$form, $form_state, $form_id) { | ||
$form['maintenance_mode_status'] = array( | ||
'#type' => 'radios', | ||
'#title' => t('Maintenance mode response code'), | ||
'#description' => t('This option controls what HTTP Status is returned when the site is in maintenance mode. 503 is the Drupal default.'), | ||
'#default_value' => variable_get('maintenance_mode_status', '200 OK'), | ||
'#options' => array( | ||
'200 OK' => '200 OK', | ||
'500 Internal Server Error' => '500 Internal Server Error', | ||
'501 Not Implemented' => '501 Not Implemented', | ||
'502 Bad Gateway' => '502 Bad Gateway', | ||
'503 Service Unavailable' => '503 Service Unavailable', | ||
'504 Gateway Time-out' => '504 Gateway Time-out', | ||
), | ||
); | ||
|
||
// Drive the maintenance_mode_message input down below the status input. | ||
$form['maintenance_mode_message']['#weight'] = 1; | ||
} |
39 changes: 39 additions & 0 deletions
39
html/sites/all/modules/contrib/maintenance200/maintenance200.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* @file | ||
* | ||
* Tests functionality of the Maintenance 200 module. | ||
*/ | ||
|
||
/** | ||
* Tests functionality of the Maintenance 200 module. | ||
*/ | ||
class Maintenance200TestCase extends DrupalWebTestCase { | ||
public static function getInfo() { | ||
return array( | ||
'name' => 'Maintenance 200', | ||
'description' => 'Ensure that the Maintenance 200 module returns the selected HTTP Status when maintenance mode is enabled.', | ||
'group' => 'Maintenance 200', | ||
); | ||
} | ||
|
||
public function setUp() { | ||
// Enable the Maintenance 200 module. | ||
parent::setUp('maintenance200'); | ||
|
||
// Login as an admin user. | ||
$admin = $this->drupalCreateUser(array('administer site configuration')); | ||
$this->drupalLogin($admin); | ||
|
||
// Put the site into mainenance mode and set the status to 200. | ||
$form = array(); | ||
$form['maintenance_mode'] = 1; | ||
$this->drupalPost('admin/config/development/maintenance', $form, t('Save configuration')); | ||
} | ||
|
||
public function testMaintenance200Status() { | ||
$this->assertTrue(variable_get('maintenance_mode', FALSE), 'Site is in maintenance mode.'); | ||
$this->drupalGet(''); | ||
$this->assertResponse(200, 'Site returns a 200 Status code.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters