Comments

sasanikolic created an issue. See original summary.

sasanikolic’s picture

Status: Active » Needs review
StatusFileSize
new691 bytes

Here is the fix.

alexpott’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

The fix looks good - anyway to test this?

timmillwood’s picture

StatusFileSize
new745 bytes
new743 bytes

Patch in #2 looks good to me, but wondering if this is slightly more readable.

sasanikolic’s picture

We could test it with having a invalid SQL query that breaks views.

dawehner’s picture

Ups things happen, but now we will add test coverage so we actually gained something from breaking it :)

sasanikolic’s picture

Issue summary: View changes
sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new4.78 KB
new4.05 KB

Here is the test for the exception.

timmillwood’s picture

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

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -1454,7 +1454,8 @@ function execute(ViewExecutable $view) {
+          $view_storage_label = $view->storage->label()[$view->storage->id()];
+          throw new DatabaseExceptionWrapper("Exception in {$view_storage_label}: {$e->getMessage()}");

I don't understand how the test is testing this code. Running the test without this code does not fail.

juanse254’s picture

Please provide a TEST-Only with the test so we know that the test is actually failing without the fix.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new4.73 KB
new2.6 KB

1.) Reverted the exception in Sql.php, because it returns an invalid php syntax error,
2.) Made the query break in the test
3.) Now we're checking that the view label and id are in there as expected in the thrown exception.

sasanikolic’s picture

StatusFileSize
new4.06 KB

Here is the test-only patch.

Status: Needs review » Needs work

The last submitted patch, 13: error_in_case_of_a-2547357-13.patch, failed testing.

edurenye’s picture

Status: Needs work » Needs review

Seems fine for me.
Next time remember to add the -test_only suffix in the name of the test only patch.

berdir’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Yes, #4 was wrong, this is *not* php array access. It's about displaying this string: "My super view[my_super_view_id]".

  1. +++ b/core/modules/views/src/Tests/Plugin/FilterExceptionTest.php
    @@ -0,0 +1,85 @@
    +/**
    + * Tests the exception filter.
    + *
    + * @group views
    + * @see test_exception_filter
    + */
    +class FilterExceptionTest extends PluginTestBase {
    

    I don't think that such a @see works? There is no function that it can point to, if anything, then we need to make it a reference to the plugin class?

    We are not testing the exception filter here. We are testing the views exception handling, so this should be called ViewsSqlExceptionTest or something like that. With a matching comment.

  2. +++ b/core/modules/views/src/Tests/Plugin/FilterExceptionTest.php
    @@ -0,0 +1,85 @@
    +  public static $modules = array('views_ui');
    

    Do we really need the views_ui module to be enabled here?

  3. +++ b/core/modules/views/src/Tests/Plugin/FilterExceptionTest.php
    @@ -0,0 +1,85 @@
    +  public function testFilterException() {
    

    This would then be called testSqlExeption()

  4. +++ b/core/modules/views/src/Tests/Plugin/FilterExceptionTest.php
    @@ -0,0 +1,85 @@
    +    // Check that we can find the test filter plugin.
    +    $plugin = $this->container->get('plugin.manager.views.filter')->createInstance('test_exception_filter');
    +    $this->assertTrue($plugin instanceof FilterPluginException, 'Test filter exception plugin found.');
    

    Comment is outdated and I actually think those three lines are useless, we don't need to test that the plugin exists here.

  5. +++ b/core/modules/views/src/Tests/Plugin/FilterExceptionTest.php
    @@ -0,0 +1,85 @@
    +    // Change the filtering.
    

    Add a more specific comment here, say that you add a filter that will result in an invalid query.

  6. +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterExceptionTest.php
    @@ -0,0 +1,52 @@
    +   */
    +  protected function defineOptions() {
    +    $options = parent::defineOptions();
    +
    +    $options['test_enable'] = array('default' => TRUE);
    +    return $options;
    +  }
    +
    +  /**
    +   * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
    +   *
    +   * @return array
    +   */
    +  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +    parent::buildOptionsForm($form, $form_state);
    +
    +    $form['test_enable'] = array(
    +      '#type' => 'checkbox',
    +      '#title' => $this->t('Controls whether the filter plugin should be active'),
    +      '#default_value' => $this->options['test_enable'],
    +    );
    +  }
    +
    

    We don't need all this.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new3.59 KB
new3.61 KB

Changes for the comment(s) above.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

It is great that we have test coverage now.

+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterExceptionTest.php
@@ -0,0 +1,24 @@
+  /**
+   * Overrides Drupal\views\Plugin\views\filter\FilterPluginBase::query().
+   */

We could just use {@inheritdoc}

sasanikolic’s picture

Added the @inheritdoc to the test.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 19: error_in_case_of_a-2547357-19.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new3.54 KB
new719 bytes

Rebased.

Status: Needs review » Needs work

The last submitted patch, 21: error_in_case_of_a-2547357-21.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
juanse254’s picture

Status: Needs review » Reviewed & tested by the community

Everything seems to work accordingly.

mbovan’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php
    @@ -0,0 +1,73 @@
    +use Drupal\views_test_data\Plugin\views\filter\FilterExceptionTest as FilterPluginException;
    

    Not used.

  2. +++ b/core/modules/views/src/Tests/Plugin/ViewsSqlExceptionTest.php
    @@ -0,0 +1,73 @@
    +
    +  public function testSqlExeption() {
    

    Typo and missing doc block.

  3. +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/filter/FilterExceptionTest.php
    @@ -0,0 +1,24 @@
    +/**
    + * @ViewsFilter("test_exception_filter")
    + */
    

    Missing short class description.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new3.56 KB
new1.48 KB

Fixes for the comment above.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now I think.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed b833f73 and pushed to 8.0.x. Thanks!

  • alexpott committed b833f73 on 8.0.x
    Issue #2547357 by sasanikolic, timmillwood, Berdir, mbovan: $error in...

Status: Fixed » Closed (fixed)

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