If an environment is created without a hostname entered, the following error is thrown:

InvalidArgumentException: The URI '/admin/config/development/environment-indicator/switcher' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 282 of /var/www/drupalvm/drupal/web/core/lib/Drupal/Core/Url.php).

In my use case I wish to have various environment templates set up as part of a profile, and this bug prevents my from doing this and having consistent settings across projects.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

john@johncook.me.uk created an issue. See original summary.

John Cook’s picture

The bug is caused in _environment_indicator_switcher_links() when constructing the links:

'url' => Url::fromUri($entity->getUrl() . $current_path),

Drupal\Core\Url->fromUri() throws the exception because the constructed URL does not have a scheme.

In the patch I've added a filter to remove any EnvironmentIndicator entities that do not have a URL before the link is constructed for them.

John Cook’s picture

Status: Active » Needs review

Set to 'needs review'.

pratik_kamble’s picture

Issue tags: +DIACWJuly2020
Jancy Christopher’s picture

Assigned: Unassigned » Jancy Christopher
Jancy Christopher’s picture

Assigned: Jancy Christopher » Unassigned

This patch works fine for me.

Steps followed.
- After configuring the Environment Indicator Module.
- Go to /admin/config/development/environment-indicator, in Environment Switcher tab Add a new environment by clicking the Add environment button.
- Add a new environment by giving an empty hostname. The above invalid uri issue occurs.
- After applying the patch this issue got resolved and able to create multiple Environments templates with empty hostname.
Thanks for the patch.

Jancy Christopher’s picture

Status: Needs review » Reviewed & tested by the community
e0ipso’s picture

Thanks for the patch!

  • e0ipso committed 228e913 on 4.x authored by John Cook
    Issue #3122913 by John Cook, Jancy Christopher, pratik_kamble, e0ipso: "...
e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.