Skip to content

Commit

Permalink
Fix action route matching order
Browse files Browse the repository at this point in the history
Fixes #11435
  • Loading branch information
brandonkelly committed Jun 15, 2022
1 parent f87d4b6 commit acc565a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Fixed a bug where changes to existing Matrix blocks weren’t saving for element types that supported drafts but not change tracking. ([#11419](https://github.com/craftcms/cms/issues/11419))
- Fixed a bug where double-clicking on a related asset’s thumbnail could open the asset’s preview modal. ([#11424](https://github.com/craftcms/cms/issues/11424))
- Fixed a bug where the control panel wasn’t displaying file upload failure messages.
- Fixed a bug where `action` query params were taking precedence over `actionTrigger` URI matches, when handling action requests. ([#11435](https://github.com/craftcms/cms/issues/11435))

## 4.0.4 - 2022-06-03

Expand Down
23 changes: 14 additions & 9 deletions src/web/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,20 @@ public function checkIfActionRequest(bool $force = false, bool $checkToken = tru

private function _checkIfActionRequestInternal(bool $checkSpecialPaths): bool
{
// Important we check in this specific order:
// 1) /actions/some/action
// 2) any/uri?action=some/action
// 3) special/uri

// Trigger match?
if (
$this->getSegment(1) === $this->generalConfig->actionTrigger &&
count($this->getSegments()) > 1
) {
$this->_actionSegments = array_slice($this->getSegments(), 1);
return true;
}

// Action param?
if ($this->getNormalizedContentType() !== 'application/json') {
$actionParam = $this->getParam('action');
Expand All @@ -1627,15 +1641,6 @@ private function _checkIfActionRequestInternal(bool $checkSpecialPaths): bool
return true;
}

// Trigger match?
if (
$this->getSegment(1) === $this->generalConfig->actionTrigger &&
count($this->getSegments()) > 1
) {
$this->_actionSegments = array_slice($this->getSegments(), 1);
return true;
}

// Special path?
if (
$checkSpecialPaths &&
Expand Down

0 comments on commit acc565a

Please sign in to comment.