diff --git a/CHANGELOG.md b/CHANGELOG.md index 4105db8b..7d0176a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * Fixed admin user creation and password reset allowing unsafe passwords * Fixed missing validation when registering the first admin user * Fixed reset password email not to have session specific token in it + * Fixed admin controller running before setting `$grav['page']` # v1.10.7 ## 03/17/2021 diff --git a/admin.php b/admin.php index 2add3900..dd0c63df 100644 --- a/admin.php +++ b/admin.php @@ -449,22 +449,9 @@ class AdminPlugin extends Plugin $this->grav['page'] = $page; $this->admin->form = $controller->getActiveForm(); + $legacyController = false; } else { - // Handle tasks. - $this->admin->task = $task = $this->grav['task'] ?? $this->grav['action']; - if ($task) { - Admin::DEBUG && Admin::addDebugMessage("Admin task: {$task}"); - - // Make local copy of POST. - $post = $this->grav['uri']->post(); - - $this->initializeController($task, $post); - } elseif ($this->template === 'logs' && $this->route) { - // Display RAW error message. - $response = new Response(200, [], $this->admin->logEntry()); - - $this->grav->close($response); - } + $legacyController = true; } // Replace page service with admin. @@ -558,6 +545,25 @@ class AdminPlugin extends Plugin } } + if ($legacyController) { + // Handle tasks. + $this->admin->task = $task = $this->grav['task'] ?? $this->grav['action']; + if ($task) { + Admin::DEBUG && Admin::addDebugMessage("Admin task: {$task}"); + + // Make local copy of POST. + $post = $this->grav['uri']->post(); + + $this->initializeController($task, $post); + } elseif ($this->template === 'logs' && $this->route) { + // Display RAW error message. + $response = new Response(200, [], $this->admin->logEntry()); + + $this->grav->close($response); + } + + } + // Explicitly set a timestamp on assets $this->grav['assets']->setTimestamp(substr(md5(GRAV_VERSION . $this->grav['config']->checksum()), 0, 10)); }