Skip to content

Commit

Permalink
Merge branch '2.3' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 3, 2024
2 parents 0b16685 + 6e4b18a commit 5a3ebcc
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions code/ModelAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,29 @@ protected function init()
$models = $this->getManagedModels();
$this->modelTab = $this->getRequest()->param('ModelClass');

// security check for valid models
if ($this->modelTab && !$this->isManagedModel($this->modelTab)) {
// No need to check model tab since we are already redirected
// This happens when there's a permission failure in LeftAndMain
if ($this->redirectedTo()) {
// reset so we use the "landing page"
$this->modelTab = null;
} else {
// if it fails to match the string exactly, try reverse-engineering a classname
$this->modelTab = $this->unsanitiseClassName($this->modelTab);

if (!$this->isManagedModel($this->modelTab)) {
throw new \RuntimeException(sprintf('ModelAdmin::init(): Invalid Model class %s', $this->modelTab));
}
}
}

// if we've hit the "landing" page
if ($this->modelTab === null) {
reset($models);
$this->modelTab = key($models ?? []);
}

// security check for valid models
if (!$this->isManagedModel($this->modelTab)) {
// if it fails to match the string exactly, try reverse-engineering a classname
$this->modelTab = $this->unsanitiseClassName($this->modelTab);

if (!$this->isManagedModel($this->modelTab)) {
throw new \RuntimeException(sprintf('ModelAdmin::init(): Invalid Model class %s', $this->modelTab));
}
}

$this->modelClass = isset($models[$this->modelTab]['dataClass'])
? $models[$this->modelTab]['dataClass']
: $this->modelTab;
Expand Down

0 comments on commit 5a3ebcc

Please sign in to comment.