Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
#1933 (comment)
#1933 (comment)
  • Loading branch information
micgro42 committed Apr 6, 2018
1 parent fcbc613 commit b384ead
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions inc/ActionRouter.php
Expand Up @@ -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();
}

/**
Expand All @@ -62,6 +54,17 @@ public static function getInstance($reinit = false) {
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
*
Expand Down
1 change: 1 addition & 0 deletions inc/actions.php
Expand Up @@ -14,6 +14,7 @@
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');
Expand Down

0 comments on commit b384ead

Please sign in to comment.