Problem/Motivation
When hitting a site with at least one block configured with a request_path condition on any URL prefixed with index.php
(i.e example.com/index.phpfoo
, the following error is thrown (truncated stacktrace for brevity)
InvalidArgumentException: Source path foo has to start with a slash. in Drupal\path_alias\AliasManager->getAliasByPath() (line 185 of core/modules/path_alias/src/AliasManager.php).
Drupal\system\Plugin\Condition\RequestPath->evaluate() (Line: 77)
Drupal\Core\Condition\ConditionManager->execute() (Line: 84)
Drupal\Core\Condition\ConditionPluginBase->execute() (Line: 26)
Steps to reproduce
- Clean Drupal installation
- Go to admin/structure/block, edit any (for example: Search) block that appears on the frontpage
- Go to pages tab and set
/user/*
and click "Show for the listed pages" - Go to your.site/index.php.php
- There is an exception:
InvalidArgumentException: Source path .php has to start with a slash. in Drupal\Core\Path\AliasManager->getAliasByPath() (line 229 of core/lib/Drupal/Core/Path/AliasManager.php).
Proposed resolution
Potentially always prefix $path
with a forward slash.