diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php index faa92e1c082..7c923614d21 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php @@ -91,6 +91,29 @@ class SettingsTest extends UITestBase { views_invalidate_cache(); $this->drupalPost('admin/structure/views/add', $view, t('Continue & edit')); $this->assertNoFieldById('edit-displays-top-add-display-embed'); + + // Configure to hide/show the sql at the preview. + $edit = array( + 'ui_show_sql_query_enabled' => FALSE, + ); + $this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/structure/views/add', $view, t('Continue & edit')); + + $this->drupalPost(NULL, array(), t('Update preview')); + $xpath = $this->xpath('//div[@class="views-query-info"]/pre'); + $this->assertEqual(count($xpath), 0, 'The views sql is hidden.'); + + $edit = array( + 'ui_show_sql_query_enabled' => TRUE, + ); + $this->drupalPost('admin/structure/views/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/structure/views/add', $view, t('Continue & edit')); + + $this->drupalPost(NULL, array(), t('Update preview')); + $xpath = $this->xpath('//div[@class="views-query-info"]//pre'); + $this->assertEqual(count($xpath), 1, 'The views sql is shown.'); + $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.'); + $this->assertTrue(strpos($xpath[0], "node.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.'); } } diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php index 7905b8839c5..dda1c01b419 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -8,6 +8,8 @@ namespace Drupal\views_ui; use Drupal\views\ViewExecutable; +use Drupal\Core\Database\Database; +use Drupal\views\Plugin\views\query\Sql; /** * Stores UI related temporary settings. @@ -1791,7 +1793,7 @@ class ViewUI extends ViewExecutable { // Only the sql default class has a method getArguments. $quoted = array(); - if (get_class($this->query) == 'views_plugin_query_default') { + if ($this->query instanceof Sql) { $quoted = $query->getArguments(); $connection = Database::getConnection(); foreach ($quoted as $key => $val) {