Adds getAjaxHandler() API to controllers

Fixes bug where update process fails midway
This commit is contained in:
Samuel Georges 2015-06-30 07:55:54 +10:00
parent 56caa1db3d
commit f9c921a797
3 changed files with 40 additions and 9 deletions

View File

@ -355,17 +355,31 @@ class Controller extends Extendable
return $this->makeViewContent($result);
}
/**
* Returns the AJAX handler for the current request, if available.
* @return string
*/
public function getAjaxHandler()
{
if (!Request::ajax() || Request::method() != 'POST') {
return null;
}
if ($handler = Request::header('X_OCTOBER_REQUEST_HANDLER')) {
return trim($handler);
}
return null;
}
/**
* This method is used internally.
* Invokes a controller event handler and loads the supplied partials.
*/
protected function execAjaxHandlers()
{
if (Request::method() != 'POST') {
return null;
}
if ($handler = trim(Request::header('X_OCTOBER_REQUEST_HANDLER'))) {
if ($handler = $this->getAjaxHandler()) {
try {
/*
* Validate the handler name

View File

@ -566,17 +566,30 @@ class Controller
// AJAX
//
/**
* Returns the AJAX handler for the current request, if available.
* @return string
*/
public function getAjaxHandler()
{
if (!Request::ajax() || Request::method() != 'POST') {
return null;
}
if ($handler = Request::header('X_OCTOBER_REQUEST_HANDLER')) {
return trim($handler);
}
return null;
}
/**
* Executes the page, layout, component and plugin AJAX handlers.
* @return mixed Returns the AJAX Response object or null.
*/
protected function execAjaxHandlers()
{
if (Request::method() != 'POST') {
return null;
}
if ($handler = trim(Request::header('X_OCTOBER_REQUEST_HANDLER'))) {
if ($handler = $this->getAjaxHandler()) {
try {
/*
* Validate the handler name

View File

@ -43,6 +43,10 @@ class Updates extends Controller
BackendMenu::setContext('October.System', 'system', 'updates');
SettingsManager::setContext('October.System', 'updates');
if ($this->getAjaxHandler() == 'onExecuteStep') {
$this->useSecurityToken = false;
}
}
/**