diff --git a/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php b/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php index 8214b3d..3a036ac 100644 --- a/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php +++ b/core/modules/views/src/Plugin/views/join/FieldOrLanguageJoin.php @@ -67,36 +67,38 @@ class FieldOrLanguageJoin extends JoinPluginBase { * {@inheritdoc} */ protected function joinAddExtra(&$arguments, &$condition, $table, SelectInterface $select_query, $left_table = NULL) { + if (empty($this->extra)) { + return; + } + if (is_array($this->extra)) { $extras = []; foreach ($this->extra as $extra) { $extras[] = $this->buildExtra($extra, $arguments, $table, $select_query, $left_table); } - if ($extras) { - // Remove and store the langcode OR bundle join condition extra. - $language_bundle_conditions = []; - foreach ($extras as $key => &$extra) { - if (strpos($extra, '.langcode') !== FALSE || strpos($extra, '.bundle') !== FALSE) { - $language_bundle_conditions[] = $extra; - unset($extras[$key]); - } + // Remove and store the langcode OR bundle join condition extra. + $language_bundle_conditions = []; + foreach ($extras as $key => $extra) { + if (strpos($extra, '.langcode') !== FALSE || strpos($extra, '.bundle') !== FALSE) { + $language_bundle_conditions[] = $extra; + unset($extras[$key]); } + } - if (count($extras) == 1) { - $condition .= ' AND ' . array_shift($extras); - } - else { - $condition .= ' AND (' . implode(' ' . $this->extraOperator . ' ', $extras) . ')'; - } + if (count($extras) > 1) { + $condition .= ' AND (' . implode(' ' . $this->extraOperator . ' ', $extras) . ')'; + } + elseif ($extras) { + $condition .= ' AND ' . array_shift($extras); + } - // Tack on the langcode OR bundle join condition extra. - if (!empty($language_bundle_conditions)) { - $condition .= ' AND (' . implode(' OR ', $language_bundle_conditions) . ')'; - } + // Tack on the langcode OR bundle join condition extra. + if (!empty($language_bundle_conditions)) { + $condition .= ' AND (' . implode(' OR ', $language_bundle_conditions) . ')'; } } - elseif ($this->extra && is_string($this->extra)) { + elseif (is_string($this->extra)) { $condition .= " AND ($this->extra)"; } } diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php index dcb3e97..23a4732 100644 --- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php +++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php @@ -320,7 +320,7 @@ protected function joinAddExtra(&$arguments, &$condition, $table, SelectInterfac * Builds a single extra condition. * * @param array $info - * The extra information. See JoinPluginBase::$extra for details. + * The extra information. See JoinPluginBase::$extra for details. * @param array $arguments * Array of query arguments. * @param array $table diff --git a/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php b/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php index 66a7019..b838cbf 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php @@ -181,7 +181,6 @@ public function testLanguageBundleConditions() { ], ]; - // Build the actual join values and read them back from the query object. $query = \Drupal::database()->select('node');