Skip to content

Commit

Permalink
Merge pull request #25 from christopherdarling/patch-1
Browse files Browse the repository at this point in the history
FIX CMSPreview 500 error
  • Loading branch information
bendubuisson authored Jun 26, 2017
2 parents 34cdd75 + af62f7e commit a9e4ad1
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@

require_once __DIR__.'/../framework/core/Core.php';

$request = new SS_HTTPRequest(
$_SERVER['REQUEST_METHOD'],
isset($_GET['url']) ? $_GET['url'] : '',
$_GET
);
\Versioned::choose_site_stage();

$headers = Director::extract_request_headers($_SERVER);
// Only skip framework/main.php if live stage
if (\Versioned::current_stage() == \Versioned::get_live_stage()) {

foreach ($headers as $header => $value) {
$request->addHeader($header, $value);
}
$request = new SS_HTTPRequest(
$_SERVER['REQUEST_METHOD'],
isset($_GET['url']) ? $_GET['url'] : '',
$_GET
);

$container = Injector::inst();
$headers = Director::extract_request_headers($_SERVER);

$session = $container->create('Session', array());
if (Session::request_contains_session_id()) {
$session->inst_start();
}
foreach ($headers as $header => $value) {
$request->addHeader($header, $value);
}

$container = Injector::inst();

$container->get('RequestProcessor')->preRequest($request, $session, DataModel::inst());
$session = $container->create('Session', array());
if (Session::request_contains_session_id()) {
$session->inst_start();
}

$container->get('RequestProcessor')->preRequest($request, $session, DataModel::inst());
}

require_once __DIR__.'/../framework/main.php';

0 comments on commit a9e4ad1

Please sign in to comment.