Skip to content

Commit

Permalink
deprecation notice on missing cpTrigger strings
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuot committed Sep 30, 2024
1 parent 80b5d8a commit a86b849
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/http/requests/WebRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ public function setDefaultProperties(string $url)
}

$isCpRequest = $this->uriContainsAdminSlug($uri);
if ($isCpRequest) {
$uri = preg_replace('#^'.preg_quote(\Craft::$app->getConfig()->getGeneral()->cpTrigger).'/?#', '', $uri);
$cpTrigger = \Craft::$app->getConfig()->getGeneral()->cpTrigger;
if ($isCpRequest && $cpTrigger) {
$uri = preg_replace('#^'.preg_quote($cpTrigger).'/?#', '', $uri);
}

$this->setRaw([
Expand Down Expand Up @@ -161,7 +162,7 @@ public function setDefaultProperties(string $url)
protected function uriContainsAdminSlug(string $uri): bool
{
$path = parse_url($uri, PHP_URL_PATH);
$slug = \Craft::$app->getConfig()->getGeneral()->cpTrigger;
$slug = \Craft::$app->getConfig()->getGeneral()->cpTrigger ?? '';

return str_starts_with(ltrim($path, '/'), $slug);
}
Expand Down

0 comments on commit a86b849

Please sign in to comment.