Commit 81aeb3cb authored by catch's avatar catch
Browse files

Issue #2796045 by Lendude, abarrio, ranjith_kumar_k_u, megan_m, joachim,...

Issue #2796045 by Lendude, abarrio, ranjith_kumar_k_u, megan_m, joachim, alexpott, estoyausente, larowlan: Adding a field with relationship results in confusing error message when relationship is not present

(cherry picked from commit 5d4b11b2)
parent 152704c0
......@@ -2522,7 +2522,12 @@ public function validate() {
foreach (ViewExecutable::getHandlerTypes() as $type => $handler_type_info) {
foreach ($this->getHandlers($type) as $handler) {
if (!empty($handler->options['relationship']) && $handler->options['relationship'] != 'none' && !in_array($handler->options['relationship'], $relationships)) {
$errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()]);
$errors[] = $this->t('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', [
'%relationship_name' => $handler->options['relationship'],
'%handler_type' => $handler_type_info['lstitle'],
'%handler' => $handler->adminLabel(),
'%display_name' => $this->display['display_title'],
]);
}
}
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\views\Functional\Plugin;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\views\Views;
......@@ -362,8 +363,8 @@ public function testMissingRelationship() {
$errors = $view->validate();
// Check that the error messages are shown.
$this->assertCount(2, $errors['default'], 'Error messages found for required relationship');
$this->assertEquals(t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => 'field', '%handler' => 'User: Last login']), $errors['default'][0]);
$this->assertEquals(t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => 'field', '%handler' => 'User: Created']), $errors['default'][1]);
$this->assertEquals(new FormattableMarkup('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', ['%relationship_name' => 'uid', '%handler_type' => 'field', '%handler' => 'User: Last login', '%display_name' => 'Default']), $errors['default'][0]);
$this->assertEquals(new FormattableMarkup('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', ['%relationship_name' => 'uid', '%handler_type' => 'field', '%handler' => 'User: Created', '%display_name' => 'Default']), $errors['default'][1]);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment