Drupal 8 问题:InvalidArgumentException:URI '' 无效
Drupal 8 issue: InvalidArgumentException: The URI '' is invalid
我正在为这个问题苦苦挣扎:
InvalidArgumentException: The URI '' is invalid.
You must use a valid URI scheme. in Drupal\Core\Url::fromUri()
(line 284 of core/lib/Drupal/Core/Url.php).
我该如何解决这个问题?
从 fromUri() function it would appear as though it throws that error when the PHP parse_url 函数的源代码来看 returns 一个空方案:
... elseif (empty($uri_parts['scheme'])) { throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme."); ...
根据我在您的问题中收集到的信息,您似乎向 fromUri 方法提供了一个 empty/null 值,这反过来导致脚本在尝试解析该值时出错。所以我想你需要在将它传递给 fromUri 函数之前做一些检查。
fromUri 页面的评论部分提供了有关如何使用此方法的示例:https://api.drupal.org/comment/61905#comment-61905
您正在将空白 uri
传递到方法中。它抱怨缺少方案(例如 http://
或 https://
,或内部方案,例如:internal:/
)
因此,要么您明确传递了空白,要么设置不正确。但是,它似乎不是空的。
我在 Drupal 8 站点中遇到了类似的问题,请确保您的文件目录路径设置正确
我的案例文件路径是 Private 并且未在 settings.php 中配置。
$settings['file_private_path'] = 'sites/default/files/private';
我正在为这个问题苦苦挣扎:
InvalidArgumentException: The URI '' is invalid.
You must use a valid URI scheme. in Drupal\Core\Url::fromUri()
(line 284 of core/lib/Drupal/Core/Url.php).
我该如何解决这个问题?
从 fromUri() function it would appear as though it throws that error when the PHP parse_url 函数的源代码来看 returns 一个空方案:
... elseif (empty($uri_parts['scheme'])) { throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme."); ...
根据我在您的问题中收集到的信息,您似乎向 fromUri 方法提供了一个 empty/null 值,这反过来导致脚本在尝试解析该值时出错。所以我想你需要在将它传递给 fromUri 函数之前做一些检查。
fromUri 页面的评论部分提供了有关如何使用此方法的示例:https://api.drupal.org/comment/61905#comment-61905
您正在将空白 uri
传递到方法中。它抱怨缺少方案(例如 http://
或 https://
,或内部方案,例如:internal:/
)
因此,要么您明确传递了空白,要么设置不正确。但是,它似乎不是空的。
我在 Drupal 8 站点中遇到了类似的问题,请确保您的文件目录路径设置正确
我的案例文件路径是 Private 并且未在 settings.php 中配置。
$settings['file_private_path'] = 'sites/default/files/private';