After update to 7-3.16 started to get this

Warning: Invalid argument supplied for foreach() in views_join->build_join() (line 1548 of ./sites/all/modules/views/includes/handlers.inc).

I need to make some patch or wait for next version?

Comments

Dmitry Pogodaev created an issue. See original summary.

damienmckenna’s picture

Version: 7.x-3.16 » 7.x-3.x-dev
Status: Active » Needs review
Related issues: +#1930288: views_join: wrong handling of $extra parameter
StatusFileSize
new730 bytes

Could you please install the Devel module and test to see what $this->extra is if it isn't an array?

Out of interest, does this help?

Status: Needs review » Needs work

The last submitted patch, 2: views-n2866370-2.patch, failed testing.

schwarli4783’s picture

I have the same problem. In my case $this->extra has the value entity_translation_node.entity_type = 'node'
It seems that the problem occurs if you have installed the entity_translation module.

Dmitry Pogodaev’s picture

I'm also detected, that this accured if i use
https://www.drupal.org/project/language_fallback filter.
If i switch it off, error not shows.

And one more: if it's switched ON, i see more results then should. 1 node showing as many times as i set in view limit.

Sorry for late response. Didn't get any notification on e-mail...

Dmitry Pogodaev’s picture

It seems that the problem occurs if you have installed the entity_translation module.

I agree

It's not about language fallback, but about entity translation in views

Out of interest, does this help?

This patch remove the warning, but content still filteterd wrong and i see in views result to much copies of 1 node

dotline’s picture

There is also a problem when you have
https://www.drupal.org/project/views_natural_sort
installed

alzz’s picture

I have installed entity_reference module (7.x-1.0-beta6).
$this->extra as #4 says has the value "entity_translation_node.entity_type = 'node'".

Applied #2 patch and removes the warning and the view does not duplicated results for me, working good.

bohz’s picture

I also agree this is caused by the recent update in entity_translation.
Patch #2 doesn't resolve. The warning message is unvaried.
However I do not experience duplicates in my views.
Cheers

hartsak’s picture

I just noticed that my error log was also filled with the mentioned warning. In my case $this->extra seems to have at least these values:

entity_translation_node.entity_type = 'node'
entity_translation_field_collection_item.entity_type = 'field_collection_item'

I applied the patch #2 and I'm not getting those errors any more. I just have to look into my other views as well (there are so many). I didn't notice any problems with the view results, though.

Thanks for the patch!

loze’s picture

I have this error also. Not using entity_translation or views_natural_sort

perarg’s picture

This patch works for me. Thank you

steveganz’s picture

This patch removes the warning but we are not using entity_translation or views_natural_sort

rudi teschner’s picture

StatusFileSize
new564 bytes

#2 is not working for me. Even though it prevents the error messages, the view results contain duplicates (the entity translation filter is not applied, so all translations are shown).

From a logical point of view, the patch in #2 only considers arrays, so any value provided not as an array is discarded.

A slightly different approach would be to check whether extra is just a string and convert it into an array. That way, the warnings are gone and the views dont produce duplicate results (at least in my case).

sergei_brill’s picture

The bug appeared due to this fix https://www.drupal.org/node/1930288
As I see, documentation says property extra must be an array but modules mentioned above sets extra as a string. I think it's not a bug of module views. We should create issues in appropriate modules and fix setting of a string in extra property of views_join class.

knalstaaf’s picture

#14 works for us (haven't tried #2).

steveganz’s picture

#14 works for us as well.

berenddeboer’s picture

Agree with #15, bad code should be fixed. I had a case in my code where I had a string instead of an array. What about we log a warning when it's a string with a clear indication on how to fix it?

attisan’s picture

#14 works for me

alfthecat’s picture

#14 seems to work for me too. Thanks for the patch!

nironan’s picture

@loze - I found the same issue on select_translation too, perhaps you are using it too? I will file a patch there soon.

@sergei_brill - the website documentation still reports extra as An array of extra conditions on the join. Each condition is either a string that's directly added, or an array of items. Should we update it too?

rosk0’s picture

Status: Needs work » Closed (works as designed)

Completely agree with #15, bad code should be fixed. I had a case in my code where I had a string instead of an array.

Closing because there is nothing to fix in views itself.

j-lee’s picture

artis’s picture

Anyone having this issue with views_natural_sort, there is now a patch against the 2.x release of that module that fixes it.
https://www.drupal.org/node/2866668#comment-12098172

drupalfan2’s picture

I have the same error after updating to 7.x-3.16 .

And the views pages look very different (mixing up the nodes from the second language used on my site).

So views 3.16 can not be used at the moment.

Will there be any solution?

marco-s’s picture

I agree with #15, bad code should be fixed. But I think #14 is a reasonable fallback. Thanks for the patch!

hargobind’s picture

StatusFileSize
new1.11 KB

I'm in agreement about fixing bad code, but there are still plenty of people who just need their site to work with the latest version of views. So I'm submitting one more patch to this issue even though it's closed. It's based on #14, but the code has been moved inside of the if (isset($this->extra)) check. And it has also been added to the views_join_subquery class.

joey-santiago’s picture

Hello!

Could you please help me understand why my code causes this issue?

if ($view->base_table == "node") {
      $condition = db_and()
        ->condition('entity_translation_node.entity_type', 'node', '=');
      $query->add_where(
        0, $condition
      );
    }

put into a hook_views_query_alter implementation.

The reason i need this is the query is by default built in a way that creates duplicates as it is not filtering for the entity_translation type so that a translated file for ex would make a duplicate.
thanks

damienmckenna’s picture

Status: Closed (works as designed) » Needs review

No, I'll accept that it'd be useful to convert $this->extra to an array.

Status: Needs review » Needs work

The last submitted patch, 27: views-warning_invalid-2866370-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

hossein425’s picture

@sergei_brill #15

As I see, documentation says property extra must be an array but modules mentioned above sets extra as a string

The documentation states that directly added string is acceptable in array items not as extra itself.

  • extra: An array of extra conditions on the join. Each condition is
    either a string that's directly added, or an array of items:
damienmckenna’s picture

Status: Needs work » Needs review

The tests were broken but are now fixed, so lets see if this passes.

damienmckenna’s picture

FYI there was also an instance where the 'extra' parameter was not defined properly in the module itself, see #2852791: Undefined index: field_example in views_handler_filter_term_node_tid->exposed_validate() for details.

damienmckenna’s picture

Status: Needs review » Fixed

The tests pass, so this is good. Thanks everyone for helping to track down the problem!

damienmckenna’s picture

  • DamienMcKenna committed 5e00d96 on 7.x-3.x
    Issue #2866370 by hargobind, Rudi Teschner, DamienMcKenna, schwarli4783...

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture