diff --git a/lib/Drupal/views/ManyToOneHelper.php b/lib/Drupal/views/ManyToOneHelper.php index 280fa35..18320eb 100644 --- a/lib/Drupal/views/ManyToOneHelper.php +++ b/lib/Drupal/views/ManyToOneHelper.php @@ -307,7 +307,13 @@ class ManyToOneHelper { $this->handler->query->add_where_expression($options['group'], "$field $operator", $placeholders); } else { - $this->handler->query->add_where($options['group'], $field, $value, $operator); + $placeholder = $this->placeholder(); + if (count($this->handler->value) > 1) { + $this->query->add_where_expression(0, "$field $operator($placeholder)", array($placeholder => $value)); + } + else { + $this->handler->query->add_where_expression(0, "$field $operator $placeholder", array($placeholder => $value)); + } } } diff --git a/lib/Drupal/views/Plugin/views/join/Subquery.php b/lib/Drupal/views/Plugin/views/join/Subquery.php index 41583b6..913c866 100644 --- a/lib/Drupal/views/Plugin/views/join/Subquery.php +++ b/lib/Drupal/views/Plugin/views/join/Subquery.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\join; use Drupal\Core\Annotation\Plugin; +use Drupal\Component\Plugin\Discovery\DiscoveryInterface; /** * Join handler for relationships that join with a subquery as the left field. @@ -23,9 +24,13 @@ use Drupal\Core\Annotation\Plugin; */ class Subquery extends JoinPluginBase { - function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') { - parent::construct($table, $left_table, $left_field, $field, $extra, $type); - $this->left_query = $this->definition['left_query']; + /** + * Constructs a Subquery object. + */ + public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) { + parent::__construct($configuration, $plugin_id, $discovery); + + $this->left_query = $this->configuration['left_query']; } /** @@ -41,11 +46,11 @@ class Subquery extends JoinPluginBase { * */ public function buildJoin($select_query, $table, $view_query) { - if (empty($this->definition['table formula'])) { + if (empty($this->configuration['table formula'])) { $right_table = "{" . $this->table . "}"; } else { - $right_table = $this->definition['table formula']; + $right_table = $this->configuration['table formula']; } // Add our join condition, using a subquery on the left instead of a field. diff --git a/lib/Drupal/views/Tests/Handler/HandlerAllTest.php b/lib/Drupal/views/Tests/Handler/HandlerAllTest.php new file mode 100644 index 0000000..8b5bb3a --- /dev/null +++ b/lib/Drupal/views/Tests/Handler/HandlerAllTest.php @@ -0,0 +1,106 @@ + 'Handlers: All', + 'description' => 'Test instances of all handlers.', + 'group' => 'Views Handlers', + ); + } + + /** + * Tests most of the handlers. + */ + public function testHandlers() { + $object_types = array_keys(ViewExecutable::viewsHandlerTypes()); + foreach (views_fetch_data() as $base_table => $info) { + if (!isset($info['table']['base'])) { + continue; + } + + $view = views_new_view(); + $view->base_table = $base_table; + $view = new ViewExecutable($view); + + // @todo The groupwise relationship is currently broken. + $exclude[] = 'taxonomy_term_data:tid_representative'; + $exclude[] = 'users:uid_representative'; + + // Go through all fields and there through all handler types. + foreach ($info as $field => $field_info) { + // Table is a reserved key for the metainformation. + if ($field != 'table' && !in_array("$base_table:$field", $exclude)) { + foreach ($object_types as $type) { + if (isset($field_info[$type]['id'])) { + $options = array(); + if ($type == 'filter') { + $handler = views_get_handler($base_table, $field, $type); + if ($handler instanceof InOperator) { + $options['value'] = array(1); + } + } + $view->addItem('default', $type, $base_table, $field, $options); + } + } + } + } + + // Go through each step invidiually to see whether some parts are failing. + $view->build(); + $view->preExecute(); + $view->execute(); + $view->render(); + + // Make sure all handlers extend the HandlerBase. + foreach ($object_types as $type) { + if (isset($view->{$type})) { + foreach ($view->{$type} as $handler) { + $this->assertTrue($handler instanceof HandlerBase); + } + } + } + } + } + +} diff --git a/lib/Drupal/views/ViewExecutable.php b/lib/Drupal/views/ViewExecutable.php index 215ba2d..e311ebd 100644 --- a/lib/Drupal/views/ViewExecutable.php +++ b/lib/Drupal/views/ViewExecutable.php @@ -516,6 +516,10 @@ class ViewExecutable { if (!empty($this->pager)) { return $this->pager->use_pager(); } + // Maybe other code stores something on the view object, so allow that. + else { + $this->{$name} = $value; + } } /** diff --git a/lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php b/lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php index c4ec914..8da53dd 100644 --- a/lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php +++ b/lib/Views/taxonomy/Plugin/views/field/TaxonomyIndexTid.php @@ -26,7 +26,7 @@ class TaxonomyIndexTid extends PrerenderList { public function init(ViewExecutable $view, &$options) { parent::init($view, $options); // @todo: Wouldn't it be possible to use $this->base_table and no if here? - if ($view->base_table == 'node_revision') { + if ($view->storage->base_table == 'node_revision') { $this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid'); } else {