refactor: don't setup $ACT in ActionRouter constructor

This caused problems with using the ActionRouter in actionOK, because
actionOK is first called during the initialization of $INFO, which in
turn must be initialized for checking modes like admin.

See
https://github.com/splitbrain/dokuwiki/pull/1933#issuecomment-290693452
https://github.com/splitbrain/dokuwiki/pull/1933#issuecomment-377298777
This commit is contained in:
Michael Große 2018-04-06 17:34:34 +02:00
parent fcbc6130e8
commit b384ead49e
No known key found for this signature in database
GPG Key ID: 7E31028FBFEACC79
2 changed files with 12 additions and 8 deletions

View File

@ -32,21 +32,13 @@ class ActionRouter {
/**
* ActionRouter constructor. Singleton, thus protected!
*
* Sets up the correct action based on the $ACT global. Writes back
* the selected action to $ACT
*/
protected function __construct() {
global $ACT;
global $conf;
$this->disabled = explode(',', $conf['disableactions']);
$this->disabled = array_map('trim', $this->disabled);
$this->transitions = 0;
$ACT = act_clean($ACT);
$this->setupAction($ACT);
$ACT = $this->action->getActionName();
}
/**
@ -62,6 +54,17 @@ class ActionRouter {
return self::$instance;
}
/**
* Sets up the correct action based on the $ACT global. Writes back the selected action to $ACT
*/
public function setupACT() {
global $ACT;
$ACT = act_clean($ACT);
$this->setupAction($ACT);
$ACT = $this->action->getActionName();
}
/**
* Setup the given action
*

View File

@ -14,6 +14,7 @@ if(!defined('DOKU_INC')) die('meh.');
function act_dispatch(){
// always initialize on first dispatch (test request may dispatch mutliple times on one request)
$router = \dokuwiki\ActionRouter::getInstance(true);
$router->setupACT();
$headers = array('Content-Type: text/html; charset=utf-8');
trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders');