Issue #3268612: StageValidationException does not provide a message based on validation results
Merge request reports
Activity
added 29 commits
-
204f0309...8bf9b100 - 27 commits from branch
project:8.x-2.x
- fccc4025 - Add getResultsAsText()
- 08fed501 - Fix test flaw
-
204f0309...8bf9b100 - 27 commits from branch
added 8 commits
-
c14762bd...d7246753 - 4 commits from branch
project:8.x-2.x
- a5634b8f - Add getResultsAsText()
- 611450b3 - Fix test flaw
- 79db41f9 - use message passed to constructor also
- 72db3f4a - try set state key
Toggle commit list-
c14762bd...d7246753 - 4 commits from branch
added 13 commits
-
72db3f4a...de3d6c71 - 9 commits from branch
project:8.x-2.x
- a8ee6829 - Add getResultsAsText()
- 204f0309 - Fix test flaw
- c07ab330 - Merge branch '8.x-2.x' into 3268612-stagevalidationexception-does-not
- ad4f7c3a - Merge branch '3268612-stagevalidationexception-does-not' of...
Toggle commit list-
72db3f4a...de3d6c71 - 9 commits from branch
added 1 commit
- 2231cb58 - Remove HTML formatting and move formatting tests into Package Manager
21 21 * 22 22 * @param \Drupal\package_manager\ValidationResult[] $results 23 23 * Any relevant validation results. 24 * @param string $message 25 * (optional) The exception message. Defaults to a plain text representation 26 * of the validation results. 24 27 * @param mixed ...$arguments 25 * Arguments to pass to the parent constructor. 28 * Additional arguments to pass to the parent constructor. 26 29 */ 27 public function __construct(array $results = [], ...$arguments) { 30 public function __construct(array $results = [], string $message = '', ...$arguments) { 28 31 $this->results = $results; 29 parent::__construct(...$arguments); 32 parent::__construct($message ?: $this->getResultsAsText(), ...$arguments); Could we actually send
$message
to$this->getResultsAsText()
and use it as the start of the message if set.For example in
Updater.php
we havecatch (StageValidationException $e) { throw new UpdateException($e->getResults(), $e->getMessage() ?: "Unable to complete the update because of errors.", $e->getCode(), $e); }
Since
UpdateException extends StageValidationException
for the example above$updater_exception->getMessage()
will always return "Unable to complete the update because of errors." and never contain the results. So this issue would not help any of the exceptions thrown here.Sure, we could do that, but refactoring this exception is tricky because of the major knock-on effect it has on the tests.
Here's my suggestion: in this issue, let's change Updater::dispatch() so that it removes the default message it passes to UpdateException. That should be a simpler fix. Maybe in a follow-up we could properly implement the ability to have a bit of preamble text before the results, since that is useful but not quite as urgent for DrupalCon.